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

USER.H File Reference

#include <Assert.h>
#include <Windows.h>
#include "BaseType.h"
#include "Vec3d.h"
#include "XForm3d.h"
#include "Camera.h"
#include "Genesis.h"
#include "World.h"
#include "Surface.h"
#include "DCommon.h"

Go to the source code of this file.

Compounds

struct  gePoly
struct  User_Info

Defines

#define MAX_USER_VERTS   4
#define USER_MAX_SORTED_POLYS   1024

Typedefs

typedef gePoly gePoly
typedef User_Info User_Info

Functions

geBoolean User_EngineInit (geEngine *Engine)
void User_EngineShutdown (geEngine *Engine)
geBoolean User_WorldInit (geWorld *World)
void User_WorldShutdown (geWorld *World)
geBoolean User_RenderPolyList (gePoly *PolyList)
GENESISAPI gePolygeWorld_AddPolyOnce (geWorld *World, GE_LVertex *Verts, int32 NumVerts, geBitmap *Bitmap, gePoly_Type Type, uint32 RenderFlags, geFloat Scale)
GENESISAPI gePolygeWorld_AddPoly (geWorld *World, GE_LVertex *Verts, int32 NumVerts, geBitmap *Bitmap, gePoly_Type Type, uint32 RenderFlags, geFloat Scale)
GENESISAPI void geWorld_RemovePoly (geWorld *World, gePoly *Poly)
GENESISAPI geBoolean gePoly_GetLVertex (gePoly *Poly, int32 Index, GE_LVertex *LVert)
GENESISAPI geBoolean gePoly_SetLVertex (gePoly *Poly, int32 Index, const GE_LVertex *LVert)
geBoolean User_SetCameraInfo (geEngine *Engine, geWorld *World, geCamera *Camera, Frustum_Info *Fi)
geBoolean User_DestroyOncePolys (geWorld *World)
void User_DestroyPolyList (geWorld *World, gePoly *List)
void User_EngineFillRect (geEngine *Engine, const GE_Rect *Rect, const GE_RGBA *Color)


Define Documentation

#define MAX_USER_VERTS   4
 

Definition at line 42 of file USER.H.

Referenced by geWorld_AddPoly().

#define USER_MAX_SORTED_POLYS   1024
 

Definition at line 43 of file USER.H.

Referenced by User_RenderPolyList().


Typedef Documentation

typedef struct gePoly gePoly
 

typedef struct User_Info User_Info
 


Function Documentation

GENESISAPI geBoolean gePoly_GetLVertex gePoly Poly,
int32  Index,
GE_LVertex LVert
 

Definition at line 1070 of file User.c.

References GE_TRUE, geBoolean, GENESISAPI, NULL, and gePoly::Verts.

01071 {
01072         assert (Poly != NULL);
01073         assert(LVert != NULL);
01074         assert(geWorld_PolyIsValid(Poly));
01075 
01076         assert(Index >= 0);
01077         assert(Index < Poly->NumVerts);
01078 
01079         *LVert= Poly->Verts[Index];
01080 
01081         return GE_TRUE;
01082 }

GENESISAPI geBoolean gePoly_SetLVertex gePoly Poly,
int32  Index,
const GE_LVertex LVert
 

Definition at line 1087 of file User.c.

References GE_TRUE, geBoolean, GENESISAPI, geWorld_LinkPolyToLeaf(), geWorld_UnLinkPolyFromLeaf(), gePoly::LeafData, NULL, gePoly::Verts, and gePoly::World.

Referenced by Client_UpdateSinglePlayer().

01088 {
01089         assert (Poly != NULL);
01090         assert(LVert != NULL);
01091         assert(geWorld_PolyIsValid(Poly));
01092 
01093         assert(Index >= 0);
01094         assert(Index < Poly->NumVerts);
01095 
01096         Poly->Verts[Index] = *LVert;
01097 
01098         assert(Poly->LeafData);         // A poly does not get created UNLESS it gets attaches to a leaf!!!
01099 
01100         geWorld_UnLinkPolyFromLeaf(Poly);                       // Detach the poly from it's current leaf
01101         geWorld_LinkPolyToLeaf(Poly->World, Poly);      // Re-attach to the new leaf (if any, check for cohearency!)
01102         
01103         return GE_TRUE;
01104 }

