view_to_light (VIEW* view, var num,var mode);
Sets the given view to the position of a shadow throwing dynamic light, for rendering a scene from a light position.
Copies light data into the hit struct.
view - the view to be set to the light position,
num - the light number from 1 = closest to 8 = furthest.
mode - CAST = consider only lights with a CAST flag; SPOTLIGHT = consider only spot lights.
Number of lights yet to render that overlap with the frustum of the current view, including the current light (0..8).
view.x y z - set to the light position.
view.clip_near- set to 1.
view.clip_far - set to the light range.
view.pan tilt - set to the light angles if it is a spot or directional light; otherwise unaffected.
view.genius - set to the light emitting entity, or to NULL if it's a light placed
in the level.
hit.x y z - set to the light position.
hit.nx ny nz - set to the light direction.
hit.blue green red - set to the light color.
hit.entity - set to the light emitting entity, or to NULL if it's a light placed in the level.
hit.model - pointer to the D3DLIGHT9 struct of the light.
Only lights with a range fully or partially within the view frustum, and the sun light are detected by this function.
- If this function is called during rendering, i.e. in a view material render event, the frustum of the current view is used for determining the closest lights. Otherwise the light_view view frustum is used. Note: the view passed as parameter has no affect on determining the closest lights!
Slow when called the first time for the current view; fast in subsequent calls.
A7.20 C LC
// sets up to six views for rendering from a light position
// returns 0, 1, or 6 dependent on how many views are to render for this light
view_light_front.pan = -1; // for checking whether it's a spot light
var num = view_to_light(view_light_front,light_num,CAST); // set view to the light position
if (num == 0) return 0; // no further shadow throwing lights to render
if (view_light_front.pan >= 0) return 1; // sun or spot light? render front view only
view_light_front.pan = 0;
VIEW, stage, c_scan,view_to_matrix,