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. A7.64 Copies light data into the hit struct.


view - the view to be set to the light position, or NULL.
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. 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.



Slow when called the first time for the current view; fast in subsequent calls.


A7.20  C   LC 

Example (lite-C):

// 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
function shadowmap_view_setup(light_num)
  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;
  return 6;

See also:

VIEW, stage, c_scan,view_to_matrix, ent_nextlight

► latest version online