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

World.h File Reference

#include "ErrorLog.h"
#include "PtrTypes.h"
#include "Genesis.h"
#include "GBSPFile.h"
#include "Motion.h"
#include "Surface.h"
#include "Fog.h"
#include "WBitmap.h"
#include "User.h"
#include "Light.h"
#include "Bitmaplist.h"
#include "Actor.h"
#include "Sprite.h"

Go to the source code of this file.

Compounds

struct  geWorld
struct  geWorld_DebugInfo
struct  geWorld_EntClassSet
struct  geWorld_FogData
struct  geWorld_Leaf
struct  geWorld_Model
struct  geWorld_SkyBoxTData
struct  World_Actor
struct  World_BSP
struct  World_SkyBox
struct  World_Sprite

Defines

#define MAX_MODELS   256
#define MAX_MIRROR_RECURSION   1
#define MAX_RENDERFACE_VERTS   64
#define MODEL_CHANGED_XFORM   (1<<0)
#define MAX_VISIBLE_FOG   12
#define MAX_WORLD_ENT_CLASS_SETS   256

Typedefs

typedef geWorld_Model geWorld_Model
typedef geWorld_Leaf geWorld_Leaf
typedef World_BSP World_BSP
typedef World_Actor World_Actor
typedef World_Sprite World_Sprite
typedef geWorld geWorld

Functions

GENESISAPI geWorldgeWorld_Create (geVFile *File)
GENESISAPI void geWorld_Free (geWorld *World)
geBoolean geWorld_CreateRef (geWorld *World)
geBoolean World_EngineInit (geEngine *Engine)
void World_EngineShutdown (geEngine *Engine)
geBoolean World_SetEngine (geEngine *Engine)
geBoolean World_SetWorld (geWorld *World)
geBoolean World_SetGBSP (World_BSP *BSP)
geBoolean World_WorldRenderQ (geEngine *Engine, geWorld *World, geCamera *Camera)
GENESISAPI geBoolean geWorld_SetModelXForm (geWorld *World, geWorld_Model *Model, const geXForm3d *XForm)
GENESISAPI geBoolean geWorld_GetModelXForm (const geWorld *World, const geWorld_Model *Model, geXForm3d *XForm)
GENESISAPI geBoolean geWorld_GetModelRotationalCenter (const geWorld *World, const geWorld_Model *Model, geVec3d *Center)
GENESISAPI geMotiongeWorld_ModelGetMotion (geWorld_Model *Model)
GENESISAPI void * geWorld_ModelGetUserData (const geWorld_Model *Model)
GENESISAPI void geWorld_ModelSetUserData (geWorld_Model *Model, void *UserData)
GENESISAPI void geWorld_ModelGetCenter (geWorld_Model *Model, geVec3d *Center)
GENESISAPI geWorld_ModelgeWorld_WorldGetNextModel (geWorld *World, geWorld_Model *Start)
GENESISAPI geBoolean geWorld_AddBitmap (geWorld *World, geBitmap *Bitmap)
GENESISAPI geBoolean geWorld_RemoveBitmap (geWorld *World, geBitmap *Bitmap)
GENESISAPI geBitmapgeWorld_GetBitmapByName (geWorld *World, const char *BitmapName)
geBoolean geWorld_AttachAll (geWorld *World, DRV_Driver *Driver, geFloat Gamma)
geBoolean geWorld_DetachAll (geWorld *World)


Define Documentation

#define MAX_MIRROR_RECURSION   1
 

Definition at line 53 of file World.h.

Referenced by RenderFace().

#define MAX_MODELS   256
 

Definition at line 50 of file World.h.

Referenced by geWorld_Create().

#define MAX_RENDERFACE_VERTS   64
 

Definition at line 54 of file World.h.

Referenced by RenderFace(), and SetupSkyBoxFaceForScene().

#define MAX_VISIBLE_FOG   12
 

Definition at line 89 of file World.h.

Referenced by VisFog().

#define MAX_WORLD_ENT_CLASS_SETS   256
 

Definition at line 188 of file World.h.

Referenced by InsertEntityInClassList().

#define MODEL_CHANGED_XFORM   (1<<0)
 

Definition at line 59 of file World.h.

Referenced by CalcBSPModelInfo(), geWorld_SetModelXForm(), and Vis_VisWorld().


Typedef Documentation

