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

puppet.h File Reference

#include "Motion.h"
#include "Camera.h"
#include "Body.h"
#include "Pose.h"
#include "ExtBox.h"
#include "Frustum.h"
#include "vfile.h"

Go to the source code of this file.

Typedefs

typedef gePuppet gePuppet

Functions

gePuppet *GENESISCC gePuppet_Create (geVFile *TextureFS, const geBody *B, geWorld *World)
void GENESISCC gePuppet_Destroy (gePuppet **P)
geBoolean GENESISCC gePuppet_RenderThroughFrustum (const gePuppet *P, const gePose *Joints, const geExtBox *Box, geEngine *Engine, geWorld *World, const geCamera *Camera, Frustum_Info *FInfo)
geBoolean GENESISCC gePuppet_Render (const gePuppet *P, const gePose *Joints, geEngine *Engine, geWorld *World, const geCamera *Camera, geExtBox *Box)
int GENESISCC gePuppet_GetMaterialCount (gePuppet *P)
geBoolean GENESISCC gePuppet_GetMaterial (gePuppet *P, int MaterialIndex, geBitmap **Bitmap, geFloat *Red, geFloat *Green, geFloat *Blue)
geBoolean GENESISCC gePuppet_SetMaterial (gePuppet *P, int MaterialIndex, geBitmap *Bitmap, geFloat Red, geFloat Green, geFloat Blue)
void GENESISCC gePuppet_SetShadow (gePuppet *P, geBoolean DoShadow, geFloat Scale, const geBitmap *ShadowMap, int BoneIndex)
geFloat GENESISCC gePuppet_GetAlpha (const gePuppet *P)
void GENESISCC gePuppet_SetAlpha (gePuppet *P, geFloat Alpha)
void GENESISCC gePuppet_SetEnvironmentOptions (gePuppet *P, geEnvironmentOptions *envop)
geEnvironmentOptions GENESISCC gePuppet_GetEnvironmentOptions (gePuppet *P)
void GENESISCC gePuppet_GetStaticLightingOptions (const gePuppet *P, geBoolean *AmbientLightFromStaticLights, geBoolean *TestRayCollision, int *MaxStaticLightsToUse)
void GENESISCC gePuppet_SetStaticLightingOptions (gePuppet *P, geBoolean AmbientLightFromStaticLights, geBoolean TestRayCollision, int MaxStaticLightsToUse)
void GENESISCC gePuppet_GetLightingOptions (const gePuppet *P, geBoolean *UseFillLight, geVec3d *FillLightNormal, geFloat *FillLightRed, geFloat *FillLightGreen, geFloat *FillLightBlue, geFloat *AmbientLightRed, geFloat *AmbientLightGreen, geFloat *AmbientLightBlue, geBoolean *UseAmbientLightFromFloor, int *MaximumDynamicLightsToUse, int *LightReferenceBoneIndex, geBoolean *PerBoneLighting)
void GENESISCC gePuppet_SetLightingOptions (gePuppet *P, geBoolean UseFillLight, const geVec3d *FillLightNormal, geFloat FillLightRed, geFloat FillLightGreen, geFloat FillLightBlue, geFloat AmbientLightRed, geFloat AmbientLightGreen, geFloat AmbientLightBlue, geBoolean AmbientLightFromFloor, int MaximumDynamicLightsToUse, int LightReferenceBoneIndex, int PerBoneLighting)


Typedef Documentation

typedef struct gePuppet gePuppet
 

Definition at line 40 of file puppet.h.


Function Documentation

gePuppet* GENESISCC gePuppet_Create geVFile TextureFS,
const geBody B,
geWorld World
 

Definition at line 270 of file puppet.c.

References gePuppet::AmbientLightFromFloor, gePuppet::AmbientLightFromStaticLights, gePuppet::AmbientLightIntensity, B, gePuppet_Color::Blue, gePuppet::BodyInstance, gePuppet::DoShadow, gePuppet::DoTestRayCollision, ERR_PUPPET_ENOMEM, gePuppet::FillLightColor, gePuppet::FillLightNormal, GE_FALSE, GE_POSE_ROOT_JOINT, GE_RAM_ALLOCATE_STRUCT, GE_TRUE, geBody_IsValid(), geBodyInst_Create(), geErrorLog_Add, GENESISCC, gePuppet_Destroy(), gePuppet_FetchTextures(), gePuppet_StaticPuppetCount, geRam_Free, geVec3d_Normalize(), gePuppet_Color::Green, gePuppet::internal_env, gePuppet::LightReferenceBoneIndex, gePuppet::MaxDynamicLightsToUse, gePuppet::MaxStaticLightsToUse, NULL, gePuppet::OverallAlpha, geEnvironmentOptions::PercentEnvironment, geEnvironmentOptions::PercentMaterial, geEnvironmentOptions::PercentPuppet, PUPPET_DEFAULT_MAX_DYNAMIC_LIGHTS, gePuppet_Color::Red, gePuppet::ShadowBoneIndex, gePuppet::ShadowScale, geEnvironmentOptions::Supercede, gePuppet::TextureFileContext, geEnvironmentOptions::UseEnvironmentMapping, gePuppet::UseFillLight, gePuppet::World, geVec3d::X, geVec3d::Y, and geVec3d::Z.

Referenced by geActor_RenderPrep().

00271 {
00272         gePuppet *P;
00273 
00274         assert( geBody_IsValid(B)!=GE_FALSE );
00275         #pragma message ("Need geWorld_IsValid()")
00276         
00277         P = GE_RAM_ALLOCATE_STRUCT(gePuppet);
00278         if (P==NULL)
00279         {
00280                 geErrorLog_Add(ERR_PUPPET_ENOMEM, NULL);
00281                 return NULL;
00282         }
00283         
00284         memset(P,0,sizeof(*P)); 
00285 
00286         P->BodyInstance = NULL;
00287         P->MaxDynamicLightsToUse = PUPPET_DEFAULT_MAX_DYNAMIC_LIGHTS;
00288         P->LightReferenceBoneIndex = GE_POSE_ROOT_JOINT;
00289 
00290         P->FillLightNormal.X = -0.2f;
00291         P->FillLightNormal.Y = 1.0f;
00292         P->FillLightNormal.Z = 0.4f;
00293         geVec3d_Normalize(&(P->FillLightNormal));
00294         P->FillLightColor.Red    = 0.25f;
00295         P->FillLightColor.Green  = 0.25f;
00296         P->FillLightColor.Blue   = 0.25f;
00297         P->UseFillLight = GE_TRUE;
00298         // LWM_ACTOR_RENDERING:
00299         P->OverallAlpha = 255.0f ;
00300 
00301         P->AmbientLightIntensity.Red   = 0.1f;
00302         P->AmbientLightIntensity.Green = 0.1f;
00303         P->AmbientLightIntensity.Blue  = 0.1f;
00304         P->AmbientLightFromFloor = GE_TRUE;
00305 
00306         P->DoShadow = GE_FALSE;
00307         P->ShadowScale = 0.0f;
00308         P->ShadowBoneIndex =  GE_POSE_ROOT_JOINT;
00309         P->TextureFileContext = TextureFS;
00310 
00311         P->World = World;
00312         
00313         P->AmbientLightFromStaticLights = GE_FALSE;     //BY DEFAULT DO NOTHING 
00314         P->DoTestRayCollision = GE_FALSE; 
00315         P->MaxStaticLightsToUse = PUPPET_DEFAULT_MAX_DYNAMIC_LIGHTS;
00316  
00317         //Set default environment options
00318         P->internal_env.PercentEnvironment = 0.0f;
00319         P->internal_env.PercentPuppet = 1.0f;
00320         P->internal_env.PercentMaterial = 1.0f;
00321         P->internal_env.UseEnvironmentMapping = GE_FALSE;
00322         P->internal_env.Supercede = GE_TRUE;
00323 
00324         if (gePuppet_FetchTextures(P,B)==GE_FALSE)
00325         {
00326                 geRam_Free(P);
00327                 return NULL;
00328         }
00329 
00330         P->BodyInstance = geBodyInst_Create(B);
00331         if (P->BodyInstance == NULL)
00332         {
00333                 geErrorLog_Add(ERR_PUPPET_ENOMEM, NULL);
00334                 gePuppet_Destroy( &P );
00335                 return NULL;
00336         }
00337         gePuppet_StaticPuppetCount++;
00338         return P;
00339 }

