Main Page   Modules   Alphabetical List   Data Structures   Data Fields  

RpLight
[Lighting]


Data Structures

struct   RpLight
struct   RpLightTie

Typedefs

typedef RpLight *(*  RpLightCallBack )(RpLight *light, void *data)

Enumerations

enum   RpLightType {
  rpNALIGHTTYPE = 0, rpLIGHTDIRECTIONAL, rpLIGHTAMBIENT, rpLIGHTPOINT = rpLIGHTPOSITIONINGSTART,
  rpLIGHTSPOT, rpLIGHTSPOTSOFT, rpLIGHTTYPEFORCEENUMSIZEINT = RWFORCEENUMSIZEINT
}
enum   RpLightFlag { rpLIGHTLIGHTATOMICS = 0x01, rpLIGHTLIGHTWORLD = 0x02, rpLIGHTFLAGFORCEENUMSIZEINT = RWFORCEENUMSIZEINT }

Functions

RpClump RpLightGetClump (const RpLight *light)
RwReal  RpLightGetRadius (const RpLight *light)
RpLight RpLightSetRadius (RpLight *light, RwReal radius)
const RwRGBAReal RpLightGetColor (const RpLight *light)
RpLight RpLightSetColor (RpLight *light, const RwRGBAReal *color)
RwReal  RpLightGetConeAngle (const RpLight *light)
RpLight RpLightSetConeAngle (RpLight *light, RwReal angle)
RwInt32  RpLightRegisterPlugin (RwInt32 size, RwUInt32 pluginID, RwPluginObjectConstructor constructCB, RwPluginObjectDestructor destructCB, RwPluginObjectCopy copyCB)
RwInt32  RpLightRegisterPluginStream (RwUInt32 pluginID, RwPluginDataChunkReadCallBack readCB, RwPluginDataChunkWriteCallBack writeCB, RwPluginDataChunkGetSizeCallBack getSizeCB)
RwInt32  RpLightSetStreamAlwaysCallBack (RwUInt32 pluginID, RwPluginDataChunkAlwaysCallBack alwaysCB)
RwInt32  RpLightGetPluginOffset (RwUInt32 pluginID)
RwBool  RpLightValidatePlugins (const RpLight *light)
RwUInt32  RpLightStreamGetSize (const RpLight *light)
const RpLight RpLightStreamWrite (const RpLight *light, RwStream *stream)
RpLight RpLightStreamRead (RwStream *stream)
RpLight RpLightSetFrame (RpLight *light, RwFrame *frame)
RwFrame RpLightGetFrame (const RpLight *light)
RpLightType  RpLightGetType (const RpLight *light)
RpLight RpLightSetFlags (RpLight *light, RwUInt32 flags)
RwUInt32  RpLightGetFlags (const RpLight *light)
RwBool  RpLightDestroy (RpLight *light)
RpLight RpLightCreate (RwInt32 type)
void  RpLightSetFreeListCreateParams (RwInt32 blockSize, RwInt32 numBlocksToPrealloc)
void  RpLightTieSetFreeListCreateParams (RwInt32 blockSize, RwInt32 numBlocksToPrealloc)
RpWorld RpLightGetWorld (const RpLight *light)
RpLight RpLightForAllWorldSectors (RpLight *light, RpWorldSectorCallBack callback, void *data)

Detailed Description

Lighting 3D objects. Lights are used to illuminate atomics and worlds

RpLight Overview

Requirements

Overview

This object represents dynamic lighting in a RenderWare Graphics Retained Mode scene. Lighting models available are:

Directional, Point, Spotlight and Soft Spotlight types all require that a Frame RwFrame be attached to the Light. An ambient type Light does not require a Frame as positioning is not needed. It is possible to specify whether a particular Light illuminates dynamic models, static models or both by setting the appropriate flags.

Further information is available in the Dynamic Models chapter of the User Guide.


Typedef Documentation

typedef RpLight*(* RpLightCallBack)(RpLight * light, void *data)
 

RpLightCallBack represents the function called from RpWorldForAllLights and RpWorld SectorForAllLights for all lights in a given world or world sector. This function should return a pointer to the current light to indicate success. The callback may return NULL to terminate further callbacks on the world sector.

Parameters:
light  Pointer to the current light in the world sector.
data  Pointer to developer-defined data structure.
Returns:
Pointer to the current light.

Enumeration Type Documentation

