![]()
gePoly
Description: User poly's
Source file: ...\genesis3d\OpenSource\Source\World\USER.h
Functions:
EngineInit, EngineShutdown, WorldInit, WorldShutdown, RenderPolyList, AddPolyOnce, AddPoly, RemovePoly, GetLVertex, SetLVertex, SetCameraInfo, DestroyOncePolys, DestroyPolyList, EngineFillRect gePoly, User_Info, gePoly_TypeConstants:
viewSample Code
: viewChanges for Genesis3D v1.6
: types float changed to geFloat![]()
Types:
Note: this is from …\genesis3d\include\genesis.h
typedef enum {
GE_TEXTURED_POLY,
GE_GOURAUD_POLY,
GE_TEXTURED_POINT
} gePoly_Type;
![]()
#define MAX_USER_VERTS 4
#define USER_MAX_SORTED_POLYS 1024
Note: The following are defined in ...\genesis3d\include\genesis.h
// Poly Fx flags
#define GE_RENDER_DO_NOT_OCCLUDE_OTHERS (1<<0) // Poly will not occlude others
#define GE_RENDER_DO_NOT_OCCLUDE_SELF (1<<1) // Renders under any condition. Useful for halos, etc...
#define GE_RENDER_BACKFACED (1<<2) // Poly should be backfaced from the Camera's Pov
#define GE_RENDER_DEPTH_SORT_BF (1<<3) // Sorts relative to camera position, from back to front
#define GE_RENDER_CLAMP_UV (1<<4) // Clamp UV's in both directions
Return to Contents
![]()
Functions:
![]()
geBoolean User_EngineInit(geEngine* Engine);
This creates a new User_Info object, and attaches to Engine->User_Info. Note: Each call of this function should be matched with a call to User_EngineShutDown() to avoid memory leakage.
Return to Contents
![]()
This frees up and deletes Engine->User_Info object
Return to Contents
![]()
geBoolean User_WorldInit(geWorld* World);
This creates a new User_Info object, and attaches to World->User_Info
Return to Contents
![]()
This frees up and deletes World->User_Info object
Return to Contents
![]()
geBoolean User_RenderPolyList(gePoly* PolyList);
Renders all Poly's in the PolyList chain of gePoly's
Return to Contents
![]()
GENESISAPI gePoly* geWorld_AddPolyOnce( geWorld* World, GE_LVertex* Verts, int32 NumVerts, geBitmap* Bitmap, gePoly_Type Type, uint32 RenderFlags, float Scale);
Adds a user poly to be draw for 1 frame only (removed after one rendering).
For comments on argument required, see descriptions of variables in geWorld_AddPoly()
Note: in Genesis3D v1.6, Scale is of type geFloat
Returns
: pointer to gePoly addedReturn to Contents
![]()
GENESISAPI gePoly* geWorld_AddPoly( geWorld* World, GE_LVertex* Verts, int32 NumVerts, geBitmap* Bitmap, gePoly_Type Type, uint32 RenderFlags, float Scale);
Adds a user polygon to the world.
World
: a valid pointer to a geWorld. Note: World->UserInfo must not be NULL (i.e. User_WorldInit() must have been called a some point prior to this function). Note: The sample code (view) appears to call this function without a prior call to User_WorldInit()--and it works fine. But this function's code begins with: assert (World->UserInfo != NULL), so perhaps it is set elsewhere?.Returns
: pointer to gePoly addedNote: in Genesis3D v1.6, Scale is of type geFloat
Return to Contents
![]()
GENESISAPI void geWorld_RemovePoly(geWorld* World, gePoly* Poly);
Removes specified user Poly from World
Return to Contents
![]()
GENESISAPI geBoolean gePoly_GetLVertex(gePoly* Poly, int32 Index, GE_LVertex* LVert);
Copies Index'th GE_LVertex contained in Poly into structure pointed to by LVert, (i.e. *LVert= Poly->Verts[Index])
Return to Contents
![]()
GENESISAPI geBoolean gePoly_SetLVertex(gePoly* Poly, int32 Index, const GE_LVertex* LVert);
Sets Index'th GE_LVertex contained in Poly from structure pointed to by LVert, (i.e. Poly->Verts[Index] = *LVert)
Return to Contents
![]()
geBoolean User_SetCameraInfo(geEngine* Engine, geWorld* World, geCamera* Camera, Frustum_Info* Fi);
Purpose: Set the camera for use during rendering user polygons.
Engine
: A valid Engine pointerReturn to Contents
![]()
geBoolean User_DestroyOncePolys(geWorld* World);
Deletes all one-time polys. This should be done automatically at end of one frame rendering. This could be called early if needed.
Return to Contents
![]()
Deletes all polys in List, beginning with the gePoly pointed to by List
Return to Contents
![]()
Make a spolygon with 4 vertexs, as specified by Rect, filled with Color. RenderGouraudPoly() is then called with this polygon. Polygon doesn't appear to be persistent.
Question
: Is this function similar to geEngine_FillRect()?Return to Contents
![]()
The following code is from ...\genesis3d\OpenSource\drawbbox.c
Each call to DrawBoundBox() adds a box at a given position, with width of Max-Min. The box will exist for one rendering cycle.
/*
This file is provided as a debugging aid. It contains code for drawing an axial
aligned bounding box. You can use this code as you see fit.
*/
static void DrawFace(geWorld* World, const geVec3d** Verts)
{
GE_LVertex LVerts[4];
int i;
for (i = 0; i < 4; i++) {
LVerts[i].r = 40.0f;
LVerts[i].g = 40.0f;
LVerts[i].b = 80.0f + 20.0f * (geFloat)i;
LVerts[i].a = 128.0f;
LVerts[i].X = Verts[i]->X;
LVerts[i].Y = Verts[i]->Y;
LVerts[i].Z = Verts[i]->Z;
}
geWorld_AddPolyOnce(World, &LVerts[0], 4, NULL, GE_GOURAUD_POLY, GE_FX_TRANSPARENT, 1.0f);
}
void DrawBoundBox(geWorld* World, const geVec3d* Pos, const geVec3d* Min, const geVec3d* Max)
{
geFloat dx;
geFloat dy;
geFloat dz;
static geVec3d Verts[8];
static geVec3d* Faces[6][4] = {
{ &Verts[0], &Verts[1], &Verts[2], &Verts[3] }, //Top
{ &Verts[4], &Verts[5], &Verts[6], &Verts[7] }, //Bottom
{ &Verts[3], &Verts[2], &Verts[6], &Verts[7] }, //Side
{ &Verts[1], &Verts[0], &Verts[4], &Verts[5] }, //Side
{ &Verts[0], &Verts[3], &Verts[7], &Verts[4] }, //Front
{ &Verts[2], &Verts[1], &Verts[5], &Verts[6] }, //Back
};
int i;
for (i = 0; i < 8; i++)
geVec3d_Add(Pos, Min, &Verts[i]);
dx = Max->X - Min->X;
dy = Max->Y - Min->Y;
dz = Max->Z - Min->Z;
Verts[0].Y += dy;
Verts[3].Y += dy;
Verts[3].X += dx;
Verts[7].X += dx;
Verts[1].Y += dy;
Verts[1].Z += dz;
Verts[5].Z += dz;
Verts[6].Z += dz;
Verts[6].X += dx;
Verts[2].X += dx;
Verts[2].Y += dy;
Verts[2].Z += dz;
for (i = 0; i < 6; i++)
DrawFace(World, &Faces[i][0]);
}
Return to Contents
![]()