void GENESISCC gePuppet_Destroy gePuppet **  P  ) 
 

Definition at line 342 of file puppet.c.

References gePuppet_Material::Bitmap, GE_FALSE, geBitmap_Destroy(), geBodyInst_Destroy(), GENESISCC, gePuppet_StaticBoneLightArray, gePuppet_StaticBoneLightArraySize, gePuppet_StaticPuppetCount, geRam_Free, geWorld_RemoveBitmap(), NULL, and gePuppet_Material::UseTexture.

Referenced by geActor_Destroy(), geActor_DestroyDirect(), geActor_RenderPrep(), and gePuppet_Create().

00343 {
00344         assert( P  );
00345         assert( *P );
00346         if ( (*P)->BodyInstance )
00347         {
00348                 geBodyInst_Destroy( &((*P)->BodyInstance) );
00349                 (*P)->BodyInstance = NULL;
00350         }
00351         if ( (*P)->MaterialArray )
00352         {
00353                 gePuppet_Material *M;
00354                 int i;
00355 
00356                 for (i=0; i<(*P)->MaterialCount; i++)
00357                 {
00358                         M = &((*P)->MaterialArray[i]);
00359                         if (M->UseTexture )
00360                         {                                       
00361                                 assert( M->Bitmap );
00362                                 geWorld_RemoveBitmap( (*P)->World, M->Bitmap );
00363                                 geBitmap_Destroy( &(M->Bitmap) );
00364                                 M->UseTexture = GE_FALSE;
00365                         }
00366                 }
00367 
00368 
00369                 geRam_Free( (*P)->MaterialArray );
00370                 (*P)->BodyInstance = NULL;
00371         }
00372         if ( (*P)->ShadowMap )
00373         {
00374                 geBitmap_Destroy((geBitmap **)&((*P)->ShadowMap));
00375                 (*P)->ShadowMap = NULL;
00376         }
00377 
00378         geRam_Free( (*P) );
00379         *P = NULL;
00380         
00381         // clean up any shared resources.
00382         gePuppet_StaticPuppetCount--;
00383         if (gePuppet_StaticPuppetCount==0)
00384                 {
00385                         if (gePuppet_StaticBoneLightArray!=NULL)
00386                                 geRam_Free(gePuppet_StaticBoneLightArray);
00387                         gePuppet_StaticBoneLightArray=NULL;
00388                         gePuppet_StaticBoneLightArraySize = 0;
00389                 }       
00390 }

geFloat GENESISCC gePuppet_GetAlpha const gePuppet P  ) 
 

Definition at line 1175 of file puppet.c.

References geFloat, GENESISCC, and gePuppet::OverallAlpha.

Referenced by geActor_GetAlpha().

01176 {
01177         assert( P ) ;
01178         return P->OverallAlpha ;
01179 }

geEnvironmentOptions GENESISCC gePuppet_GetEnvironmentOptions gePuppet P  ) 
 

Definition at line 1166 of file puppet.c.

References GENESISCC, and gePuppet::internal_env.

Referenced by geActor_GetEnvironOptions().

01167 {
01168         assert ( P );
01169         return P->internal_env;
01170 }

void GENESISCC gePuppet_GetLightingOptions const gePuppet P,
geBoolean UseFillLight,
geVec3d FillLightNormal,
geFloat FillLightRed,
geFloat FillLightGreen,
geFloat FillLightBlue,
geFloat AmbientLightRed,
geFloat AmbientLightGreen,
geFloat AmbientLightBlue,
geBoolean UseAmbientLightFromFloor,
int *  MaximumDynamicLightsToUse,
int *  LightReferenceBoneIndex,
geBoolean PerBoneLighting
 

Definition at line 408 of file puppet.c.

References gePuppet::AmbientLightFromFloor, gePuppet::AmbientLightIntensity, gePuppet_Color::Blue, gePuppet::FillLightColor, gePuppet::FillLightNormal, geFloat, GENESISCC, gePuppet_Color::Green, gePuppet::LightReferenceBoneIndex, gePuppet::MaxDynamicLightsToUse, NULL, gePuppet::PerBoneLighting, gePuppet_Color::Red, and gePuppet::UseFillLight.

Referenced by geActor_GetLightingOptions().

00422 {
00423         geFloat Scaler;
00424         assert( P != NULL);
00425         assert( UseFillLight );
00426         assert( FillLightNormal );
00427         assert( FillLightRed ); 
00428         assert( FillLightGreen );       
00429         assert( FillLightBlue );        
00430         assert( AmbientLightRed );
00431         assert( AmbientLightGreen );                    
00432         assert( AmbientLightBlue );                     
00433         assert( UseAmbientLightFromFloor );
00434         assert( MaximumDynamicLightsToUse );    
00435         assert( LightReferenceBoneIndex );
00436                 
00437         *UseFillLight = P->UseFillLight;
00438 
00439         *FillLightNormal = P->FillLightNormal;
00440         
00441         Scaler = 255.0f;
00442         *FillLightRed   = P->FillLightColor.Red * Scaler;
00443         *FillLightGreen = P->FillLightColor.Green * Scaler;
00444         *FillLightBlue  = P->FillLightColor.Blue * Scaler;
00445         
00446         *AmbientLightRed    = P->AmbientLightIntensity.Red * Scaler;
00447         *AmbientLightGreen  = P->AmbientLightIntensity.Green * Scaler;
00448         *AmbientLightBlue   = P->AmbientLightIntensity.Blue * Scaler;
00449         
00450         *UseAmbientLightFromFloor  = P->AmbientLightFromFloor;
00451         *MaximumDynamicLightsToUse = P->MaxDynamicLightsToUse;
00452         *LightReferenceBoneIndex   = P->LightReferenceBoneIndex;
00453         *PerBoneLighting                   = P->PerBoneLighting;
00454 }       

geBoolean GENESISCC gePuppet_GetMaterial gePuppet P,
int  MaterialIndex,
geBitmap **  Bitmap,
geFloat Red,
geFloat Green,
geFloat Blue
 

Definition at line 199 of file puppet.c.

References gePuppet_Material::Bitmap, gePuppet_Color::Blue, Blue, gePuppet_Material::Color, GE_TRUE, geBoolean, GENESISCC, gePuppet_Color::Green, Green, gePuppet::MaterialArray, gePuppet_Color::Red, and Red.

Referenced by geActor_GetMaterial().

00202 {
00203         assert( P      );
00204         assert( Red    );
00205         assert( Green  );
00206         assert( Blue   );
00207         assert( Bitmap );
00208         assert( MaterialIndex >= 0 );
00209         assert( MaterialIndex < P->MaterialCount );
00210 
00211         {
00212                 gePuppet_Material *M = &(P->MaterialArray[MaterialIndex]);
00213                 *Bitmap = M->Bitmap;
00214                 *Red    = M->Color.Red;
00215                 *Green  = M->Color.Green;
00216                 *Blue   = M->Color.Blue;
00217         }
00218         return GE_TRUE;
00219 }