enum RpLightFlag
 

RpLightFlag defines what geometry is influenced by the light. The bit-field RpLightFlag specifies the options available for controlling the scope of a light source (see API function RpLightSetFlags):

Enumeration values:
rpLIGHTLIGHTATOMICS  The light source illuminates all atomics in a world
rpLIGHTLIGHTWORLD  The light source illuminates all static geometry in a world
enum RpLightType
 

RpLightType are light sub types. This type represents the different types of light source that can be created using the API function RpLightCreate. Note that lights of types rpLIGHTPOINT, rpLIGHTSPOT and rpLIGHTSPOTSOFT have linear intensity fall-off with distance from the source, reducing to zero at the light's radius:

Enumeration values:
rpLIGHTDIRECTIONAL  Directional Light
rpLIGHTAMBIENT  Ambient Light
rpLIGHTPOINT  Point Light
rpLIGHTSPOT  Spot Light
rpLIGHTSPOTSOFT  Soft Spot Light

Function Documentation

RpLight* RpLightCreate RwInt32    type
 

RpLightCreate is used to create a new light of the type specified. The light needs to be linked to a frame and added to a world before it can be included in any rendering. The associated frame enables the light to be positioned and oriented (i.e. positioned) within the world as required.

When a frame is defined directional lighting (rpLIGHTDIRECTIONAL, rpLIGHTSPOT and rpLIGHTSPOTSOFT) is oriented such that it illuminates in the direction of the frame's look-at vector, while positionable lighting (rpLIGHTPOINT, rpLIGHTSPOT and rpLIGHTSPOTSOFT) is located at the origin. Transformations applied to the frame can then be used to move and re-orient the light as required.

The following defaults are defined:

  • For lights with intensity fall-off with distance (rpLIGHTPOINT, rpLIGHTSPOT and rpLIGHTSPOTSOFT) the radius is zero,
  • For spot lights (rpLIGHTSPOT and rpLIGHTSPOTSOFT) the cone angle is zero,
  • For all light types the initial color is white (1.0, 1.0, 1.0),
  • All light types are set up to illuminate both atomics and static world geometry.
The world plugin must be attached before using this function.
Parameters:
type  A RwInt32 value indicating the type of light to be created.
Supported values are
  • rpLIGHTDIRECTIONAL Directional light.
  • rpLIGHTAMBIENT Ambient light.
  • rpLIGHTPOINT Point light, linear intensity fall-off with distance from the source.
  • rpLIGHTSPOT Spot light, linear intensity fall-off with distance from the source, no fall-off across the cone (hard-edged).
  • rpLIGHTSPOTSOFT Spot light, linear intensity fall-off with distance from the source, quadratic fall-off across the cone (soft-edged).
Returns:
Returns pointer to the new light if successful or NULL if there is an error.
See also:
RpLightDestroy , RpLightSetFrame , RpWorldAddLight , RpWorldRemoveLight , RpLightSetColor , RpLightSetRadius , RpLightSetConeAngle , RpWorldPluginAttach
RwBool RpLightDestroy RpLight   light
 

RpLightDestroy is used to destroy the specified dynamic light. The light must be removed from the worlds it belongs to (if any) before destruction using RpWorldRemoveLight. Any frame attached to the light should be removed from the light using RpLightSetFrame passing NULL as the new frame.

Note:
This does not destroy the frame. To destroy the frame, get the pointer using RpLightGetFrame, then remove the frame from the light, then destroy it with RwFrameDestroy.
The following is an example, from the light example file lights.c in LightsDestroy() (line 335). SpotSoftLight is a pointer to an RpLight.
    if( SpotSoftLight )
    {
        world = RpLightGetWorld(SpotSoftLight);
        if( world )
        {
            RpWorldRemoveLight(world, SpotSoftLight);
        }

        frame = RpLightGetFrame(SpotSoftLight);
        RpLightSetFrame(SpotSoftLight, NULL);
        RwFrameDestroy(frame);

        RpLightDestroy(SpotSoftLight);
    }

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light
Returns:
Returns TRUE if successful or FALSE if there is an error
See also:
RpWorldRemoveLight , RpLightSetFrame , RwFrameDestroy , RpLightCreate , RpWorldPluginAttach
RpLight* RpLightForAllWorldSectors RpLight   light,
RpWorldSectorCallBack    callback,
void *    data
 