typedef struct geWorld geWorld
 

typedef struct geWorld_Leaf geWorld_Leaf
 

typedef struct geWorld_Model geWorld_Model
 

typedef struct World_Actor World_Actor
 

typedef struct World_BSP World_BSP
 

typedef struct World_Sprite World_Sprite
 


Function Documentation

GENESISAPI geBoolean geWorld_AddBitmap geWorld World,
geBitmap Bitmap
 

Referenced by Corona_Init(), DoSplashScreen(), Electric_SetWorld(), GameMgr_SetTextureIndex(), GameMgr_SetWorld(), gePuppet_FetchTextures(), gePuppet_SetMaterial(), geSprite_RenderPrep(), geWorld_BitmapListInit(), LoadFxTextures(), and PathPoint_SetTexture().

geBoolean geWorld_AttachAll geWorld World,
DRV_Driver Driver,
geFloat  Gamma
 

Definition at line 3447 of file World.c.

References geWorld::AttachedBitmaps, BitmapList_AttachAll(), GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, and NULL.

Referenced by geEngine_AttachAllWorlds().

03448 {
03449         assert(World);
03450         assert(World->AttachedBitmaps);
03451         assert(Driver);
03452 
03453         if (!BitmapList_AttachAll(World->AttachedBitmaps, Driver, Gamma))
03454         {
03455                 geErrorLog_AddString(-1, "geWorld_AttachAll:  BitmapList_AttachAll failed.", NULL);
03456                 return GE_FALSE;
03457         }
03458         
03459         return GE_TRUE;
03460 }

GENESISAPI geWorld* geWorld_Create geVFile File  ) 
 

Definition at line 357 of file World.c.

References geWorld::ActorArray, geWorld::ActorCount, World_BSP::BSPData, BuildSkyBox(), CalcBSPModelInfo(), geWorld::Changed, CreateGBSP(), CreateStaticFogList(), geWorld::CurrentBSP, geWorld::CurrentLeaf, Ent_WorldInit(), Error, GE_ERR_OUT_OF_MEMORY, GE_FALSE, GE_RAM_ALLOCATE_ARRAY, GE_RAM_ALLOCATE_STRUCT, GE_TRUE, geErrorLog_Add, geErrorLog_AddString, GENESISAPI, geRam_Free, geWBitmap_Pool_Create(), geWorld_BitmapListInit(), geWorld_CreateRef(), geWorld_Free(), geXForm3d_SetIdentity(), GBSP_BSPData::GFXSkyData, GBSP_BSPData::GFXTexData, int32, World_BSP::LeafData, Light_WorldInit(), List_Start(), MAX_MODELS, World_BSP::Models, NULL, GBSP_BSPData::NumGFXLeafs, GBSP_BSPData::NumGFXTexData, geWorld::SkyBox, geWorld::SpriteArray, geWorld::SpriteCount, Surf_WorldInit(), User_WorldInit(), Vis_WorldInit(), geWorld_Model::VisFrame, World_BSP::WBitmapPool, and World_CreateBSPFromBox().

Referenced by DoSplashScreen(), and GameMgr_SetWorld().

