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.




mtl - predefined material pointer, set to the material
- predefined entity pointer, set to the entity.



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