RpLightForAllWorldSectors is used to enumerate all the world sectors that a light affects.

If any invocation of the callback function returns a failure status the iteration is terminated. However, RpLightForAllWorldSectors will still return successfully.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
callback  Callback to be called with each world sector.
data  User data pointer to be passed to the callback.
Returns:
Calls the specified callback with all the world sectors that a light is used to illuminate.
See also:
RpWorldSectorForAllLights , RpWorldPluginAttach
RpClump* RpLightGetClump const RpLight   light
 

RpLightGetClump is used to retrieve the specified light's parent clump, if one exists.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns pointer to the parent clump if successful or NULL if there is an error or if the light has no parent clump.
See also:
RpClumpAddLight , RpClumpRemoveLight , RpLightGetFrame , RpLightSetFrame , RpWorldPluginAttach
const RwRGBAReal* RpLightGetColor const RpLight   light
 

RpLightGetColor is used to retrieve the color of the specified light. Light colors are specified as real values within the range 0 to 1 in each color channel.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns pointer to a RwRGBAReal value equal to the light's color if successful or NULL if there is an error.
See also:
RpLightSetColor , RpLightGetRadius , RpLightSetRadius , RpLightGetConeAngle , RpLightSetConeAngle , RpWorldPluginAttach
RwReal RpLightGetConeAngle const RpLight   light
 

RpLightGetConeAngle is used to retrieve the angle at which a spot light illuminates objects (measured from the direction vector of the light). The cone angle only applies to lights of type rpLIGHTTYPESPOT and rpLIGHTTYPESPOTSOFT and this function will return an error if used on any other type.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns a RwReal value equal to the cone angle in radians if successful or zero if there is an error.
See also:
RpLightSetConeAngle , RpLightGetRadius , RpLightSetRadius , RpLightGetColor , RpLightSetColor , RpWorldPluginAttach
RwUInt32 RpLightGetFlags const RpLight   light
 

RpLightGetFlags is used to retrieve the flags associated with a light object.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns a 32-bit unsigned integer whose value is one of the following constants (if both flags are set the return value is the bit-wise OR of the two constants):
  • rpLIGHTLIGHTATOMICS The light illuminates atomics.
  • rpLIGHTLIGHTWORLD The light illuminates static world geometry.
See also:
RpLightSetFlags , RpWorldPluginAttach
RwFrame* RpLightGetFrame const RpLight   light
 

RpLightGetFrame is used to retrieve the frame the specified light is attached to, if any.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns a pointer to the frame if successful or NULL if there is an error.
See also:
RpLightSetFrame , RpLightCreate , RpWorldPluginAttach
RwInt32 RpLightGetPluginOffset RwUInt32    pluginID
 

RpLightGetPluginOffset is used to get the offset of a previously registered light plugin.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwUInt32 value equal to the plugin ID.
Returns:
Returns the data block offset if successful or -1 if the plugin is not registered.
See also:
RpLightRegisterPlugin , RpLightRegisterPluginStream , RpLightSetStreamAlwaysCallBack , RpLightValidatePlugins , RpWorldPluginAttach
RwReal RpLightGetRadius const RpLight   light
 

RpLightGetRadius is used to retrieve the radius of a point or spot light - the distance from the light in world units beyond which it has no influence. Within the radius of the light the intensity falls according to 1-(d/R), where d is the distance from the light and R is the radius. Hence at d=0 the light has full intensity and at d=R the intensity is zero.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns a RwReal value equal to the radius of the light (in world units) if successful or zero if there is an error.
See also:
RpLightSetRadius , RpLightGetColor , RpLightSetColor , RpLightGetConeAngle , RpLightSetConeAngle , RpWorldPluginAttach
RpLightType RpLightGetType const RpLight   light
 

RpLightGetType is used to determine the type of a light object, if any.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
RpLightType or rpNALIGHTTYPE if the light is none of the supported types.
See also:
RpLightCreate , RpWorldPluginAttach
RpWorld* RpLightGetWorld const RpLight   light
 

RpLightGetWorld is used to determine the world the specified light belongs to, if any.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns pointer to the world which contains the light if successful or NULL if there is an error or if the light does not belong to any world.
See also:
RpWorldAddLight , RpWorldRemoveLight , RpLightCreate , RpWorldPluginAttach
RwInt32 RpLightRegisterPlugin RwInt32    size,
RwUInt32    pluginID,
RwPluginObjectConstructor    constructCB,
RwPluginObjectDestructor    destructCB,
RwPluginObjectCopy    copyCB
 