int GENESISCC gePuppet_GetMaterialCount gePuppet P  ) 
 

Definition at line 193 of file puppet.c.

References GENESISCC, and gePuppet::MaterialCount.

Referenced by geActor_GetMaterialCount().

00194 {
00195         assert( P );
00196         return P->MaterialCount;
00197 }

void GENESISCC gePuppet_GetStaticLightingOptions const gePuppet P,
geBoolean AmbientLightFromStaticLights,
geBoolean TestRayCollision,
int *  MaxStaticLightsToUse
 

Definition at line 392 of file puppet.c.

References gePuppet::AmbientLightFromStaticLights, gePuppet::DoTestRayCollision, GENESISCC, gePuppet::MaxStaticLightsToUse, and NULL.

Referenced by geActor_GetStaticLightingOptions().

00393 {       assert( P != NULL);
00394         assert( UseAmbientLightFromStaticLights );
00395         assert( MaxStaticLightsToUse );
00396         *UseAmbientLightFromStaticLights = P->AmbientLightFromStaticLights;
00397         *TestRayCollision = P->DoTestRayCollision;
00398         *MaxStaticLightsToUse = P->MaxStaticLightsToUse;
00399 }       

geBoolean GENESISCC gePuppet_Render const gePuppet P,
const gePose Joints,
geEngine Engine,
geWorld World,
const geCamera Camera,
geExtBox Box
 

Definition at line 1510 of file puppet.c.

References gePuppet_LightParamGroup::Ambient, gePuppet_Material::Bitmap, gePuppet_Color::Blue, gePuppet::BodyInstance, GE_Rect::Bottom, gePuppet_Material::Color, geEngine::DebugInfo, gePuppet::DoShadow, geEngine::DriverInfo, Engine, ERR_PUPPET_RENDER, gePuppet::FillLightColor, gePuppet_LightParamGroup::FillLightColor, gePuppet::FillLightNormal, gePuppet_LightParamGroup::FillLightNormal, G, GE_BODYINST_FACE_TRIANGLE, GE_FALSE, GE_TRUE, geBodyInst_GetGeometry(), geBodyInst_Index, geBoolean, geCamera_GetCameraSpaceXForm(), geCamera_GetClippingRect(), geCamera_GetFarClipPlane(), geCamera_Project(), geEngine_Printf(), geEngine_RenderPoly(), geErrorLog_Add, geFloat, GENESISCC, gePose_GetAllJointTransforms(), gePose_GetJointTransform(), gePose_GetScale(), gePuppet_ComputeAmbientLight(), gePuppet_DrawShadow(), gePuppet_PrepLights(), gePuppet_SetVertexColor(), gePuppet_StaticBoneLightArray, gePuppet_StaticBoneLightArraySize, gePuppet_StaticLightGrp, geRam_Realloc, geTClip_SetTexture(), geTClip_SetupEdges(), geTClip_Triangle(), geVec3d_Set(), geXFArray_GetElements(), geXForm3d_Transform(), gePuppet_Color::Green, GE_Rect::Left, gePuppet_LightParamGroup::LightCount, gePuppet_BoneLight::LightCount, gePuppet::LightReferenceBoneIndex, gePuppet_LightParamGroup::Lights, List, gePuppet::MaterialArray, gePuppet_LightParamGroup::MaterialColor, geExtBox::Max, gePuppet::MaxDynamicLightsToUse, geExtBox::Min, geDriver::Name, NULL, Sys_DebugInfo::NumActors, Sys_DriverInfo::NumSubDrivers, gePuppet::OverallAlpha, gePuppet::PerBoneLighting, gePuppet_LightParamGroup::PerBoneLighting, gePuppet_Color::Red, geBodyInst_SkinVertex::ReferenceBoneIndex, GE_Rect::Right, gePuppet_LightParamGroup::StaticLightCount, gePuppet_LightParamGroup::StaticLights, Sys_DriverInfo::SubDrivers, gePuppet_LightParamGroup::SurfaceNormal, geBodyInst_SkinVertex::SVPoint, geBodyInst_SkinVertex::SVU, geBodyInst_SkinVertex::SVV, GE_Rect::Top, geXForm3d::Translation, uint32, gePuppet::UseFillLight, gePuppet_LightParamGroup::UseFillLight, v, V, geVec3d::X, geVec3d::Y, and geVec3d::Z.

Referenced by geActor_Render().

