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

World.h

Go to the documentation of this file.
00001 /****************************************************************************************/
00002 /*  World.h                                                                             */
00003 /*                                                                                      */
00004 /*  Author: John Pollard                                                                */
00005 /*  Description: Code to render the world, and distribute work to other modules         */
00006 /*                                                                                      */
00007 /*  The contents of this file are subject to the Genesis3D Public License               */
00008 /*  Version 1.01 (the "License"); you may not use this file except in                   */
00009 /*  compliance with the License. You may obtain a copy of the License at                */
00010 /*  http://www.genesis3d.com                                                            */
00011 /*                                                                                      */
00012 /*  Software distributed under the License is distributed on an "AS IS"                 */
00013 /*  basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.  See                */
00014 /*  the License for the specific language governing rights and limitations              */
00015 /*  under the License.                                                                  */
00016 /*                                                                                      */
00017 /*  The Original Code is Genesis3D, released March 25, 1999.                            */
00018 /*  Genesis3D Version 1.1 released November 15, 1999                                 */
00019 /*  Copyright (C) 1999 WildTangent, Inc. All Rights Reserved           */
00020 /*                                                                                      */
00021 /****************************************************************************************/
00022 #ifndef GE_WORLD_H
00023 #define GE_WORLD_H
00024 
00025 #include "ErrorLog.h"
00026 #include "PtrTypes.h"
00027 #include "Genesis.h"
00028 #include "GBSPFile.h"
00029 #include "Motion.h"
00030 #include "Surface.h"
00031 #include "Fog.h"
00032 #include "WBitmap.h"
00033 #include "User.h"
00034 #include "Light.h"
00035 
00036 #include "Bitmaplist.h"
00037 
00038 #include "Actor.h"                      
00039 
00040 //MRB BEGIN
00041 //geSprite
00042 #include "Sprite.h"
00043 //MRB END                       
00044 
00045 #ifdef __cplusplus
00046 extern "C" {
00047 #endif
00048 
00049 
00050 #define MAX_MODELS      256
00051 
00052 // Upper limits on misc things
00053 #define MAX_MIRROR_RECURSION            1
00054 #define MAX_RENDERFACE_VERTS            64
00055 
00056 //=====================================================================================
00057 //      Structure defines
00058 //=====================================================================================
00059 #define MODEL_CHANGED_XFORM                             (1<<0)
00060 
00061 typedef struct geWorld_Model
00062 {
00063         char                    Name[64];                                                       // Model's name
00064         int32                   GFXModelNum;                                            // Model number in disk tree structure
00065         geXForm3d               XForm;                                                          // Models transform     (Object Space)
00066         geVec3d                 Mins, Maxs;                                                     // Model BBox (World Space)
00067         geVec3d                 TMins, TMaxs;                                           // Translated Model BBox (World Space)
00068         geVec3d                 Pivot;                                                          // Center of rotation (World Space)
00069         geVec3d                 RealCenter;
00070         int32                   VisFrame;                                                       // == World->CurFrame if visible
00071         void                    *UserData;                                                      // Place for client to store data
00072         GFX_Model *             BSPModel;                                                       // Oh, this is terrible.
00073 
00074         geBoolean               Open;                                                           // Model Open/Closed    (Set by API, used for area vising)
00075 
00076         uint32                  Flags;                                                          // GE_MODEL_RENDER_NORMAL, etc... (getypes.h)
00077 
00078         uint32                  ChangedFlags;
00079 } geWorld_Model;
00080 
00081 typedef struct geWorld_Leaf
00082 {
00083         int32                   VisFrame;
00084         int32                   Parent;                                                         // Parent nodes of all leafs
00085 
00086         gePoly                  *PolyList;                                                      // List of poly fragments to render for this leaf (geWorld_AddPoly)
00087 } geWorld_Leaf;
00088 
00089 #define MAX_VISIBLE_FOG         12      // Hope to God there is not this much visible at a time!!!
00090 
00091 // This is set in the UserData of the fog the the world creates at load time
00092 typedef struct
00093 {
00094         int32                   Leaf;
00095 
00096         geVec3d                 Mins;                                                           // - Radius
00097         geVec3d                 Maxs;                                                           // + Radius
00098 
00099         int32                   VisFrame;                                                       // == World->CurFrameDynamic when visible
00100 
00101         geWorld                 *World;
00102 } geWorld_FogData;
00103 
00104 typedef struct World_BSP
00105 {
00106         char                    FileName[200];
00107         GBSP_BSPData    BSPData;                                // Info in the BSP loaded directly off disk
00108 
00109         //      Extra info thats not in the disk bsp structure
00110         Surf_SurfInfo   *SurfInfo;                                                      // Valid when GE_SetGBSPFile is called
00111         Surf_TexVert    *TexVerts;                                                      //
00112 
00113         geWBitmap_Pool  *WBitmapPool;
00114 
00115         geWorld_Model   Models[MAX_MODELS];                                     // Extra info about models not in disk structure
00116 
00117         geWorld_Leaf    *LeafData;
00118 
00119         int32                   *ClusterVisFrame;
00120         int32                   *NodeVisFrame;
00121         int32                   *AreaVisFrame;
00122         uint8                   AreaConnections[256][256];
00123 
00124         int32                   *NodeParents;                                           // Parent nodes of all leafs
00125 
00126 } World_BSP;
00127 
00128 typedef struct
00129 {
00130         // Untransformed original data
00131         geVec3d                 Verts[6][4];
00132         Surf_TexVert    TexVerts[6][4];
00133         
00134         geVec3d                 Axis;                                                           // Rotation axis
00135         geFloat                 Dpm;                                                            // Degres per minute
00136         geFloat                 DrawScale;                                                      // Texture drawscale
00137         int32                   Textures[6];
00138         
00139         geFloat                 Angle;                                                          // Current rotation angle around roation axis
00140 
00141 } World_SkyBox;
00142 
00143 typedef struct
00144 {
00145         // Transformed data
00146         uint32                  SkyFlags;
00147 
00148         geVec3d                 TransformedVecs[6][2];
00149         GFX_Plane               TransformedPlanes[6];
00150 
00151         int32                   NumTransformed;                                         // Num transformed and clipped
00152         geVec3d                 TransformedVerts[6][10];                        // Transformed verts
00153         Surf_TexVert    TransformedTexVerts[6][10];                     // Transformed tex verts
00154         int32                   NumTransformedVerts[6];                         // Number of transformed verts/texverts
00155         int32                   OriginalFaces[6];                                       // Indexes to original bitmap
00156 
00157 } geWorld_SkyBoxTData;
00158 
00159 typedef struct World_Actor
00160 {
00161         geActor                 *Actor;
00162         uint32                  Flags;                          // GE_ACTOR_RENDER_NORMAL, GE_ACTOR_RENDER_MIRRORS, GE_ACTOR_COLLIDE
00163         uint32                  UserFlags;
00164 
00165         //int32                 Leaf;                           // Current leaf the actor is in (currently used for PVS occlusion)
00166 } World_Actor;
00167 
00168 //MRB BEGIN
00169 //geSprite
00170 typedef struct World_Sprite
00171 {
00172         geSprite                        *Sprite;
00173         uint32                  Flags;                          // GE_SPRITE_RENDER_NORMAL, GE_SPRITE_RENDER_MIRRORS, GE_SPRITE_COLLIDE
00174         uint32                  UserFlags;
00175 
00176         //int32                 Leaf;                           // Current leaf the sprite is in (currently used for PVS occlusion)
00177 } World_Sprite;
00178 //MRB END
00179 
00180 /******
00181 
00182 Critial : A negative-numbered Node is a Leaf.
00183         Node (-1) is Leaf 0 ; (the first leaf is Leaf 0).
00184         Node (-N) is Leaf (N-1) = (-Node-1)
00185 
00186 ******/
00187 
00188 #define MAX_WORLD_ENT_CLASS_SETS        256
00189 
00190 typedef struct
00191 {
00192         const char                      *ClassName;             // NULL for main set
00193         geEntity_EntitySet      *Set;
00194 } geWorld_EntClassSet;
00195 
00196 typedef struct
00197 {
00198         int32           NumNodesTraversed1;
00199         int32           NumNodesTraversed2;
00200         int32           NumLeafsHit1;
00201         int32           NumLeafsHit2;
00202         int32           NumLeafsWithUserPolys;
00203         int32           NumUserPolys;
00204 
00205 } geWorld_DebugInfo;
00206 
00207 typedef struct geWorld
00208 {
00209         int32                           CurFrameStatic;                                         // World CurrentFrame
00210         int32                           CurFrameDynamic;                                        // World CurrentFrame
00211         geFloat                         CurTime;                                                        // World CurrentTime
00212         int32                           CurrentLeaf;
00213         geBoolean                       ForceVis;
00214 
00215         geBoolean                       VisInfo;
00216 
00217         // Info that each respective module fills in...
00218         World_BSP                       *CurrentBSP;                                            // Valid when geWorld_SetGBSP is called
00219 
00220         World_SkyBox            SkyBox;
00221 
00222         Frustum_Info            *FrustumInfo;
00223 
00224         Light_LightInfo         *LightInfo;                                                     // Info that the light module fills in
00225 
00226         Mesh_MeshInfo           *MeshInfo;                                                      // Info that the mesh module fills in
00227         
00228         int32                           ActorCount;                                                     // Number of actors in world
00229         World_Actor                     *ActorArray;                                            // Array of actors
00230 
00231 //MRB BEGIN
00232 //geSprite
00233         int32                           SpriteCount;                                                    // Number of sprites in world
00234         World_Sprite                    *SpriteArray;                                           // Array of sprites
00235 //MRB END
00236         
00237         geWorld_EntClassSet     EntClassSets[MAX_WORLD_ENT_CLASS_SETS];
00238         int32                           NumEntClassSets;
00239 
00240         User_Info                       *UserInfo;
00241 
00242         // Debug info
00243         int32                           ActiveUserPolys;
00244         geWorld_DebugInfo       DebugInfo;
00245 
00246         geFog                           *FogList;                                                       // Linked list of fog in the world currently
00247         
00248         geFog                           *VisibleFog[MAX_VISIBLE_FOG];           // List of visible fog for this frame
00249         int32                           NumVisibleFog;
00250 
00251         BitmapList                      *AttachedBitmaps;                                               
00252 
00253         geXForm3d                       LastCameraXForm;
00254 
00255         int32                           RefCount;
00256 
00257         geBoolean                       Changed;                                                        // GE_TRUE if this world has changed
00258 
00259 } geWorld;
00260 
00261 //=====================================================================================
00262 //      Function prototypes
00263 //=====================================================================================
00264 GENESISAPI              geWorld *geWorld_Create(geVFile *File);
00265 GENESISAPI              void geWorld_Free(geWorld *World);
00266 geBoolean               geWorld_CreateRef(geWorld *World);
00267 
00268 geBoolean       World_EngineInit(geEngine *Engine);
00269 void            World_EngineShutdown(geEngine *Engine);
00270 
00271 geBoolean       World_SetEngine(geEngine *Engine);
00272 geBoolean       World_SetWorld(geWorld *World);
00273 geBoolean       World_SetGBSP(World_BSP *BSP);
00274 
00275 geBoolean       World_WorldRenderQ(geEngine *Engine, geWorld *World, geCamera *Camera);
00276 
00277 GENESISAPI geBoolean geWorld_SetModelXForm(
00278         geWorld *                       World,
00279         geWorld_Model *         Model,
00280         const geXForm3d *       XForm);
00281 GENESISAPI geBoolean geWorld_GetModelXForm(
00282         const geWorld *                 World,
00283         const geWorld_Model *   Model,
00284         geXForm3d *                             XForm);
00285 
00286 GENESISAPI geBoolean geWorld_GetModelRotationalCenter(
00287         const geWorld *                 World,
00288         const geWorld_Model *   Model,
00289         geVec3d *                               Center);
00290 
00291 GENESISAPI geMotion * geWorld_ModelGetMotion(geWorld_Model *Model);
00292 
00293 GENESISAPI void * geWorld_ModelGetUserData(const geWorld_Model *Model);
00294 
00295 GENESISAPI void geWorld_ModelSetUserData(geWorld_Model *Model, void *UserData);
00296 
00297 //      eaa3 07/28/2000
00298 
00299 GENESISAPI void geWorld_ModelGetCenter(geWorld_Model *Model, geVec3d *Center);
00300 
00301 GENESISAPI geWorld_Model *geWorld_WorldGetNextModel(geWorld *World, geWorld_Model *Start);
00302 
00303 GENESISAPI geBoolean geWorld_AddBitmap(geWorld *World, geBitmap *Bitmap);
00304 GENESISAPI geBoolean geWorld_RemoveBitmap(geWorld *World,geBitmap *Bitmap);
00305 
00306 GENESISAPI geBitmap *geWorld_GetBitmapByName(geWorld *World, const char *BitmapName);
00307 
00308 geBoolean geWorld_AttachAll(geWorld *World, DRV_Driver *Driver, geFloat Gamma);
00309 geBoolean geWorld_DetachAll(geWorld *World);
00310 
00311 #ifdef __cplusplus
00312 }
00313 #endif
00314 #endif
00315 

Generated on Tue Sep 30 12:36:41 2003 for GTestAndEngine by doxygen 1.3.2