00358 {
00359         geWorld                 *NewWorld;
00360         int32                   i;
00361         geWorld_Model   *Models;
00362 
00363         NewWorld = GE_RAM_ALLOCATE_STRUCT(geWorld);
00364 
00365         if (!NewWorld)
00366         {
00367                 geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL);
00368                 return NULL;
00369         }
00370 
00371         memset(NewWorld, 0, sizeof(geWorld));
00372 
00373         // Create a ref on the world now, so if there is an error, it will free what is in the world...
00374         geWorld_CreateRef(NewWorld);
00375 
00376         if ( ! List_Start() )
00377                 goto Error;
00378 
00379         if (!File)
00380         {
00381                 geVec3d TMins = {-1000.0f, -1000.0f, -1000.0f};
00382                 geVec3d TMaxs = { 1000.0f,  1000.0f,  1000.0f};
00383 
00384                 NewWorld->CurrentBSP = World_CreateBSPFromBox(&TMins, &TMaxs);
00385         }
00386         else
00387         {
00388                 assert(File != NULL);
00389 
00390                 NewWorld->CurrentBSP = CreateGBSP(File);
00391         }
00392 
00393         // The world has changed
00394         NewWorld->Changed = GE_TRUE;
00395 
00396         if (!NewWorld->CurrentBSP)
00397                 goto Error;
00398 
00399         assert(NewWorld->CurrentBSP->BSPData.NumGFXLeafs > 0);
00400 
00401         // Create the leafdata array
00402         NewWorld->CurrentBSP->LeafData = GE_RAM_ALLOCATE_ARRAY(geWorld_Leaf, NewWorld->CurrentBSP->BSPData.NumGFXLeafs);
00403 
00404         if (!NewWorld->CurrentBSP->LeafData)
00405                 goto Error;
00406 
00407         memset(NewWorld->CurrentBSP->LeafData, 0, sizeof(geWorld_Leaf)*NewWorld->CurrentBSP->BSPData.NumGFXLeafs);
00408 
00409         if (!Light_WorldInit(NewWorld))
00410                 goto Error;
00411 
00412         if (!Ent_WorldInit(NewWorld))
00413                 goto Error;
00414 
00415         if (!Vis_WorldInit(NewWorld))
00416                 goto Error;
00417 
00418         if (!Surf_WorldInit(NewWorld))
00419                 goto Error;
00420 
00421         // Create the wbitmaps out of the GFXTexData
00422         NewWorld->CurrentBSP->WBitmapPool = geWBitmap_Pool_Create(&NewWorld->CurrentBSP->BSPData);
00423 
00424         if (!NewWorld->CurrentBSP->WBitmapPool)
00425                 goto Error;
00426 
00427         #if 1
00428                 // HACK
00429                 // We can now free the texturedata in the BSP that was loaded off disk.
00430                 // Eventually, the BSP disk format will be bitmaps, and no conversion will be needed, JP.
00431                 if (NewWorld->CurrentBSP->BSPData.GFXTexData)   // Not all worlds have tex data!!!
00432                 {
00433                         geRam_Free(NewWorld->CurrentBSP->BSPData.GFXTexData);
00434                         NewWorld->CurrentBSP->BSPData.GFXTexData = NULL;        // This is to assure that FreeGBSPFile does not touch this again
00435                         NewWorld->CurrentBSP->BSPData.NumGFXTexData = 0;
00436                 }
00437         #endif
00438 
00439         // Add all the bitmaps in the WBitmapPool to the world
00440         if (!geWorld_BitmapListInit(NewWorld))
00441         {
00442                 geErrorLog_AddString(-1, "geWorld_WorldCreate:  geWorld_BitmapListInit failed.", NULL);
00443                 return GE_FALSE;
00444         }
00445 
00446         // Init user stuff
00447         if (!User_WorldInit(NewWorld))
00448                 goto Error;
00449         
00450         Models = NewWorld->CurrentBSP->Models;
00451 
00452         //#pragma message ("Fixed number of models supported")
00453         for (i=0; i< MAX_MODELS; i++)
00454         {
00455                 memset(&Models[i], 0, sizeof(geWorld_Model));
00456 
00457                 Models[i].VisFrame = -1;
00458                 
00459                 geXForm3d_SetIdentity(&Models[i].XForm);
00460         }
00461         
00462         CalcBSPModelInfo(NewWorld->CurrentBSP);
00463 
00464         if (!BuildSkyBox(&NewWorld->SkyBox, &NewWorld->CurrentBSP->BSPData.GFXSkyData))
00465                 goto Error;
00466 
00467         NewWorld->CurrentLeaf = -1;                     // Make sure the level gets vised for the first time...
00468 
00469         NewWorld->ActorCount = 0;
00470         NewWorld->ActorArray = NULL;
00471 
00472 //MRB BEGIN
00473 //geSprite
00474         NewWorld->SpriteCount = 0;
00475         NewWorld->SpriteArray = NULL;
00476 //MRB END
00477 
00478         if (!CreateStaticFogList(NewWorld))
00479         {
00480                 geErrorLog_AddString(-1,"Failed to create static FogList", NULL);
00481                 goto Error;
00482         }
00483 
00484         return NewWorld;
00485 
00486         Error:;
00487                 geWorld_Free(NewWorld);
00488 
00489         return NULL;
00490 }

geBoolean geWorld_CreateRef geWorld World  ) 
 

Definition at line 628 of file World.c.

References GE_TRUE, geBoolean, and geWorld::RefCount.

Referenced by geEngine_AddWorld(), and geWorld_Create().

