event
The event function is normally called once for every entity this material is assigned
to.
Alternatively, other event modes can be set through the ENABLE_TREE, ENABLE_RENDER, or ENABLE_VIEW flags. Material events
are used to initialize material, bitmap and entity properties.
A7.11 The material pointer is set to the predefined mtl pointer and passed as first argument to the event function.
Type:
function
Modified:
mtl - predefined material pointer, set to the material
my - predefined entity pointer, set to the entity.
Remarks:
- If the material is not assigned to any entity,
the event is normally never called (except for view materials or ENABLE_VIEW
events). For merely initializing the material, use
a startup function.
- Breakpoints can not be placed in material events.
- A7
The predefined mtl pointer
can be used for temporarily switching the material depending on
the current view when changed in an ENABLE_RENDER material
event. The newly set material overrides any materials or effects from the
model. An effect is not necessary anymore for triggering the event (see
example 2):
Example:
function mtl_enviro_init()
{
bmap_to_cubemap(bmap_for_entity(my,1)); // convert the entity's skin 1 to a cube map
return(0);
}
MATERIAL* mtl_enviro =
{
event = mtl_enviro_init;
...
}
Example 2:
// switch between different materials dependent on the view (A7 only)
function mtl_event_render()
{
if (render_view == view_radar) {
mtl = mtl_radar; return(0);
}
if (render_view == view_depth) {
mtl = mtl_depth; return(0);
}
...
}
...
MATERIAL* mtl_plain =
{
event = mtl_event_render;
flags = ENABLE_RENDER;
...
}
See also:
material flags
► latest
version online