01516 {
01517         const geXFArray *JointTransforms;
01518         geVec3d Scale;
01519         #ifdef PROFILE
01520         rdtsc_timer_type RDTSCStart,RDTSCEnd;
01521         #endif
01522         geRect ClippingRect;
01523         geBoolean Clipping = GE_TRUE;
01524 
01525         char name[128];
01526         int i, j;
01527         geBoolean flag;
01528 
01529         #define BACK_EDGE (1.0f)
01530 
01531         const geBodyInst_Geometry *G;
01532         assert( P      );
01533         assert( Engine );
01534         assert( World  );
01535         assert( Camera );
01536 
01537         #ifdef PROFILE
01538         rdtsc_read(&RDTSCStart);
01539     rdtsc_zero(&RDTSCEnd);
01540         #endif
01541 
01542         flag = GE_FALSE;
01543         j = Engine->DriverInfo.NumSubDrivers;
01544         for(i=0;i<j;i++)
01545         {
01546                 strcpy(name, Engine->DriverInfo.SubDrivers[i].Name);
01547                 if(name[0]=='G')
01548                 {
01549                         flag = GE_TRUE;
01550                         break;
01551                 }
01552         }
01553         
01554 
01555         geCamera_GetClippingRect(Camera,&ClippingRect);
01556         
01557         if (TestBox != NULL)
01558         {
01559                 // see if the test box is visible on the screen.  If not: don't draw actor.
01560                 // (transform and project it to the screen, then check extents of that projection
01561                 //  against the clipping rect)
01562                 geVec3d BoxCorners[8];
01563                 const geXForm3d *ObjectToCamera;
01564                 geVec3d Maxs,Mins;
01565                 #define BIG_NUMBER (99e9f)  
01566                 int i;
01567                 geBoolean ZFarEnable;
01568                 geFloat ZFar;
01569 
01570                 BoxCorners[0] = TestBox->Min;
01571                 BoxCorners[1] = BoxCorners[0];  BoxCorners[1].X = TestBox->Max.X;
01572                 BoxCorners[2] = BoxCorners[0];  BoxCorners[2].Y = TestBox->Max.Y;
01573                 BoxCorners[3] = BoxCorners[0];  BoxCorners[3].Z = TestBox->Max.Z;
01574                 BoxCorners[4] = TestBox->Max;
01575                 BoxCorners[5] = BoxCorners[4];  BoxCorners[5].X = TestBox->Min.X;
01576                 BoxCorners[6] = BoxCorners[4];  BoxCorners[6].Y = TestBox->Min.Y;
01577                 BoxCorners[7] = BoxCorners[4];  BoxCorners[7].Z = TestBox->Min.Z;
01578 
01579                 ObjectToCamera = geCamera_GetCameraSpaceXForm(Camera);
01580                 assert( ObjectToCamera );
01581 
01582                 geVec3d_Set(&Maxs,-BIG_NUMBER,-BIG_NUMBER,-BIG_NUMBER);
01583                 geVec3d_Set(&Mins, BIG_NUMBER, BIG_NUMBER, BIG_NUMBER);
01584                 for (i=0; i<8; i++)
01585                 {
01586                         geVec3d V;
01587                         geXForm3d_Transform(  ObjectToCamera,&(BoxCorners[i]),&(BoxCorners[i]));
01588                         geCamera_Project(  Camera,&(BoxCorners[i]),&V);
01589                         if (V.X > Maxs.X ) Maxs.X = V.X;
01590                         if (V.X < Mins.X ) Mins.X = V.X;
01591                         if (V.Y > Maxs.Y ) Maxs.Y = V.Y;
01592                         if (V.Y < Mins.Y ) Mins.Y = V.Y;
01593                         if (V.Z > Maxs.Z ) Maxs.Z = V.Z;
01594                         if (V.Z < Mins.Z ) Mins.Z = V.Z;
01595                 }
01596                 
01597                 // Reject against ZFar clipplane if enabled...
01598                 geCamera_GetFarClipPlane(Camera, &ZFarEnable, &ZFar);
01599                 if (ZFarEnable) 
01600                 {
01601                         if ( (Maxs.X < ClippingRect.Left) 
01602                                 || (Mins.X > ClippingRect.Right)
01603                                 || (Maxs.Z < BACK_EDGE)                                 //Test X and Z first, and Y
01604                                 || (Mins.Z > ZFar)
01605                                 || (Maxs.Y < ClippingRect.Top) 
01606                                 || (Mins.Y > ClippingRect.Bottom))
01607                         {
01608                                 // not gonna draw: box is not visible.
01609                                 return GE_TRUE;
01610                         }
01611                         
01612                 } else 
01613                 {
01614                         if ( (Maxs.X < ClippingRect.Left) 
01615                                 || (Mins.X > ClippingRect.Right)
01616                                 || (Maxs.Y < ClippingRect.Top) 
01617                                 || (Mins.Y > ClippingRect.Bottom)
01618                                 || (Maxs.Z < BACK_EDGE))
01619                         {
01620                                 // not gonna draw: box is not visible.
01621                                 return GE_TRUE;
01622                         }
01623                 }
01624  
01625         } 
01626 
01627         Engine->DebugInfo.NumActors++;
01628 
01629         geTClip_SetupEdges(Engine,
01630                                                 (geFloat)ClippingRect.Left,
01631                                                 (geFloat)ClippingRect.Right,
01632                                                 (geFloat)ClippingRect.Top,
01633                                                 (geFloat)ClippingRect.Bottom,
01634                                                 BACK_EDGE);
01635                 
01636         JointTransforms = gePose_GetAllJointTransforms(Joints);
01637 
01638         #pragma message ("Level of detail hacked:")
01639         gePose_GetScale(Joints,&Scale);
01640         G = geBodyInst_GetGeometry(P->BodyInstance, &Scale, JointTransforms, 0,Camera);
01641 
01642         if ( G == NULL )
01643                 {
01644                         geErrorLog_Add(ERR_PUPPET_RENDER, NULL);
01645                         return GE_FALSE;
01646                 }
01647 
01648 #ifdef ONE_OVER_Z_PIPELINE
01649 #define TEST_Z_OUT(zzz, edge)           ((zzz) > (edge)) 
01650 #define TEST_Z_IN(zzz, edge)            ((zzz) < (edge)) 
01651 #pragma message ("test this! this is untested")
01652 #else
01653 #define TEST_Z_OUT(zzz, edge)           ((zzz) < (edge)) 
01654 #define TEST_Z_IN(zzz, edge)            ((zzz) > (edge)) 
01655 #endif
01656 
01657 
01658         // check for trivial rejection:
01659         {
01660                 if (   (G->Maxs.X < ClippingRect.Left) 
01661                         || (G->Mins.X > ClippingRect.Right)
01662                         || ( TEST_Z_OUT( G->Maxs.Z, BACK_EDGE) )                //test Y last
01663                         || (G->Maxs.Y < ClippingRect.Top) 
01664                         || (G->Mins.Y > ClippingRect.Bottom) )
01665                         {
01666                                 // not gonna draw
01667                                 return GE_TRUE;
01668                         }
01669 
01670                 if (   (G->Maxs.X < ClippingRect.Right) 
01671                         && (G->Mins.X > ClippingRect.Left)
01672                         && (G->Maxs.Y < ClippingRect.Bottom) 
01673                         && (G->Mins.Y > ClippingRect.Top)
01674                         && ( TEST_Z_IN( G->Mins.Z, BACK_EDGE) ) )
01675                         {
01676                                 // not gonna clip
01677                                 Clipping = GE_FALSE;
01678                         }
01679                 else
01680                         {
01681                                 Clipping = GE_TRUE;
01682                         } 
01683         }
01684 
01685         {
01686                 GE_LVertex v[3];
01687                 int i,j,Count;
01688                 geBodyInst_Index *List;
01689                 geBodyInst_Index Command;
01690                 geBodyInst_SkinVertex *SV;
01691                 geXForm3d RootTransform;
01692                 gePuppet_Material *PM;
01693                 geBodyInst_Index Material,LastMaterial;
01694 
01695                 gePuppet_StaticLightGrp.UseFillLight             = P->UseFillLight;
01696                 gePuppet_StaticLightGrp.FillLightNormal          = P->FillLightNormal;
01697                 gePuppet_StaticLightGrp.FillLightColor.Red       = P->FillLightColor.Red;
01698                 gePuppet_StaticLightGrp.FillLightColor.Green = P->FillLightColor.Green;
01699                 gePuppet_StaticLightGrp.FillLightColor.Blue  = P->FillLightColor.Blue;
01700                 gePuppet_StaticLightGrp.PerBoneLighting          = P->PerBoneLighting;
01701                 
01702                 gePose_GetJointTransform(Joints,P->LightReferenceBoneIndex,&(RootTransform));
01703 
01704                 if (P->MaxDynamicLightsToUse > 0)
01705                 {
01706                         if (P->PerBoneLighting)
01707                                 {
01708                                         int BoneCount;
01709                                         const geXForm3d *XFA = geXFArray_GetElements(JointTransforms, &BoneCount);
01710                                         if (BoneCount>0)
01711                                                 {
01712                                                         if (gePuppet_StaticBoneLightArraySize < BoneCount)
01713                                                                 {
01714                                                                         gePuppet_BoneLight *LG;
01715                                                         
01716                                                                         LG = geRam_Realloc(gePuppet_StaticBoneLightArray, sizeof(gePuppet_BoneLight) * BoneCount);
01717                                                                         if (LG==NULL)
01718                                                                                 {
01719                                                                                         geErrorLog_Add(ERR_PUPPET_RENDER,"Failed to allocate space for bone lighting info cache");
01720                                                                                         return GE_FALSE;
01721                                                                                 }
01722                                                                         gePuppet_StaticBoneLightArray = LG;
01723                                                                         gePuppet_StaticBoneLightArraySize = BoneCount;
01724                                                                 }
01725                                                         for (i=0; i<BoneCount; i++)
01726                                                                 {
01727                                                                         gePuppet_StaticBoneLightArray[i].LightCount = gePuppet_PrepLights(P,World,
01728                                                                                                 gePuppet_StaticBoneLightArray[i].Lights,&(XFA[i].Translation));
01729                                                                 }
01730                                                 }
01731                                 }
01732                         else
01733                                 {
01734                                         gePuppet_StaticLightGrp.LightCount = gePuppet_PrepLights(P,World
01735                                                                 ,gePuppet_StaticLightGrp.Lights,&(RootTransform.Translation));
01736                                 }
01737                 }
01738                 else
01739                 {
01740                         gePuppet_StaticLightGrp.LightCount = 0;
01741                 }
01742 
01743                 
01744    //XING Studios code
01745                 gePuppet_StaticLightGrp.StaticLightCount = gePuppet_ComputeAmbientLight(P,
01746                                                                                                                                                            World,
01747                                                                                                                                                            &(gePuppet_StaticLightGrp.Ambient),
01748                                                                                                                                                            gePuppet_StaticLightGrp.StaticLights ,
01749                                                                                                                                                            &(RootTransform.Translation));
01750                 Count = G->FaceCount;
01751                 List  = G->FaceList;
01752                 #if 1
01753                 v[0].a = v[1].a= v[2].a = P->OverallAlpha ;
01754                 #else
01755                 v[0].a = v[1].a= v[2].a = 255.0f;
01756                 #endif
01757 
01758                 LastMaterial = -1;
01759 
01760                 for (i=0; i<Count; i++)
01761                 {       
01762 
01763                         Command = *List;
01764                         List ++;
01765                         Material = *List;
01766                         List ++;
01767 
01768                         assert( Command == GE_BODYINST_FACE_TRIANGLE );
01769                         assert( Material>=0 );
01770                         assert( Material<P->MaterialCount);
01771 
01772                         {
01773                                 geFloat AX,AY,BXMinusAX,BYMinusAY,CYMinusAY,CXMinusAX;
01774                                 geBodyInst_Index *List2;
01775                                 
01776                                 List2 = List;
01777                                 SV = &(G->SkinVertexArray[ *List2 ]);
01778                                 AX = SV->SVPoint.X;
01779                                 AY = SV->SVPoint.Y;
01780                                 List2++;
01781                                 List2++;
01782                                 
01783                                 SV = &(G->SkinVertexArray[ *List2 ]);
01784                                 BXMinusAX = SV->SVPoint.X - AX;
01785                                 BYMinusAY = SV->SVPoint.Y - AY;
01786                                 List2++;
01787                                 List2++;
01788 
01789                                 SV = &(G->SkinVertexArray[ *List2 ]);
01790                                 CXMinusAX = SV->SVPoint.X - AX;
01791                                 CYMinusAY = SV->SVPoint.Y - AY;
01792                                 List2++;
01793                                 List2++;
01794 
01795                                 // ZCROSS is z the component of a 2d vector cross product of ABxAC
01796                                 //#define ZCROSS(Ax,Ay,Bx,By,Cx,Cy)  ((((Bx)-(Ax))*((Cy)-(Ay))) - (((By)-(Ay))*((Cx)-(Ax))))
01797 
01798                                 // 2d cross product of AB cross AC   (A is vtx[0], B is vtx[1], C is vtx[2]
01799                                 if ( ((BXMinusAX * CYMinusAY) - (BYMinusAY * CXMinusAX)) > 0.0f )
01800                                 {
01801                                         List = List2;
01802                                         continue;
01803                                 }
01804                         }
01805 
01806                         if ( Material != LastMaterial )
01807                         {
01808                                 PM = &(P->MaterialArray[Material]);
01809                                 geTClip_SetTexture(PM->Bitmap);
01810                                 gePuppet_StaticLightGrp.MaterialColor = PM->Color;
01811                         }
01812 
01813                         for (j=0; j<3; j++)
01814                         {
01815                                 SV = &(G->SkinVertexArray[ *List ]);
01816                                 List++;
01817 
01818                                 v[j].X = SV->SVPoint.X;
01819                                 v[j].Y = SV->SVPoint.Y;
01820 
01821                                 v[j].Z = SV->SVPoint.Z;
01822                                 v[j].u = SV->SVU;
01823                                 v[j].v = SV->SVV;
01824                                 
01825 //                              assert( ((geFloat)fabs(1.0-geVec3d_Length( &(G->NormalArray[ *List ] ))))< 0.001f );
01826                                 
01827                                 gePuppet_StaticLightGrp.SurfaceNormal = (G->NormalArray[ *List ]);
01828                                 List++;
01829 
01830                                 gePuppet_SetVertexColor(&(v[j]),SV->ReferenceBoneIndex);
01831                         }
01832                 
01833                         if(flag==GE_FALSE)
01834                                 Clipping = GE_FALSE;
01835 
01836                         if (Clipping)
01837                         {
01838                                 geTClip_Triangle(v);
01839                         }
01840                         else 
01841                         {
01842                                 geEngine_RenderPoly(Engine, (GE_TLVertex *)v, 3, PM->Bitmap, 0 );
01843                         }
01844 
01845                 }
01846                 assert( ((uint32)List) - ((uint32)G->FaceList) == (uint32)(G->FaceListSize) );
01847         }
01848 
01849 
01850         if (P->DoShadow)
01851         {
01852                 gePuppet_DrawShadow(P,Joints,Engine,World,Camera);
01853         }
01854 
01855 
01856         #ifdef PROFILE
01857         {
01858                 double Count=0.0;
01859                 int i;
01860 
01861                 rdtsc_read(&RDTSCEnd);
01862                 rdtsc_delta(&RDTSCStart,&RDTSCEnd,&RDTSCEnd);
01863                 geEngine_Printf(Engine, 320,10,"Puppet Render Time=%f",(double)(rdtsc_cycles(&RDTSCEnd)/200000000.0));
01864                 geEngine_Printf(Engine, 320,30,"Puppet Render Cycles=%f",(double)(rdtsc_cycles(&RDTSCEnd)));
01865                 #if 1
01866                 Puppet_AverageCount[(Puppet_AverageIndex++)%PUPPET_AVERAGE_ACROSS] = rdtsc_cycles(&RDTSCEnd);
01867                 for (i=0; i<PUPPET_AVERAGE_ACROSS; i++)
01868                         {       
01869                                 Count+=Puppet_AverageCount[i];
01870                         }
01871                 Count /= (double)PUPPET_AVERAGE_ACROSS;
01872 
01873                 geEngine_Printf(Engine, 320,60,"Puppet AVG Render Time=%f",(double)(Count/200000000.0));
01874                 geEngine_Printf(Engine, 320,90,"Puppet AVG Render Cycles=%f",(double)(Count));
01875                 #endif
01876                                 
01877         }
01878         #endif
01879 
01880         return GE_TRUE;
01881 }

