LW Item Info 2 Locale Info Globals Table of Contents

"LW Light Info 2"

Availability:  LightWave 6.0
Component:  Layout

The light info global returns functions for getting light-specific information about any of the lights in a scene. Use the item info global to get the light list and for generic item information. The information returned by these functions is read-only.

Global Call

   LWLightInfo *lightinfo;
   lightinfo = global( "LW Light Info", GFUSE_TRANSIENT );

The global function returns a pointer to an LWLightInfo.

   typedef struct st_LWLightInfo {
      void         (*ambient)    (LWTime, LWDVector color);
      int          (*type)       (LWItemID);
      void         (*color)      (LWItemID, LWTime, LWDVector color);
      int          (*shadowType) (LWItemID);
      void         (*coneAngles) (LWItemID, double *radius, double *edge);
      unsigned int (*flags)      (LWItemID);
      double       (*range)      (LWItemID);
   } LWLightInfo;
ambient( time, color )
Returns the color of the global ambient light for the scene at the given time. The RGB levels include the effect of the user's intensity setting for the ambient light.

lighttype = type( light )
Returns the type of the light as one of the following values.

LWLIGHT_DISTANT
LWLIGHT_POINT
LWLIGHT_SPOT
LWLIGHT_LINEAR
LWLIGHT_AREA

color( time, light, rgb )
Sets the rgb argument to the color of the light (with intensity factored in) at the given time.

shadowtype = shadowType( light )
Returns the shadow type for the light as one of the following values.

LWLSHAD_OFF
LWLSHAD_RAYTRACE
LWLSHAD_MAP

coneAngles( light, radius, edge )
Returns the cone angles for spotlights. radius receives an angle that is half the total light cone angle, and edge receives the angular width of the soft edge.

settings = flags( light )
Returns flag bits for settings related to the light.

LWLFL_LIMITED_RANGE
LWLFL_NO_DIFFUSE
LWLFL_NO_SPECULAR
LWLFL_NO_CAUSTICS
LWLFL_LENS_FLARE
LWLFL_VOLUMETRIC

dist = range( light )
Returns the range or nominal distance for the light. The interpretation of this value depends on the falloff type. If falloff is linear, the value is the distance at which the intensity of the light is 0.0. For inverse distance falloff types, the value is the distance at which the intensity equals the user's intensity setting for the light. When there's no falloff, the return value is undefined.
 

Example

This code fragment collects information about the first light.

   #include <lwserver.h>
   #include <lwrender.h>

   LWItemInfo *iteminfo;
   LWLightInfo *ltinfo;
   LWItemID id;
   LWTime t = 3.0;          /* seconds */
   LWDVector color;
   double range, radius, edge;
   int lighttype, shadowtype;
   unsigned int flags;

   iteminfo = global( "LW Item Info 2", GFUSE_TRANSIENT );
   ltinfo   = global( "LW Light Info 2", GFUSE_TRANSIENT );

   if ( iteminfo && ltinfo ) {
      id = iteminfo->first( LWI_LIGHT, NULL );
      lighttype  = ltinfo->type( id );
      shadowtype = ltinfo->shadowType( id );
      flags      = ltinfo->flags( id );
      ltinfo->color( id, t, color );

      if ( type == LWLIGHT_SPOT )
         ltinfo->coneAngles( id, &radius, &edge );
      if ( flags & LWLFL_LIMITED_RANGE )
         range = ltinfo->range( id );
   }