Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

DynLight.h File Reference

#include "genesis.h"

Go to the source code of this file.

Compounds

struct  DynamicLight

Typedefs

typedef DynamicLight DynamicLight

Functions

geBoolean DynLight_Init (geEngine *Engine, geWorld *World, geVFile *Context)
geBoolean DynLight_Reset (geWorld *World)
geBoolean DynLight_Frame (geWorld *World, const geXForm3d *ViewPoint, geFloat Time)
geBoolean DynLight_Shutdown (void)


Typedef Documentation

typedef struct DynamicLight DynamicLight
 


Function Documentation

geBoolean DynLight_Frame geWorld World,
const geXForm3d ViewPoint,
geFloat  Time
 

Definition at line 54 of file DynLight.c.

References DynamicLight::AllowRotation, DynamicLight::Color, DynamicLight::DynLight, GE_TRUE, geBoolean, geEntity_EntitySetGetNextEntity(), geEntity_GetUserData(), geFloat, geVec3d_Add(), geVec3d_Subtract(), geWorld_GetEntitySet(), geWorld_GetModelRotationalCenter(), geWorld_GetModelXForm(), geWorld_SetLightAttributes(), geXForm3d_Transform(), DynamicLight::InterpolateValues, DynamicLight::IntervalWidth, DynamicLight::LastTime, DynamicLight::MaxRadius, DynamicLight::MinRadius, DynamicLight::Model, NULL, DynamicLight::NumFunctionValues, DynamicLight::origin, DynamicLight::RadiusFunction, DynamicLight::RadiusSpeed, and geXForm3d::Translation.

Referenced by RenderWorld().

00055 {
00056         geEntity_EntitySet *    Set;
00057         geEntity *                              Entity;
00058  
00059         if      (World == NULL)
00060                 return GE_TRUE;
00061 
00062         Set = geWorld_GetEntitySet(World, "DynamicLight");
00063         if      (Set == NULL)
00064                 return GE_TRUE;
00065 
00066         Entity = geEntity_EntitySetGetNextEntity(Set, NULL);
00067         while   (Entity)
00068         {
00069                 DynamicLight *  Light;
00070                 geFloat                 Radius;
00071                 geFloat                 Percentage;
00072                 int                             Index;
00073                 geVec3d                 Pos;
00074 
00075                 Light = geEntity_GetUserData(Entity);
00076                 assert(Light->DynLight);
00077 
00078 //              if      (Light->Controller)
00079                 if      (Light->Model)
00080                 {
00081                         geXForm3d       XForm;
00082 
00083 //                      geWorld_GetModelXForm(World, Light->Controller->Model, &XForm);
00084                         geWorld_GetModelXForm(World, Light->Model, &XForm);
00085 
00086                         Pos = Light->origin;
00087                         if      (Light->AllowRotation)
00088                         {
00089                                 geVec3d Center;
00090 
00091 //                              geWorld_GetModelRotationalCenter(World, Light->Controller->Model, &Center);
00092                                 geWorld_GetModelRotationalCenter(World, Light->Model, &Center);
00093                                 geVec3d_Subtract(&Pos, &Center, &Pos);
00094                                 geXForm3d_Transform(&XForm, &Pos, &Pos);
00095                                 geVec3d_Add(&Pos, &Center, &Pos);
00096                         }
00097                         else
00098                                 geVec3d_Add(&Pos, &XForm.Translation, &Pos);
00099                 }
00100                 else
00101                 {
00102                         Pos = Light->origin;
00103                 }
00104 
00105                 assert(Light->RadiusSpeed > Light->LastTime);
00106                 Percentage = Light->LastTime / Light->RadiusSpeed;
00107 
00108                 Index = (int)(Percentage * Light->NumFunctionValues);
00109                 assert(Index < Light->NumFunctionValues);
00110                 assert(Light->RadiusFunction[Index] >= 'a' && Light->RadiusFunction[Index] <= 'z');
00111 
00112                 if      (Light->InterpolateValues && Index < Light->NumFunctionValues - 1)
00113                 {
00114                         geFloat Remainder;
00115                         geFloat InterpolationPercentage;
00116                         int             DeltaValue;
00117                         geFloat Value;
00118 
00119                         Remainder = (geFloat)fmod(Light->LastTime, Light->IntervalWidth);
00120                         InterpolationPercentage = Remainder / Light->IntervalWidth;
00121 //geEngine_Printf(TheEngine, 20, 120, "Interpolate = %4.2f", InterpolationPercentage);
00122                         DeltaValue = Light->RadiusFunction[Index + 1] - Light->RadiusFunction[Index];
00123                         Value = Light->RadiusFunction[Index] + DeltaValue * InterpolationPercentage;
00124                         Percentage = ((geFloat)(Value - 'a')) / ((geFloat)('z' - 'a'));
00125                 }
00126                 else
00127                 {
00128                         Percentage = ((geFloat)(Light->RadiusFunction[Index] - 'a')) / ((geFloat)('z' - 'a'));
00129                 }
00130 
00131                 Radius = Percentage * (Light->MaxRadius - Light->MinRadius) + Light->MinRadius;
00132 
00133                 geWorld_SetLightAttributes(World,
00134                                                                    Light->DynLight,
00135                                                                    &Pos,
00136                                                                    &Light->Color,
00137                                                                    Radius,
00138                                                                    GE_TRUE);
00139 
00140                 Light->LastTime = (geFloat)fmod(Light->LastTime + DeltaTime, Light->RadiusSpeed);
00141 
00142                 Entity = geEntity_EntitySetGetNextEntity(Set, Entity);
00143         }
00144 
00145         return GE_TRUE;
00146 }

geBoolean DynLight_Init geEngine Engine,
geWorld World,
geVFile Context
 

Definition at line 14 of file DynLight.c.

References DynLight_SetWorld(), GE_FALSE, GE_TRUE, and geBoolean.

Referenced by GameMgr_SetWorld().

00015 {
00016         
00017         if (!DynLight_SetWorld(World, Context))
00018                 return GE_FALSE;
00019 
00020         return GE_TRUE;
00021 }

geBoolean DynLight_Reset geWorld World  ) 
 

Definition at line 23 of file DynLight.c.

References GE_TRUE, geBoolean, geEntity_EntitySetGetNextEntity(), geEntity_GetUserData(), geWorld_GetEntitySet(), DynamicLight::LastTime, and NULL.

00024 {
00025         geEntity_EntitySet *    Set;
00026         geEntity *                              Entity;
00027 
00028         if      (!World)
00029                 return GE_TRUE;
00030  
00031         Set = geWorld_GetEntitySet(World, "DynamicLight");
00032         if      (Set == NULL)            
00033                 return GE_TRUE;
00034 
00035         Entity = geEntity_EntitySetGetNextEntity(Set, NULL);
00036         while   (Entity)
00037         {
00038                 DynamicLight *          Light;
00039 
00040                 Light = geEntity_GetUserData(Entity);
00041                 Light->LastTime = 0.0f;
00042 
00043                 Entity = geEntity_EntitySetGetNextEntity(Set, Entity);
00044         }
00045 
00046         return GE_TRUE;
00047 }

geBoolean DynLight_Shutdown void   ) 
 

Definition at line 49 of file DynLight.c.

References GE_TRUE, and geBoolean.

00050 {
00051         return GE_TRUE;
00052 }


Generated on Tue Sep 30 12:37:27 2003 for GTestAndEngine by doxygen 1.3.2