geBoolean GENESISCC gePuppet_RenderThroughFrustum const gePuppet P,
const gePose Joints,
const geExtBox Box,
geEngine Engine,
geWorld World,
const geCamera Camera,
Frustum_Info FInfo
 

Definition at line 1189 of file puppet.c.

References DRV_TLVertex::a, gePuppet_LightParamGroup::Ambient, GE_LVertex::b, Surf_TexVert::b, gePuppet_Material::Bitmap, gePuppet_Color::Blue, gePuppet::BodyInstance, gePuppet_Material::Color, Engine, ERR_PUPPET_RENDER, gePuppet::FillLightColor, gePuppet_LightParamGroup::FillLightColor, gePuppet::FillLightNormal, gePuppet_LightParamGroup::FillLightNormal, Frustum_ClipToPlaneUVRGBA(), Frustum_ProjectRGBA(), GE_LVertex::g, Surf_TexVert::g, G, GE_BODYINST_FACE_TRIANGLE, GE_FALSE, GE_TRUE, geBodyInst_GetGeometry(), geBodyInst_Index, geBoolean, geCamera_GetPov(), geCamera_Transform(), geEngine_RenderPoly(), geErrorLog_Add, geFloat, GENESISCC, gePose_GetAllJointTransforms(), gePose_GetJointTransform(), gePose_GetScale(), gePuppet_ComputeAmbientLight(), gePuppet_PrepLights(), gePuppet_SetVertexColor(), gePuppet_StaticBoneLightArray, gePuppet_StaticBoneLightArraySize, gePuppet_StaticLightGrp, geRam_Realloc, geVec3d_CrossProduct(), geVec3d_DotProduct(), geVec3d_Length(), geVec3d_Normalize(), geVec3d_Subtract(), geXFArray_GetElements(), gePuppet_Color::Green, int32, gePuppet::internal_env, gePuppet_LightParamGroup::LightCount, gePuppet_BoneLight::LightCount, gePuppet::LightReferenceBoneIndex, gePuppet_LightParamGroup::Lights, List, gePuppet::MaterialArray, gePuppet_LightParamGroup::MaterialColor, gePuppet_Material::MaterialName, geExtBox::Max, gePuppet::MaxDynamicLightsToUse, geExtBox::Min, NULL, NumClips, Frustum_Info::NumPlanes, gePuppet::OverallAlpha, gePuppet::PerBoneLighting, gePuppet_LightParamGroup::PerBoneLighting, geEnvironmentOptions::PercentEnvironment, geEnvironmentOptions::PercentMaterial, geEnvironmentOptions::PercentPuppet, PLANE_ANY, Frustum_Info::Planes, PSIDE_BACK, PSIDE_FRONT, GE_LVertex::r, Surf_TexVert::r, gePuppet_Color::Red, geBodyInst_SkinVertex::ReferenceBoneIndex, gePuppet_LightParamGroup::StaticLightCount, gePuppet_LightParamGroup::StaticLights, geEnvironmentOptions::Supercede, gePuppet_LightParamGroup::SurfaceNormal, geBodyInst_SkinVertex::SVPoint, geBodyInst_SkinVertex::SVU, geBodyInst_SkinVertex::SVV, Trace_BoxOnPlaneSide(), geXForm3d::Translation, GFX_Plane::Type, Surf_TexVert::u, geEnvironmentOptions::UseEnvironmentMapping, gePuppet::UseFillLight, gePuppet_LightParamGroup::UseFillLight, Surf_TexVert::v, and v.