GENESISAPI gePoly* geWorld_AddPoly geWorld World,
GE_LVertex Verts,
int32  NumVerts,
geBitmap Bitmap,
gePoly_Type  Type,
uint32  RenderFlags,
geFloat  Scale
 

Definition at line 968 of file User.c.

References geWorld::ActiveUserPolys, gePoly::AddOnceNext, gePoly::Bitmap, World_BSP::BSPData, geWorld::CurrentBSP, GE_GOURAUD_POLY, GE_RAM_ALLOCATE_STRUCT, GENESISAPI, geWorld_LinkPolyToLeaf(), GBSP_BSPData::GFXModels, gGFXModels, gePoly::LeafData, MAX_USER_VERTS, gePoly::Next, NULL, gePoly::NumVerts, gePoly::Prev, gePoly::RenderFlags, gePoly::Scale, gePoly::Type, geWorld::UserInfo, gePoly::Verts, and gePoly::World.

Referenced by CheckClientPlayerChanges(), and geWorld_AddPolyOnce().

00975 {
00976         gePoly          *Poly;
00977 
00978         assert(World != NULL);
00979         assert(World->UserInfo != NULL);
00980 
00981         assert(Bitmap != NULL || Type == GE_GOURAUD_POLY);
00982         assert(Verts != NULL);
00983         assert(NumVerts <= MAX_USER_VERTS);
00984         
00985         Poly = GE_RAM_ALLOCATE_STRUCT(gePoly);
00986 
00987         if (!Poly)
00988                 return NULL;
00989 
00990         if ( World->CurrentBSP )
00991                 gGFXModels = World->CurrentBSP->BSPData.GFXModels;
00992         else
00993                 gGFXModels = NULL;
00994 
00995 #ifdef _DEBUG
00996         Poly->Self1 = Poly;
00997         Poly->Self2 = Poly;
00998 #endif
00999 
01000         Poly->NumVerts = NumVerts;
01001         Poly->Bitmap = Bitmap;
01002         Poly->Type = Type;
01003         Poly->RenderFlags = RenderFlags;
01004         Poly->Scale = Scale;
01005         Poly->World = World;            // I could think of no other way!!!  Poly needs world in SetLVertex.  Should we require it as a parm???
01006         Poly->AddOnceNext = NULL;
01007         Poly->Next = NULL;
01008         Poly->Prev = NULL;
01009         Poly->LeafData = NULL;
01010 
01011         memcpy(Poly->Verts, Verts, sizeof(GE_LVertex)*NumVerts);
01012 
01013         // Link the poly to the leaf it is in
01014         geWorld_LinkPolyToLeaf(World, Poly);
01015 
01016         World->ActiveUserPolys++;
01017 
01018         return Poly;
01019 }

GENESISAPI gePoly* geWorld_AddPolyOnce geWorld World,
GE_LVertex Verts,
int32  NumVerts,
geBitmap Bitmap,
gePoly_Type  Type,
uint32  RenderFlags,
geFloat  Scale
 

Definition at line 1024 of file User.c.

References gePoly::AddOnceNext, User_Info::AddPolyOnceList, GENESISAPI, geWorld_AddPoly(), NULL, and geWorld::UserInfo.

Referenced by _Electric_BoltEffectRender(), ControlExplode1Anim(), ControlExplode2Anim(), ControlParticleAnim(), ControlShredderAnim(), ControlSmokeAnim(), Corona_Frame(), DoSplashScreen(), DrawFace(), DrawLine3d(), Electric_BoltEffectRender(), and PathPoint_Frame2().

01031 {
01032         gePoly          *Poly;
01033 
01034         assert(World != NULL);
01035         assert(World->UserInfo != NULL);
01036         
01037         // For AddPOlyOnce, do an AddPoly, then put it in the list to be removed at the end of the frame
01038         Poly = geWorld_AddPoly(World, Verts, NumVerts, Bitmap, Type, RenderFlags, Scale);
01039 
01040         if (!Poly)
01041                 return NULL;
01042 
01043         // Insert add poly once polys into the AddPolyOnceList so they can be removed at the end of the frame
01044         Poly->AddOnceNext = World->UserInfo->AddPolyOnceList;
01045         World->UserInfo->AddPolyOnceList = Poly;
01046 
01047         return Poly;
01048 }