00629 {
00630         World->RefCount++;
00631 
00632         return GE_TRUE;
00633 }

geBoolean geWorld_DetachAll geWorld World  ) 
 

Definition at line 3465 of file World.c.

References geWorld::AttachedBitmaps, BitmapList_DetachAll(), GE_FALSE, GE_TRUE, geBoolean, geErrorLog_AddString, and NULL.

Referenced by geEngine_DetachAllWorlds(), geEngine_RemoveAllWorlds(), and geEngine_RemoveWorld().

03466 {
03467         assert(World);
03468         assert(World->AttachedBitmaps);
03469 
03470         if (!BitmapList_DetachAll(World->AttachedBitmaps))
03471         {
03472                 geErrorLog_AddString(-1, "geWorld_DetachAll:  BitmapList_DetachAll failed.", NULL);
03473                 return GE_FALSE;
03474         }
03475         return GE_TRUE;
03476 }

GENESISAPI void geWorld_Free geWorld World  ) 
 

Definition at line 495 of file World.c.

References World_Actor::Actor, geWorld::ActorArray, geWorld::ActorCount, World_BSP::BSPData, geWorld::CurrentBSP, Ent_WorldShutdown(), geWorld::FogList, GBSP_FreeGBSPFile(), geActor_Destroy(), geErrorLog_AddString, geFog_Destroy(), geFog_GetUserData(), geFog_SetUserData(), GENESISAPI, geRam_Free, geSprite_Destroy(), geWBitmap_Pool_Destroy(), geWorld_BitmapListShutdown(), int32, World_BSP::LeafData, Light_WorldShutdown(), List_Stop(), geFog::Next, NULL, GBSP_BSPData::NumGFXLeafs, geWorld_Leaf::PolyList, geWorld::RefCount, World_Sprite::Sprite, geWorld::SpriteArray, geWorld::SpriteCount, Surf_WorldShutdown(), User_DestroyPolyList(), User_WorldShutdown(), Vis_WorldShutdown(), and World_BSP::WBitmapPool.

Referenced by DoSplashScreen(), GameMgr_FreeWorld(), geEngine_RemoveAllWorlds(), geEngine_RemoveWorld(), and geWorld_Create().

