event
The event function is called once for every entity this material is assigned to,
or (in case of a view material) once before the assigned view is rendered.
It is normally used to initialize the MATERIAL struct, generate required bitmaps etc. Different event modes can be set through the ENABLE_TREE, ENABLE_RENDER, or ENABLE_VIEW flags. The material pointer is passed as the 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 (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
}
MATERIAL* mtl_enviro =
{
event = mtl_enviro_init;
...
}
Example 2:
// switch between different entity materials dependent on the current view
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, render_view, mtl
► latest version online