Referenced by geActor_RenderThroughFrustum().

01196 {
01197         int32           ClipFlags;
01198         geVec3d     Scale;
01199         const geXFArray *JointTransforms;
01200 
01201         const geBodyInst_Geometry *G;
01202         assert( P      );
01203         assert( Engine );
01204         assert( World  );
01205         assert( Camera );
01206         assert( Joints );
01207 
01208         JointTransforms = gePose_GetAllJointTransforms(Joints);
01209 
01210         #pragma message ("Level of detail hacked:")
01211 
01212         gePose_GetScale(Joints,&Scale);
01213         G = geBodyInst_GetGeometry(P->BodyInstance, &Scale, JointTransforms, 0, NULL);
01214 
01215         // Setup clip flags...
01216         ClipFlags = 0xffff;
01217 
01218         {
01219                 geExtBox        MinMaxs;
01220                 //geVec3d               d1, d2, d3;
01221                 GFX_Plane       *Planes;
01222                 int32           k;
01223                 geVec3d         Expand = {150.0f, 150.f, 150.0f};
01224                 int32           OriginalClips;
01225 
01226                 OriginalClips = NumClips;
01227 
01228                 MinMaxs = *Box;
01229 
01230                 Planes = FInfo->Planes;
01231 
01232                 for (k=0; k< FInfo->NumPlanes; k++, Planes++)
01233                 {
01234                         int32           Side;
01235                         
01236                         Planes->Type = PLANE_ANY;
01237                         
01238                         Side = Trace_BoxOnPlaneSide(&MinMaxs.Min, &MinMaxs.Max, Planes);
01239 
01240                         if (Side == PSIDE_BACK)
01241                         {
01242                                 NumClips = OriginalClips;
01243                                 return GE_TRUE;
01244                         }
01245                         
01246                         if (Side == PSIDE_FRONT)
01247                         {
01248                                 ClipFlags &= ~(1<<k);
01249                         }
01250                         else
01251                                 NumClips++;
01252                         
01253                 }
01254         }
01255 
01256         if (G == NULL)
01257         {
01258                 geErrorLog_Add(ERR_PUPPET_RENDER, NULL);
01259                 return GE_FALSE;
01260         }
01261 
01262         {
01263                 int32                   NumFaces;
01264                 int32                   i;
01265                 geBodyInst_Index        *List;
01266                 geXForm3d               RootTransform;
01267 
01268                 gePuppet_StaticLightGrp.UseFillLight             = P->UseFillLight;
01269                 gePuppet_StaticLightGrp.FillLightNormal          = P->FillLightNormal;
01270                 gePuppet_StaticLightGrp.FillLightColor.Red       = P->FillLightColor.Red;
01271                 gePuppet_StaticLightGrp.FillLightColor.Green = P->FillLightColor.Green;
01272                 gePuppet_StaticLightGrp.FillLightColor.Blue  = P->FillLightColor.Blue;
01273                 gePuppet_StaticLightGrp.PerBoneLighting      = P->PerBoneLighting;
01274 
01275                 gePose_GetJointTransform(Joints,P->LightReferenceBoneIndex,&(RootTransform));
01276 
01277                 // LWM_OPTIMIZATION: It seems that if you know that there are 
01278                 // no dynamic lights anywhere you could skip this test easily
01279                 if (P->MaxDynamicLightsToUse > 0)
01280                 {
01281                         if (P->PerBoneLighting)
01282                                 {
01283                                         int BoneCount;
01284                                         const geXForm3d *XFA = geXFArray_GetElements(JointTransforms, &BoneCount);
01285                                         if (BoneCount>0)
01286                                                 {
01287                                                         if (gePuppet_StaticBoneLightArraySize < BoneCount)
01288                                                                 {
01289                                                                         gePuppet_BoneLight *LG;
01290                                                         
01291                                                                         LG = geRam_Realloc(gePuppet_StaticBoneLightArray, sizeof(gePuppet_BoneLight) * BoneCount);
01292                                                                         if (LG==NULL)
01293                                                                                 {
01294                                                                                         geErrorLog_Add(ERR_PUPPET_RENDER,"Failed to allocate space for bone lighting info cache");
01295                                                                                         return GE_FALSE;
01296                                                                                 }
01297                                                                         gePuppet_StaticBoneLightArray = LG;
01298                                                                         gePuppet_StaticBoneLightArraySize = BoneCount;
01299                                                                 }
01300                                                         for (i=0; i<BoneCount; i++)
01301                                                                 {
01302                                                                         gePuppet_StaticBoneLightArray[i].LightCount = gePuppet_PrepLights(P,World,
01303                                                                                                 gePuppet_StaticBoneLightArray[i].Lights,&(XFA[i].Translation));
01304                                                                 }
01305                                                 }
01306                                 }
01307                         else
01308                                 {
01309                                         gePuppet_StaticLightGrp.LightCount = gePuppet_PrepLights(P,World
01310                                                                 ,gePuppet_StaticLightGrp.Lights,&(RootTransform.Translation));
01311                                 }
01312                 }
01313                 else
01314                 {
01315                         gePuppet_StaticLightGrp.LightCount = 0;
01316                 }
01317 
01318                 //XING Studios code
01319                 gePuppet_StaticLightGrp.StaticLightCount = gePuppet_ComputeAmbientLight(P,
01320                                                                                                                                                            World,
01321                                                                                                                                                            &(gePuppet_StaticLightGrp.Ambient),
01322                                                                                                                                                            gePuppet_StaticLightGrp.StaticLights,
01323                                                                                                                                                            &(RootTransform.Translation));
01324                 NumFaces        = G->FaceCount;
01325                 List            = G->FaceList;
01326                 
01327                 // For each face, clip it to the view frustum supplied...
01328                 for (i=0; i<NumFaces; i++)
01329                 {
01330                         #define MAX_TEMP_VERTS          30              // To be safe...
01331 
01332                         int32                           Length1, Length2, v, p;
01333                         geVec3d                         Dest1[MAX_TEMP_VERTS], *pDest1;
01334                         geVec3d                         Dest2[MAX_TEMP_VERTS], *pDest2;
01335                         geVec3d                         Verts[MAX_TEMP_VERTS], *pVerts, v1, v2, v3;
01336                         Surf_TexVert            TexVerts[MAX_TEMP_VERTS], Tex1[MAX_TEMP_VERTS], *pTexVerts;
01337                         Surf_TexVert            Tex2[MAX_TEMP_VERTS], *pTex1, *pTex2;                   
01338                         Surf_TLVertex           ScreenPts[MAX_TEMP_VERTS];
01339                         GFX_Plane                       *FPlanes;
01340                         geBodyInst_Index                Command, Material;
01341                         gePuppet_Material       *PM;
01342                         geFloat                         Dist;
01343 
01344                         Command = *List;
01345                         List++;
01346                         Material = *List;
01347                         List ++;
01348                         
01349                         assert( Command == GE_BODYINST_FACE_TRIANGLE );
01350                         assert( Material>=0 );
01351                         assert( Material<P->MaterialCount);
01352 
01353                         PM = &(P->MaterialArray[Material]);
01354                         gePuppet_StaticLightGrp.MaterialColor = PM->Color;
01355 
01356                         Length1 = 3;                                    //FIXME:  I'm assuming numverts == 3
01357 
01358                         pVerts = Verts;
01359                         pTexVerts = TexVerts;
01360 
01361                         // AHHH!! Copy over till I get a better way...
01362                         for (v=0; v< Length1; v++, pVerts++, pTexVerts++)
01363                         {
01364                                 geBodyInst_SkinVertex   *SVert;
01365                                 GE_LVertex lvert;
01366 
01367                                 SVert = &G->SkinVertexArray[*List];
01368                                 List++;
01369 
01370                                 *pVerts = SVert->SVPoint;
01371 
01372                                 assert( ((geFloat)fabs(1.0-geVec3d_Length( &(G->NormalArray[ *List ] ))))< 0.001f );
01373                                                 
01374                                 gePuppet_StaticLightGrp.SurfaceNormal = (G->NormalArray[ *List ]);
01375                                                 
01376                                 List++;
01377 
01378                                 //gePuppet_SetVertexColor2(P,PM,&Ambient,SurfaceNormal, Lights,LightCount, pTexVerts);
01379                                 gePuppet_SetVertexColor(&lvert,SVert->ReferenceBoneIndex);
01380                                 pTexVerts->r = lvert.r;
01381                                 pTexVerts->g = lvert.g;
01382                                 pTexVerts->b = lvert.b;
01383                                 //Environment mapping code...
01384                                 if( P->internal_env.UseEnvironmentMapping )
01385                                 {
01386                                         pTexVerts->u = ( SVert->SVU * P->internal_env.PercentPuppet );
01387                                         pTexVerts->v = ( SVert->SVV * P->internal_env.PercentPuppet );
01388                                         
01389                                         if( P->internal_env.Supercede && PM->MaterialName[0] == 'g' )
01390                                         {
01391                                                 pTexVerts->u += ( (G->NormalArray[ *List ]).X * P->internal_env.PercentMaterial);
01392                                                 pTexVerts->v += ( (G->NormalArray[ *List ]).Y * P->internal_env.PercentMaterial);
01393                                         }
01394                                         else
01395                                         {
01396                                                 pTexVerts->u += ( (G->NormalArray[ *List ]).X * P->internal_env.PercentEnvironment);
01397                                                 pTexVerts->v += ( (G->NormalArray[ *List ]).Y * P->internal_env.PercentEnvironment);
01398                                         }
01399                                 }
01400                                 else
01401                                 {
01402                                         pTexVerts->u = SVert->SVU;
01403                                         pTexVerts->v = SVert->SVV;
01404                                         
01405                                         if( P->internal_env.Supercede && PM->MaterialName[0] == 'g' )
01406                                         {
01407                                                 pTexVerts->u += ( (G->NormalArray[ *List ]).X * P->internal_env.PercentMaterial);
01408                                                 pTexVerts->v += ( (G->NormalArray[ *List ]).Y * P->internal_env.PercentMaterial);
01409                                         }
01410                                 }
01411                         }
01412 
01413                         geVec3d_Subtract(&Verts[2], &Verts[1], &v1);
01414                         geVec3d_Subtract(&Verts[0], &Verts[1], &v2);
01415                         geVec3d_CrossProduct(&v1, &v2, &v3);
01416                         geVec3d_Normalize(&v3);
01417 
01418                         Dist = geVec3d_DotProduct(&v3, &Verts[0]);
01419 
01420                         Dist = geVec3d_DotProduct(&v3, geCamera_GetPov(Camera)) - Dist;
01421 
01422                         if (Dist <= 0)
01423                                 continue;
01424                         
01425                         pDest1 = Verts;
01426                         pDest2 = Dest2;
01427                         pTex1 = TexVerts;
01428                         pTex2 = Tex2;
01429 
01430                         FPlanes = FInfo->Planes;
01431 
01432                         for (p=0; p< FInfo->NumPlanes; p++, FPlanes++)
01433                         {
01434                                 if (!(ClipFlags & (1<<p)))
01435                                         continue;               // No need to clip...
01436 
01437                                 assert(Length1 < MAX_TEMP_VERTS);
01438 
01439                                 if (!Frustum_ClipToPlaneUVRGBA(FPlanes, pDest1, pDest2, pTex1, pTex2, Length1, &Length2))
01440                                         break;
01441 
01442                                 assert(Length2 < MAX_TEMP_VERTS);
01443                                 
01444                                 if (pDest1 == Dest2)
01445                                 {
01446                                         pDest1 = Dest1;
01447                                         pDest2 = Dest2;
01448                                         pTex1 = Tex1;
01449                                         pTex2 = Tex2;
01450                                 }
01451                                 else
01452                                 {
01453                                         pDest1 = Dest2;
01454                                         pDest2 = Dest1;
01455                                         pTex1 = Tex2;
01456                                         pTex2 = Tex1;
01457                                 }
01458                                 Length1 = Length2;
01459                         }
01460                         
01461                         assert(Length1 < MAX_TEMP_VERTS);
01462           
01463                         if (p != FInfo->NumPlanes)
01464                                 continue;                               // Can't possibly be visible
01465 
01466                         if (Length1 < 3)
01467                                 continue;                               // Can't possibly be visible
01468                         
01469                         // Transform to world space...
01470                         for (v=0; v<Length1; v++)
01471                                 geCamera_Transform(Camera, &pDest1[v], &pDest2[v]);
01472 
01473                         // Project the face, and combine tex coords into one structure (Clipped1)
01474                         Frustum_ProjectRGBA(pDest2, pTex1, (DRV_TLVertex*)ScreenPts, Length1, Camera);
01475 
01476                         // LWM_ACTOR_RENDERING
01477                         #if 1
01478                         ScreenPts[0].a = P->OverallAlpha ;
01479                         #else
01480                         ScreenPts[0].a = 255.0f;
01481                         #endif
01482 
01483                         geEngine_RenderPoly(Engine, (GE_TLVertex*)ScreenPts, Length1, PM->Bitmap, 0 );
01484                 }
01485         }
01486 
01487         #pragma message ("BUG:  Shadow caused crash in mirrors (oops).  Need to write a RenderShadowThroughFrustum...")
01488         /*
01489         if (P->DoShadow)
01490                 {
01491                         gePuppet_DrawShadow(P,Engine,World,Camera);
01492                 }
01493         */
01494         return GE_TRUE;
01495 }