00496 {
00497         int                     i;
00498         geFog           *Fog, *Next;
00499         /*extern                geActor_Count;
00500         extern          geActor_RefCount;
00501         extern          geActor_DefCount;
00502         extern          geActor_DefRefCount;*/
00503 
00504         assert(World);
00505         assert(World->RefCount > 0);
00506 
00507         World->RefCount--;
00508 
00509         if (World->RefCount > 0)
00510                 return;                 // No need to destroy till ref count goes to zero...
00511 
00512 if (World->CurrentBSP)
00513 {
00514         // Shutdown actors
00515         if (World->ActorCount>0)
00516                 {
00517                         assert( World->ActorArray != NULL );
00518                         for (i=0; i< World->ActorCount; i++)
00519                                 {
00520                                 if(!geActor_Destroy( &( World->ActorArray[i].Actor ) ))
00521                                         geErrorLog_AddString(-1, "geWorld_Free:  geActor_Destroy failed.", NULL);
00522                                 }
00523 
00524                         /*geActor_Count       = 0;geActor_DestroyDirect
00525                         geActor_RefCount    = 0;
00526                         geActor_DefCount    = 0;
00527                         geActor_DefRefCount = 0;*/
00528                         World->ActorCount       = 0;
00529 
00530         }
00531         if (World->ActorArray != NULL)
00532                 {
00533                         geRam_Free( World->ActorArray );
00534                         World->ActorArray = NULL;
00535                 }
00536 
00537 //MRB BEGIN
00538 //geSprite
00539         // Shutdown sprites
00540         if (World->SpriteCount>0)
00541         {
00542                         assert( World->SpriteArray != NULL );
00543                         for (i=0; i< World->SpriteCount; i++)
00544                                 {
00545                                         geSprite_Destroy( &( World->SpriteArray[i].Sprite ) );
00546                                 }
00547                         World->SpriteCount = 0;
00548         }
00549         if (World->SpriteArray != NULL)
00550         {
00551                         geRam_Free( World->SpriteArray );
00552                         World->SpriteArray = NULL;
00553         }
00554 //MRB END
00555                 
00556         assert( World->ActorArray == NULL );
00557         
00558         // Call other modules to release info from the world that they created...
00559 #ifdef  MESHES
00560         Mesh_WorldShutdown(World);
00561 #endif
00562         Light_WorldShutdown(World);
00563         Ent_WorldShutdown(World);
00564         Vis_WorldShutdown(World);
00565         Surf_WorldShutdown(World);
00566 
00567         User_WorldShutdown(World);
00568 
00569         if (World->CurrentBSP->WBitmapPool)
00570         {
00571                 geWBitmap_Pool_Destroy(World->CurrentBSP->WBitmapPool);
00572                 World->CurrentBSP->WBitmapPool = NULL;
00573         }
00574 
00575         // Make sure we free all the fog
00576         for (Fog = World->FogList; Fog; Fog = Next)
00577         {
00578                 geWorld_FogData         *FogData;
00579 
00580                 Next = Fog->Next;
00581 
00582                 FogData = (geWorld_FogData*)geFog_GetUserData(Fog);
00583 
00584                 if (FogData)
00585                         geRam_Free(FogData);
00586 
00587                 geFog_SetUserData(Fog, NULL);           // Just in case...
00588 
00589                 geFog_Destroy(Fog);
00590         }
00591 
00592         // Free the leaf data array in the world
00593         if (World->CurrentBSP->LeafData)
00594         {
00595                 int32                   l;
00596                 geWorld_Leaf    *pLeafData;
00597                 
00598                 pLeafData = World->CurrentBSP->LeafData;
00599 
00600                 for (l=0; l< World->CurrentBSP->BSPData.NumGFXLeafs; l++, pLeafData++)
00601                 {
00602                         if (pLeafData->PolyList)
00603                         {
00604                                 User_DestroyPolyList(World, pLeafData->PolyList);
00605                                 pLeafData->PolyList = NULL;
00606                         }
00607                 }
00608         
00609                 geRam_Free(World->CurrentBSP->LeafData);
00610                 World->CurrentBSP->LeafData = NULL;
00611         }
00612 
00613         GBSP_FreeGBSPFile(&World->CurrentBSP->BSPData);
00614         geRam_Free(World->CurrentBSP);
00615 
00616         // Shutdown the bitmaplist      (this should be done last, to give others a chance to remove their bitmaps)
00617         geWorld_BitmapListShutdown(World);
00618 }
00619 
00620         geRam_Free(World);
00621 
00622         List_Stop();
00623 }

GENESISAPI geBitmap* geWorld_GetBitmapByName geWorld World,
const char *  BitmapName
 

Definition at line 3434 of file World.c.

References geWorld::CurrentBSP, GENESISAPI, geWBitmap_Pool_GetBitmapByName(), NULL, and World_BSP::WBitmapPool.

Referenced by ProcEng_Create().

03435 {
03436         if (!World->CurrentBSP)
03437                 return NULL;
03438 
03439         assert(World->CurrentBSP->WBitmapPool);
03440 
03441         return geWBitmap_Pool_GetBitmapByName(World->CurrentBSP->WBitmapPool, BitmapName);
03442 }

GENESISAPI geBoolean geWorld_GetModelRotationalCenter const geWorld World,
const geWorld_Model Model,
geVec3d Center
 

Definition at line 2193 of file World.c.

References GE_TRUE, geBoolean, GENESISAPI, NULL, and geWorld_Model::Pivot.

Referenced by Corona_Frame(), DynLight_Frame(), PathPt_Frame(), and Plat_Trigger().

02197 {
02198         assert(World != NULL);
02199         assert(Model != NULL);
02200         assert(Center != NULL);
02201 
02202         *Center = Model->Pivot;
02203 
02204         return GE_TRUE;
02205 }

GENESISAPI geBoolean geWorld_GetModelXForm const geWorld World,
const geWorld_Model Model,
geXForm3d XForm
 

Definition at line 2064 of file World.c.

References GE_TRUE, geBoolean, GENESISAPI, NULL, and geWorld_Model::XForm.

Referenced by Corona_Frame(), DynLight_Frame(), and PathPt_Frame().

02065 {
02066         assert(World != NULL);
02067         assert(Model != NULL);
02068         assert(XForm != NULL);
02069 
02070         *XForm = Model->XForm;
02071 
02072         return GE_TRUE;
02073 }

