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:

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