void GENESISCC gePuppet_SetAlpha gePuppet P,
geFloat  Alpha
 

Definition at line 1182 of file puppet.c.

References GENESISCC, and gePuppet::OverallAlpha.

Referenced by geActor_SetAlpha().

01183 {
01184         assert( P ) ;
01185         P->OverallAlpha = Alpha ;
01186 }

void GENESISCC gePuppet_SetEnvironmentOptions gePuppet P,
geEnvironmentOptions envop
 

Definition at line 1150 of file puppet.c.

References GE_FALSE, GE_TRUE, GENESISCC, gePuppet::internal_env, geEnvironmentOptions::PercentEnvironment, geEnvironmentOptions::PercentMaterial, geEnvironmentOptions::PercentPuppet, geEnvironmentOptions::Supercede, and geEnvironmentOptions::UseEnvironmentMapping.

Referenced by geActor_SetEnvironOptions().

01151 {
01152         assert ( P );
01153         assert ( (envop->UseEnvironmentMapping == GE_TRUE) || (envop->UseEnvironmentMapping == GE_FALSE ) );
01154         assert ( (envop->Supercede == GE_TRUE) || (envop->Supercede == GE_FALSE) );
01155         assert ( (envop->PercentEnvironment >= 0.0f) && (envop->PercentEnvironment <= 1.0f) );
01156         assert ( (envop->PercentMaterial >= 0.0f) && (envop->PercentMaterial <= 1.0f) );
01157         assert ( (envop->PercentPuppet >= 0.0f) && (envop->PercentPuppet <= 1.0f) );
01158 
01159         P->internal_env.UseEnvironmentMapping = envop->UseEnvironmentMapping;
01160         P->internal_env.Supercede = envop->Supercede;
01161         P->internal_env.PercentEnvironment = envop->PercentEnvironment;
01162         P->internal_env.PercentMaterial = envop->PercentEnvironment;
01163         P->internal_env.PercentPuppet = envop->PercentPuppet;
01164 }