GENESISAPI void geWorld_RemovePoly geWorld World,
gePoly Poly
 

Definition at line 1053 of file User.c.

References geWorld::ActiveUserPolys, GENESISAPI, geRam_Free, geWorld_UnLinkPolyFromLeaf(), and NULL.

Referenced by CheckClientPlayerChanges(), Client_DestroyPlayerWorldObjects(), UpdatePlayers(), User_DestroyPolyList(), and User_DestroyPolyOnceList().

01054 {
01055         assert(World != NULL);
01056         assert(Poly != NULL);
01057         assert(geWorld_PolyIsValid(Poly));
01058 
01059         // Remove the poly from the leaf that it is in (it must be in one. or it would not have been added to the world)
01060         geWorld_UnLinkPolyFromLeaf(Poly);
01061 
01062         World->ActiveUserPolys--;
01063 
01064         geRam_Free(Poly);
01065 }

geBoolean User_DestroyOncePolys geWorld World  ) 
 

Definition at line 308 of file User.c.

References User_Info::AddPolyOnceList, GE_TRUE, geBoolean, NULL, User_DestroyPolyOnceList(), and geWorld::UserInfo.

Referenced by World_WorldRenderQ().

00309 {
00310         if (World->UserInfo->AddPolyOnceList)
00311         {
00312                 User_DestroyPolyOnceList(World, World->UserInfo->AddPolyOnceList);
00313                 World->UserInfo->AddPolyOnceList = NULL;
00314         }
00315 
00316         return GE_TRUE;
00317 }

void User_DestroyPolyList geWorld World,
gePoly List
 

Definition at line 266 of file User.c.

References geWorld_RemovePoly(), List, and gePoly::Next.

Referenced by geWorld_Free().

00267 {
00268         gePoly  *Poly, *Next;
00269 
00270         // Clear out all the AddPolyOnce polys...
00271         for (Poly = List; Poly; Poly = Next)
00272         {
00273                 Next = Poly->Next;
00274 
00275                 assert(geWorld_PolyIsValid(Poly));
00276 
00277                 geWorld_RemovePoly(World, Poly);
00278         }
00279 }

void User_EngineFillRect geEngine Engine,
const GE_Rect Rect,
const GE_RGBA Color
 

Definition at line 779 of file User.c.

References GE_RGBA::a, DRV_TLVertex::a, GE_RGBA::b, DRV_TLVertex::b, GE_Rect::Bottom, geEngine::DriverInfo, DRV_RENDER_ALPHA, DRV_RENDER_FLUSH, Engine, GE_RGBA::g, DRV_TLVertex::g, geFloat, GE_Rect::Left, NULL, GE_RGBA::r, DRV_TLVertex::r, Sys_DriverInfo::RDriver, DRV_Driver::RenderGouraudPoly, GE_Rect::Right, GE_Rect::Top, DRV_TLVertex::u, DRV_TLVertex::v, DRV_TLVertex::x, DRV_TLVertex::y, and DRV_TLVertex::z.

Referenced by geEngine_FillRect().