GENESISAPI void geWorld_ModelGetCenter geWorld_Model Model,
geVec3d Center
 

Definition at line 2278 of file World.c.

References GENESISAPI, and geWorld_Model::RealCenter.

02279 {
02280   *Center = Model->RealCenter;
02281 
02282   return;
02283 }

GENESISAPI geMotion* geWorld_ModelGetMotion geWorld_Model Model  ) 
 

Definition at line 2235 of file World.c.

References geWorld_Model::BSPModel, GENESISAPI, and GFX_Model::Motion.

Referenced by Door_Control(), Door_Spawn(), ModelCtl_Frame(), Plat_Control(), and Plat_Spawn().

02236 {
02237         assert(Model);
02238         return Model->BSPModel->Motion;
02239 }

GENESISAPI void* geWorld_ModelGetUserData const geWorld_Model Model  ) 
 

Definition at line 2243 of file World.c.

References GENESISAPI, and geWorld_Model::UserData.

Referenced by Blaster_Control(), Bot_CheckVelocity(), Bot_GetContents(), Bot_OverLedge(), CheckVelocity(), Client_Control(), FireShredder(), and Rocket_Control().

02244 {
02245         assert(Model);
02246         return Model->UserData;
02247 }

GENESISAPI void geWorld_ModelSetUserData geWorld_Model Model,
void *  UserData
 

Definition at line 2251 of file World.c.

References GENESISAPI, and geWorld_Model::UserData.

Referenced by CheckClientPlayerChanges(), and Server_RegisterPlayerModel().

02252 {
02253         assert(Model);
02254         Model->UserData = UserData;
02255 }

GENESISAPI geBoolean geWorld_RemoveBitmap geWorld World,
geBitmap Bitmap
 

Referenced by Corona_Shutdown(), DoSplashScreen(), Electric_SetWorld(), FreeFxTextures(), GameMgr_FreeWorld(), gePuppet_Destroy(), and gePuppet_SetMaterial().

GENESISAPI geBoolean geWorld_SetModelXForm geWorld World,
geWorld_Model Model,
const geXForm3d XForm
 

Definition at line 1999 of file World.c.

References geWorld_Model::ChangedFlags, GE_TRUE, geBoolean, GENESISAPI, geVec3d_Add(), geVec3d_Inverse(), geVec3d_Scale(), geXForm3d_Rotate(), geWorld_Model::Maxs, geWorld_Model::Mins, MODEL_CHANGED_XFORM, NULL, geWorld_Model::TMaxs, geWorld_Model::TMins, geXForm3d::Translation, VectorToSUB, and geWorld_Model::XForm.

Referenced by Client_MovePlayerModel(), Client_UpdateSinglePlayer(), ModelCtl_Frame(), and Server_MovePlayerModel().

02000 {
02001         geVec3d AxisVecs[3], Center;
02002         int             i, j;
02003 
02004         assert(World != NULL);
02005         assert(Model != NULL);
02006 
02007         Model->XForm = *XForm;
02008         memset(AxisVecs, 0, sizeof(geVec3d)*3);
02009 
02010         //grab the box center
02011         geVec3d_Add(&Model->Mins, &Model->Maxs, &Center);
02012         geVec3d_Scale(&Center, 0.5f, &Center);
02013 
02014         //build a local rotated axis based on extent vectors
02015         //(this could be simplified to less fmuls)
02016         for(i=0;i < 3;i++)
02017         {
02018                 VectorToSUB(AxisVecs[i], i)     =VectorToSUB(Model->Maxs, i) - VectorToSUB(Center, i);
02019                 geXForm3d_Rotate(XForm, &AxisVecs[i], &AxisVecs[i]);
02020         }
02021 
02022         //mask off the sign bits
02023         for(i=0;i < 3;i++)
02024         {
02025                 for(j=0;j < 3;j++)
02026                 {
02027                         *((int *)(&AxisVecs[i])+j)      =*((int *)(&AxisVecs[i])+j) & 0x7fffffff;
02028                 }
02029         }
02030 
02031         //add up vecs to get max
02032         for(i=0;i < 3;i++)
02033         {
02034                 VectorToSUB(Model->TMaxs, i)
02035                         =VectorToSUB(AxisVecs[0], i)
02036                         + VectorToSUB(AxisVecs[1], i)
02037                         + VectorToSUB(AxisVecs[2], i);
02038         }
02039 
02040         //local min is opposite of max
02041         Model->TMins    =Model->TMaxs;
02042         geVec3d_Inverse(&Model->TMins);
02043 
02044         //move back to world
02045         geVec3d_Add(&XForm->Translation, &Center, &Center);
02046         geVec3d_Add(&Model->TMins, &Center, &Model->TMins);
02047         geVec3d_Add(&Model->TMaxs, &Center, &Model->TMaxs);
02048 
02049         //add a small epsilon
02050         for(i=0;i < 3;i++)
02051         {
02052                 VectorToSUB(Model->TMaxs, i)    +=1.0f;
02053                 VectorToSUB(Model->TMins, i)    -=1.0f;
02054         }
02055 
02056         Model->ChangedFlags |= MODEL_CHANGED_XFORM;
02057 
02058         return GE_TRUE;
02059 }