RpLightRegisterPlugin is used to register a plugin and reserve some space within a light. This must happen after the engine has been initialized but before the engine is opened.

The world plugin must be attached before using this function.

Parameters:
size  A RwInt32 value equal to the size of the memory block to reserve.
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
constructCB  Constructor for the plugin data block.
destructCB  Destructor for the plugin data block.
copyCB  Copy constructor for the plugin data block.
Returns:
Returns a RwInt32 value equal to the byte offset within the light of memory reserved for this plugin or a negative value if there is an error.
See also:
RpLightValidatePlugins , RpLightRegisterPluginStream , RpLightSetStreamAlwaysCallBack , RpLightGetPluginOffset , RpWorldPluginAttach
RwInt32 RpLightRegisterPluginStream RwUInt32    pluginID,
RwPluginDataChunkReadCallBack    readCB,
RwPluginDataChunkWriteCallBack    writeCB,
RwPluginDataChunkGetSizeCallBack    getSizeCB
 

RpLightRegisterPluginStream is used to associate a set of binary stream functionality with a previously registered light plugin.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
readCB  Callback used when a chunk is read that is identified as being for this plugin.
writeCB  Callback used when a chunk should be written out for this plugin.
getSizeCB  Callback used to determine the binary stream size required for this plugin (return negative to suppress chunk writing).
Returns:
Returns a RwInt32 value equal to the byte offset within the light of memory reserved for this plugin or a negative value if there is an error.
See also:
RpLightSetStreamAlwaysCallBack , RpLightValidatePlugins , RpLightRegisterPlugin , RpLightGetPluginOffset , RpWorldPluginAttach
RpLight* RpLightSetColor RpLight   light,
const RwRGBAReal   color
 

RpLightSetColor is used to specify the color of the given light. Light colors are specified as real values within the range 0 to 1 in each color channel.

The default color is white (red = 1.0, green = 1.0, blue = 1.0).

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light
color  A pointer to a RwRGBAReal value equal to the light's color.
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightGetColor , RpLightSetRadius , RpLightGetRadius , RpLightSetConeAngle , RpLightGetConeAngle , RpWorldPluginAttach
RpLight* RpLightSetConeAngle RpLight   light,
RwReal    angle
 

RpLightSetConeAngle is used to specify the cone angle at which a spot light illuminates objects (measured in radians from the direction vector of the light). This function is only valid for lights of type rpLIGHTTYPESPOT or rpLIGHTTYPESPOTSOFT.

The default cone angle is zero. The maximum allowed cone angle (this value being platform-dependent) is given by rpLIGHTMAXCONEANGLE.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
angle  A RwReal value equal to the cone angle (in radians).
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightGetConeAngle , RpLightSetRadius , RpLightGetRadius , RpLightSetColor , RpLightGetColor , RpWorldPluginAttach
RpLight* RpLightSetFlags RpLight   light,
RwUInt32    flags
 

