material.enable_render
If this flag is set, the material's event function is executed at the beginning
of every entity rendering, if the material contains an effect and was assigned
to the entity. This can be used to perform effect calculations based on entity
skills or the entity's world matrix.
Range:
on - material event function will executed at the beginning of
every entity rendering
off - material event function will executed once per entity.
Type:
Flag
Edition
C P
Remarks:
- If the event function returns 1, the entity is not rendered by the
engine. A user rendering function can be implemented this way. For rendering
the entity, 0 must be returned.
- At event time, the texture and render stages of the 3D hardware are already
set. Thus changing entity parameters in the event has no effect on the immediate
rendering - use ENABLE_TREE
for this.
- The debugger can not be used for ENABLE_RENDER events.
Example:
// generate a matrix that transforms camera space back to world space
function mtl_env_view()
{
mat_set(mtl.matrix,matViewInv);
// reset the translation part of the matrix
mtl.matrix41 = 0; // 0 == float(0)
mtl.matrix42 = 0;
mtl.matrix43 = 0;
return(0); // render the entity
}
function mtl_env_init()
{
bmap_to_cubemap(mtl.skin1);
mtl.event = mtl_env_view;
mtl.enable_render = on; // run the event at the beginning of every entity rendering
}
material mtl_envcube // environment cube
{
skin1 = bmp_envcube;
event = mtl_env_init;
...
}
See also:
material.event, material.matrix