00780 {
00781         DRV_TLVertex    DrvVertex[4];
00782         DRV_Driver *    RDriver;
00783 
00784         RDriver = Engine->DriverInfo.RDriver;
00785 
00786         assert(RDriver != NULL);
00787 // changed for RF
00788 #define NEARZ   1.0f
00789         DrvVertex[0].x = (geFloat)Rect->Left;
00790         DrvVertex[0].y = (geFloat)Rect->Top;
00791         DrvVertex[0].z = NEARZ;
00792         DrvVertex[0].u =
00793         DrvVertex[0].v = 0.0f;
00794         DrvVertex[0].r = Color->r;
00795         DrvVertex[0].g = Color->g;
00796         DrvVertex[0].b = Color->b;
00797         DrvVertex[0].a = Color->a;
00798 
00799         DrvVertex[1].x = (geFloat)Rect->Right;
00800         DrvVertex[1].y = (geFloat)Rect->Top;
00801         DrvVertex[1].z = NEARZ;
00802         DrvVertex[1].u =
00803         DrvVertex[1].v = 0.0f;
00804         DrvVertex[1].r = Color->r;
00805         DrvVertex[1].g = Color->g;
00806         DrvVertex[1].b = Color->b;
00807         DrvVertex[1].a = Color->a;
00808 
00809         DrvVertex[2].x = (geFloat)Rect->Right;
00810         DrvVertex[2].y = (geFloat)Rect->Bottom;
00811         DrvVertex[2].z = NEARZ;
00812         DrvVertex[2].u =
00813         DrvVertex[2].v = 0.0f;
00814         DrvVertex[2].r = Color->r;
00815         DrvVertex[2].g = Color->g;
00816         DrvVertex[2].b = Color->b;
00817         DrvVertex[2].a = Color->a;
00818 
00819         DrvVertex[3].x = (geFloat)Rect->Left;
00820         DrvVertex[3].y = (geFloat)Rect->Bottom;
00821         DrvVertex[3].z = NEARZ;
00822         DrvVertex[3].u =
00823         DrvVertex[3].v = 0.0f;
00824         DrvVertex[3].r = Color->r;
00825         DrvVertex[3].g = Color->g;
00826         DrvVertex[3].b = Color->b;
00827         DrvVertex[3].a = Color->a;
00828 
00829         if (Color->a != 255.0f)
00830                 RDriver->RenderGouraudPoly(DrvVertex, 4, DRV_RENDER_FLUSH);
00831         else
00832                 RDriver->RenderGouraudPoly(DrvVertex, 4, DRV_RENDER_ALPHA | DRV_RENDER_FLUSH);
00833 }

geBoolean User_EngineInit geEngine Engine  ) 
 

Definition at line 86 of file User.c.

References Engine, GE_ERR_OUT_OF_MEMORY, GE_FALSE, GE_RAM_ALLOCATE_STRUCT, GE_TRUE, geBoolean, geErrorLog_Add, NULL, and geEngine::UserInfo.

Referenced by Sys_EngineCreate().

00087 {
00088         User_Info               *Info;
00089 
00090         assert(Engine->UserInfo == NULL);
00091 
00092         Info = GE_RAM_ALLOCATE_STRUCT(User_Info);
00093 
00094         if (!Info)
00095         {
00096                 geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL);
00097                 return GE_FALSE;;
00098         }
00099 
00100         memset(Info, 0, sizeof(User_Info));
00101 
00102         Engine->UserInfo = Info;
00103 
00104         return GE_TRUE;
00105 }

void User_EngineShutdown geEngine Engine  ) 
 

Definition at line 110 of file User.c.

References Engine, geRam_Free, NULL, and geEngine::UserInfo.

Referenced by Sys_EngineFree().

00111 {
00112         User_Info                       *Info;
00113 
00114         assert(Engine != NULL);
00115 
00116         Info = Engine->UserInfo;
00117 
00118         if (!Info)
00119                 return;         // Nothing to do...
00120 
00121         geRam_Free(Info);
00122 
00123         Engine->UserInfo = NULL;
00124 }

geBoolean User_RenderPolyList gePoly PolyList  ) 
 

Definition at line 193 of file User.c.

References Dest, gCamera, GE_RENDER_DEPTH_SORT_BF, GE_TRUE, geBoolean, geCamera_Transform(), int32, gePoly::Next, PolyComp(), gePoly::RenderFlags, RenderUserPoly(), SortedPolys, USER_MAX_SORTED_POLYS, gePoly::Verts, GE_LVertex::X, geVec3d::X, GE_LVertex::Y, geVec3d::Y, GE_LVertex::Z, geVec3d::Z, and gePoly::ZOrder.

Referenced by GList_RenderOperations().