GENESISAPI geWorld_Model* geWorld_WorldGetNextModel geWorld World,
geWorld_Model Start
 

geBoolean World_EngineInit geEngine Engine  ) 
 

Definition at line 235 of file World.c.

References GE_TRUE, and geBoolean.

00236 {
00237         return GE_TRUE;
00238 }

void World_EngineShutdown geEngine Engine  ) 
 

Definition at line 243 of file World.c.

References BSPData, CEngine, CWorld, and NULL.

00244 {
00245         CEngine = NULL;
00246         CWorld = NULL;
00247         BSPData = NULL;
00248 }

geBoolean World_SetEngine geEngine Engine  ) 
 

Definition at line 639 of file World.c.

References CEngine, Engine, GE_FALSE, GE_TRUE, geBoolean, Light_SetEngine(), NULL, Plane_SetEngine(), and Surf_SetEngine().

Referenced by geEngine_CreateWorldLightmapTHandles(), geEngine_DestroyWorldLightmapTHandles(), and World_WorldRenderQ().

00640 {
00641         assert (Engine != NULL);
00642 
00643         CEngine = Engine;
00644 
00645         // Let all sub modules know what's going on...
00646         if (!Light_SetEngine(Engine))
00647                 return GE_FALSE;
00648         if (!Plane_SetEngine(Engine))
00649                 return GE_FALSE;
00650         if (!Surf_SetEngine(Engine))
00651                 return GE_FALSE;
00652 
00653         return GE_TRUE;
00654 }

geBoolean World_SetGBSP World_BSP BSP  ) 
 

Definition at line 682 of file World.c.

References BSPData, CBSP, GE_FALSE, GE_TRUE, geBoolean, Light_SetGBSP(), NULL, Plane_SetGBSP(), and Surf_SetGBSP().

Referenced by geEngine_CreateWorldLightmapTHandles(), geEngine_DestroyWorldLightmapTHandles(), and World_WorldRenderQ().

00683 {
00684         assert(BSP != NULL);
00685 
00686         // Make quick pointer to the world bsp data
00687         CBSP = BSP;
00688         BSPData = &BSP->BSPData;
00689 
00690         // Let all sub modules know what's going on...
00691         if (!Light_SetGBSP(BSP))
00692                 return GE_FALSE;
00693         if (!Plane_SetGBSP(BSP))
00694                 return GE_FALSE;
00695 
00696         if (!Surf_SetGBSP(BSP))
00697                 return GE_FALSE;
00698 
00699         return GE_TRUE;
00700 }

geBoolean World_SetWorld geWorld World  ) 
 

Definition at line 660 of file World.c.

References CWorld, GE_FALSE, GE_TRUE, geBoolean, Light_SetWorld(), NULL, Plane_SetWorld(), and Surf_SetWorld().

Referenced by geEngine_CreateWorldLightmapTHandles(), geEngine_DestroyWorldLightmapTHandles(), and World_WorldRenderQ().

00661 {
00662         assert(World != NULL);
00663         
00664         CWorld = World;
00665 
00666         // Let all sub modules know what's going on...
00667         if (!Light_SetWorld(World))
00668                 return GE_FALSE;
00669         if (!Plane_SetWorld(World))
00670                 return GE_FALSE;
00671         if (!Surf_SetWorld(World))
00672                 return GE_FALSE;
00673 
00674         return GE_TRUE;
00675 }

geBoolean World_WorldRenderQ geEngine Engine,
geWorld World,
geCamera Camera
 