void GENESISCC gePuppet_SetLightingOptions gePuppet P,
geBoolean  UseFillLight,
const geVec3d FillLightNormal,
geFloat  FillLightRed,
geFloat  FillLightGreen,
geFloat  FillLightBlue,
geFloat  AmbientLightRed,
geFloat  AmbientLightGreen,
geFloat  AmbientLightBlue,
geBoolean  AmbientLightFromFloor,
int  MaximumDynamicLightsToUse,
int  LightReferenceBoneIndex,
int  PerBoneLighting
 

Referenced by geActor_SetLightingOptions().

geBoolean GENESISCC gePuppet_SetMaterial gePuppet P,
int  MaterialIndex,
geBitmap Bitmap,
geFloat  Red,
geFloat  Green,
geFloat  Blue
 

Definition at line 222 of file puppet.c.

References gePuppet_Material::Bitmap, Blue, gePuppet_Color::Blue, gePuppet_Material::Color, GE_FALSE, GE_TRUE, geBitmap_CreateRef(), geBitmap_Destroy(), geBoolean, geErrorLog_AddString, GENESISCC, geWorld_AddBitmap(), geWorld_RemoveBitmap(), Green, gePuppet_Color::Green, gePuppet::MaterialArray, NULL, Red, gePuppet_Color::Red, gePuppet_Material::UseTexture, and gePuppet::World.

Referenced by geActor_SetMaterial().

00224 {
00225         assert( P );
00226         assert( MaterialIndex >= 0 );
00227         assert( MaterialIndex < P->MaterialCount );
00228 
00229         {
00230         geBitmap * OldBitmap;
00231         gePuppet_Material *M = P->MaterialArray + MaterialIndex;
00232 
00233                 OldBitmap = M->Bitmap;
00234 
00235                 M->Bitmap               = Bitmap;
00236                 M->Color.Red    = Red;
00237                 M->Color.Green  = Green;
00238                 M->Color.Blue   = Blue;
00239 
00240                 if ( OldBitmap != Bitmap ) 
00241                 {               
00242                         if ( OldBitmap )
00243                         {
00244                                 assert( M->UseTexture );                
00245                                 geWorld_RemoveBitmap( P->World, OldBitmap );
00246                                 geBitmap_Destroy( &(OldBitmap) );
00247                         }
00248                         
00249                         M->UseTexture = GE_FALSE;
00250 
00251                         if ( Bitmap )
00252                         {
00253                                 geBitmap_CreateRef(Bitmap);
00254                                                 
00255                                 M->UseTexture = GE_TRUE;
00256 
00257                                 if ( ! geWorld_AddBitmap(P->World,Bitmap) )
00258                                 {
00259                                         geErrorLog_AddString(-1,"Puppet_SetMaterial : World_AddBitmap", NULL);
00260                                         return GE_FALSE;
00261                                 }
00262                         }
00263                 }
00264         }
00265 
00266         return GE_TRUE;
00267 }

void GENESISCC gePuppet_SetShadow gePuppet P,
geBoolean  DoShadow,
geFloat  Scale,
const geBitmap ShadowMap,
int  BoneIndex
 

Definition at line 1883 of file puppet.c.

References gePuppet::DoShadow, GE_FALSE, GE_TRUE, geBitmap_CreateRef(), geBitmap_Destroy(), GENESISCC, gePuppet::ShadowBoneIndex, gePuppet::ShadowMap, and gePuppet::ShadowScale.

Referenced by geActor_SetShadow().

01886 {
01887         assert( P );
01888         assert( (DoShadow==GE_FALSE) || (DoShadow==GE_TRUE));
01889 
01890         if ( P->ShadowMap )
01891                 geBitmap_Destroy((geBitmap **)&(P->ShadowMap));
01892 
01893         P->DoShadow = DoShadow;
01894         P->ShadowScale = Scale;
01895         P->ShadowMap = ShadowMap;
01896         P->ShadowBoneIndex = BoneIndex;
01897 
01898         if ( P->ShadowMap )
01899                 geBitmap_CreateRef((geBitmap *)P->ShadowMap);
01900 }

void GENESISCC gePuppet_SetStaticLightingOptions gePuppet P,
geBoolean  AmbientLightFromStaticLights,
geBoolean  TestRayCollision,
int  MaxStaticLightsToUse
 

Definition at line 401 of file puppet.c.

References gePuppet::AmbientLightFromStaticLights, gePuppet::DoTestRayCollision, GENESISCC, gePuppet::MaxStaticLightsToUse, and NULL.

Referenced by geActor_SetStaticLightingOptions().

00402 {       assert( P!= NULL);
00403         P->AmbientLightFromStaticLights = UseAmbientLightFromStaticLights;
00404         P->DoTestRayCollision = TestRayCollision;
00405         P->MaxStaticLightsToUse = MaxStaticLightsToUse;
00406 }       


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