RpLightSetFlags is used to specify what a particular light object illuminates.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
flags  A 32-bit unsigned integer bitfield that specifies one (or both OR'd together) of the following values: rpLIGHTLIGHTATOMICS Light illuminates the atomics. rpLIGHTLIGHTWORLD Light illuminates the world (static geometry).
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightGetFlags , RpLightCreate , RpWorldPluginAttach
RpLight* RpLightSetFrame RpLight   light,
RwFrame   frame
 

RpLightSetFrame is used to attach the specified light to the given frame so that it can be positioned and oriented, as appropriate, within a world.

Note that this function is used for debug purposes only and, for efficiency, is available as a macro for final release versions of an application.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
frame  Pointer to the frame.
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightGetFrame , RwFrameCreate , RpWorldAddLight , RpWorldRemoveLight , RpWorldPluginAttach
void RpLightSetFreeListCreateParams RwInt32    blockSize,
RwInt32    numBlocksToPrealloc
 

RpLightSetFreeListCreateParams allows the developer to specify how many RpLight s to preallocate space for. Call before RwEngineInit.

Parameters:
blockSize  number of entries per freelist block.
numBlocksToPrealloc  number of blocks to allocate on RwFreeListCreateAndPreallocateSpace.
See also:
RwFreeList
RpLight* RpLightSetRadius RpLight   light,
RwReal    radius
 

RpLightSetRadius is used to specify the radius of a point or spot light. The radius is the distance from the light in world units beyond which it has no influence. Within the radius the intensity falls according to 1-(d/R), where d is the distance from the light and R is the radius. Hence at d=0 the light has full intensity and at d=R the intensity is zero.

The default radius is zero.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
radius  A RwReal value equal to the radius.
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightGetRadius , RpLightSetColor , RpLightGetColor , RpLightSetConeAngle , RpLightGetConeAngle , RpWorldPluginAttach
RwInt32 RpLightSetStreamAlwaysCallBack RwUInt32    pluginID,
RwPluginDataChunkAlwaysCallBack    alwaysCB
 

RpLightSetStreamAlwaysCallBack is used to associate a binary stream functionality with a previously registered light plugin. This callback is called for all plugins after stream data reading has completed.

The world plugin must be attached before using this function.

Parameters:
pluginID  A RwInt32 value equal to the plugin ID (must be unique; used to identify binary chunks).
alwaysCB  Callback used when object base and plugin data reading is complete.
Returns:
Returns a RwInt32 value equal to the byte offset within the light of memory reserved for this plugin or a negative value if there is an error.
See also:
RpLightRegisterPluginStream , RpLightValidatePlugins , RpLightRegisterPlugin , RpLightGetPluginOffset , RpWorldPluginAttach
RwUInt32 RpLightStreamGetSize const RpLight   light
 

RpLightStreamGetSize is used to determine the size in bytes of the binary representation of the given light object. This is used in the binary chunk header to indicate the size of the chunk. The size does not include the size of the chunk header.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns a RwUInt32 value equal to the chunk size in bytes if successful or zero if there is an error.
See also:
RpLightStreamRead , RpLightStreamWrite , RpWorldPluginAttach
RpLight* RpLightStreamRead RwStream   stream
 

RpLightStreamRead is used to read a light object from the specified binary stream. Note that prior to this function call a binary light chunk must be found in the stream using the RwStreamFindChunk API function.

The world plugin must be attached before using this function.

The sequence to locate and read a light from a binary stream is as follows:

   RwStream *stream;
   RpLight *NewLight;
  
   stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "mybinary.xxx");
   if (stream)
   {
       if( RwStreamFindChunk(stream, rwID_LIGHT, NULL, NULL) )
       {
           NewLight = RpLightStreamRead(stream);
       }
  
       RwStreamClose(stream, NULL);
   }
Parameters:
stream  Pointer to the stream.
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightStreamWrite , RpLightStreamGetSize , RwStreamOpen , RwStreamClose , RwStreamFindChunk , RpWorldPluginAttach
const RpLight* RpLightStreamWrite const RpLight   light,
RwStream   stream
 

RpLightStreamWrite is used to write the specified light to a binary stream. Note that the stream will have been opened prior to this function call.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
stream  Pointer to the stream.
Returns:
Returns pointer to the light if successful or NULL if there is an error.
See also:
RpLightStreamRead , RpLightStreamGetSize , RwStreamOpen , RwStreamClose , RpWorldPluginAttach
void RpLightTieSetFreeListCreateParams RwInt32    blockSize,
RwInt32    numBlocksToPrealloc
 

RpLightTieSetFreeListCreateParams allows the developer to specify how many RpLightTie s to preallocate space for. Call before RwEngineInit.

Parameters:
blockSize  number of entries per freelist block.
numBlocksToPrealloc  number of blocks to allocate on RwFreeListCreateAndPreallocateSpace.
See also:
RwFreeList
RwBool RpLightValidatePlugins const RpLight   light
 

RpLightValidatePlugins validates the plugin memory allocated within the specified light. This function is useful for determining where memory trampling may be occuring within an application.

This function only returns a meaningful response under a debug library.

The world plugin must be attached before using this function.

Parameters:
light  Pointer to the light.
Returns:
Returns TRUE if the light data is valid or FALSE if there is an error or if the light data has become corrupt.
See also:
RpLightRegisterPlugin , RpLightRegisterPluginStream , RpLightSetStreamAlwaysCallBack , RpWorldPluginAttach

Criterion Software © 1993-2003 Criterion Software Limited. All rights reserved. Built Tue Apr 22 12:46:17 2003. Send Feedback
Converted from CHM to HTML with chm2web Pro 2.85 (unicode)