Definition at line 715 of file World.c.

References World_SkyBox::Angle, DRV_Driver::BeginModels, CanDoMirrors, CDebugInfo, CFrustumInfo, geWorld::CurFrameDynamic, geWorld::CurrentBSP, geWorld::DebugInfo, World_SkyBox::Dpm, DRV_PREFERENCE_NO_MIRRORS, DRV_Driver::EndModels, Engine, DRV_Driver::EngineSettings, Frustum_SetFromCamera(), g_HackFrustum, GE_FALSE, GE_TRUE, geBoolean, geCamera_GetCameraSpaceXForm(), geCamera_GetPov(), geFloat, GlobalEyePos, geWorld::LastCameraXForm, Light_SetupLights(), MirrorRecursion, NULL, NumGListOperations, NumTransPolys, DRV_EngineSettings::PreferenceFlags, RDriver, RenderScene(), SetupStaticData(), geWorld::SkyBox, User_DestroyOncePolys(), Vis_VisWorld(), World_SetEngine(), World_SetGBSP(), and World_SetWorld().

Referenced by geEngine_RenderWorld().

00716 {
00717         Frustum_Info            FrustumInfo;
00718         geFloat                         Rpm;
00719         World_SkyBox            *pSkyBox;
00720 
00721         assert(Engine != NULL);
00722         assert(World != NULL);
00723         assert(Camera!= NULL);
00724 
00725         World->CurFrameDynamic++;
00726 
00727         MirrorRecursion = 0;
00728         NumTransPolys[MirrorRecursion] = 0;
00729         NumGListOperations[MirrorRecursion] = 0;
00730         
00731         // Clear the debug info for this world
00732         //memset(&World->DebugInfo, 0, sizeof(geWorld_DebugInfo));
00733         CDebugInfo = &World->DebugInfo;
00734 
00735         // Setup modules that need info that we don't want to lug around with us...
00736         // NOTE - This might screw up multi-threading, so it might need to be changed
00737         // around a little to work with multi-threading
00738         World_SetEngine(Engine);
00739         World_SetWorld(World);
00740         World_SetGBSP(World->CurrentBSP);
00741         
00742         // FIXME:  REMOVE!!!!!
00743         GlobalEyePos = *geCamera_GetPov(Camera);
00744 
00745         // Setup some globals for this pass (this must be done before anyone uses them, or KABOOM)
00746         SetupStaticData();
00747 
00748         CFrustumInfo = &FrustumInfo;
00749 
00750         // Se if we can do mirrors with this driver
00751         CanDoMirrors = (RDriver->EngineSettings->PreferenceFlags & DRV_PREFERENCE_NO_MIRRORS)==0;
00752 
00753         // Setup the View Frustum to default window from the camera
00754         Frustum_SetFromCamera(&FrustumInfo, Camera);
00755 
00756         // Have the Vis module setup all vising info
00757         Vis_VisWorld(Engine, World, Camera, &FrustumInfo);
00758 
00759         // Setup the dynamic lights, etc...
00760         if (!Light_SetupLights(World))
00761                 return GE_FALSE;
00762 
00763         g_HackFrustum = FrustumInfo;
00764 
00765         // Render the entire scene through the DEFAULT FRUSTUM
00766         if (!RenderScene(Engine, World, Camera, &FrustumInfo))
00767                 return GE_FALSE;
00768 
00769         // Adjust current sky angle 
00770         pSkyBox = &World->SkyBox;
00771         Rpm = (pSkyBox->Dpm/180.0f)*3.14159f;           // Get radiuns per minute
00772         pSkyBox->Angle += Rpm*(1/30.0f);                        // Assume 30 fps for now :)
00773 
00774         // Little hack to flush the scene
00775         RDriver->BeginModels();
00776         RDriver->EndModels();
00777 
00778         if (!User_DestroyOncePolys(World))
00779                 return GE_FALSE;
00780 
00781 #if 1
00782         // <> CB remember the last camera we rendered with,
00783         //      so we can avoiding redoing view-dependent calculation
00784         World->LastCameraXForm = * geCamera_GetCameraSpaceXForm(Camera);
00785 #endif
00786 
00787         return GE_TRUE;
00788 }


Generated on Tue Sep 30 12:38:26 2003 for GTestAndEngine by doxygen 1.3.2