00194 {
00195         int32                   i, NumSortedPolys;
00196         gePoly                  *Poly;
00197 
00198         assert(PolyList);
00199 
00200         NumSortedPolys = 0;
00201 
00202         for (Poly = PolyList; Poly; Poly = Poly->Next)
00203         {
00204                 assert(geWorld_PolyIsValid(Poly));
00205 
00206                 if ((Poly->RenderFlags & GE_RENDER_DEPTH_SORT_BF) && NumSortedPolys < USER_MAX_SORTED_POLYS)
00207                 {
00208                         // Sorted polys (within this list) go in the SortedPoly list, and are sorted and drawn below
00209                         geVec3d         Src;
00210                         geVec3d         Dest;
00211 
00212                         Src.X = Poly->Verts->X;
00213                         Src.Y = Poly->Verts->Y;
00214                         Src.Z = Poly->Verts->Z;
00215 
00216                         geCamera_Transform(gCamera, &Src, &Dest);
00217                         Poly->ZOrder = Dest.Z;
00218 
00219                         SortedPolys[NumSortedPolys++] = Poly;
00220                         continue;
00221                 }
00222 
00223                 // If it is not a sorted poly, render it now...
00224                 RenderUserPoly(gCamera, Poly);
00225         }
00226 
00227         if (!NumSortedPolys)            // nothing more to do, if no sorted polys
00228                 return GE_TRUE;
00229 
00230         // Now render all sorted polys
00231         // Sort the polys
00232         qsort(&SortedPolys, NumSortedPolys, sizeof(SortedPolys[0]), PolyComp);
00233 
00234         // Render them
00235         for (i=0; i< NumSortedPolys; i++)
00236         {
00237                 Poly = SortedPolys[i];
00238 
00239                 RenderUserPoly(gCamera, Poly);
00240         }
00241 
00242         return GE_TRUE; 
00243 }

geBoolean User_SetCameraInfo geEngine Engine,
geWorld World,
geCamera Camera,
Frustum_Info Fi
 

Definition at line 284 of file User.c.

References Engine, Frustum_TransformToWorldSpace(), gBSP, gCamera, GE_TRUE, geBoolean, gEngine, gGFXLeafs, gGFXModels, gWorld, gWorldSpaceFrustum, NULL, and geWorld::UserInfo.

Referenced by RenderScene().

00285 {
00286         assert(Engine != NULL);
00287         assert(World != NULL);
00288         assert(World->UserInfo != NULL);
00289         assert(Camera != NULL);
00290         assert(Fi != NULL);
00291 
00292         gWorld = World;
00293         gEngine = Engine;
00294         gCamera = Camera;
00295         gBSP = World->CurrentBSP;
00296         gGFXLeafs = World->CurrentBSP->BSPData.GFXLeafs;
00297         gGFXModels = World->CurrentBSP->BSPData.GFXModels;
00298 
00299         // Make the frustum go to World/Model space
00300         Frustum_TransformToWorldSpace(Fi, Camera, &gWorldSpaceFrustum);
00301 
00302         return GE_TRUE; 
00303 }

geBoolean User_WorldInit geWorld World  ) 
 

Definition at line 129 of file User.c.

References GE_ERR_OUT_OF_MEMORY, GE_FALSE, GE_RAM_ALLOCATE_STRUCT, GE_TRUE, geBoolean, geErrorLog_Add, NULL, and geWorld::UserInfo.

Referenced by geWorld_Create().

00130 {
00131         User_Info                       *Info;
00132 
00133         assert(World != NULL);
00134 
00135         Info = GE_RAM_ALLOCATE_STRUCT(User_Info);
00136         
00137         assert(Info != NULL);
00138 
00139         if (!Info)
00140         {
00141                 geErrorLog_Add(GE_ERR_OUT_OF_MEMORY, NULL);
00142                 return GE_FALSE;
00143         }
00144 
00145         memset(Info, 0, sizeof(User_Info));
00146 
00147         World->UserInfo = Info;
00148 
00149         return GE_TRUE; 
00150 }

void User_WorldShutdown geWorld World  ) 
 

Definition at line 155 of file User.c.

References geRam_Free, NULL, and geWorld::UserInfo.

Referenced by geWorld_Free().

00156 {
00157         User_Info                       *Info;
00158 
00159         assert(World != NULL);
00160 
00161         Info = World->UserInfo;
00162 
00163         if (!Info)
00164                 return;         // Nothing to do...
00165 
00166         geRam_Free(Info);
00167 
00168         World->UserInfo = NULL;
00169 }


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