Skip to main content
gamedev.net
🔒 Locked

Comments on class structure....

Started by RealityMonster 1 reply 300+ views
Original Post
RealityMonster
RealityMonster
Im making an OGL app. Halfway through the coding (OOP Style), I realised my class structure was not up to it. It went like this.. Scene | This is toplevel and has 6 SceneObjects(for |FLOOR,WALL,SHELF,TABLE,LIGHT...). Handles rendering and | colision detection,world loading,texture loading etc.. SceneObject |This contains a growable vector of ScenePrimitives. | ScenePrimitive |array of 4 SceneVertices .basically a QUAD. also sector ID SceneVertex |vertex info u,v etc The problem is some of the objects are quads and some are milkshape models. I wanted to handle everything uniformly hence the above strucure. However its not very responsive to change and i find myself hacking it too often. Hence am planning to change it. (Thank god for OOP. Wouldnt hv been possible otherwise The new one goes like this. SceneNormalPrimitive Topclass for objects like a floor,roof which are just QUADs SceneModelPrimitive Topclass for objects which are models eg:SHELF Scene Controls the whole thing CFloor Croom etc derived from SceneNormalPrimitive CFloorManager etc for holding a vector of CFloor''s similarly for models Am thinking of delegating loading and rendering to the individual classes CFloor etc Pls comment!Thanks.
RealityMonster
RealityMonster
pleez help. im sure a lot of you are into OOP? and game data structure design seems to be such an important thing!
zedzeek
zedzeek
basically i believe u should have just the one structure that can handle everything
follow the KISS rule.

eg heres what i use (it can handle any sort of mesh quads,milkshake models (cant say that ive use them though )
of course theres gonna be a bit of redundant data but it can handle everything. which is most important. KISS

struct MeshFrame
{
VECTOR *verts, *norms;
COLOUR4 *colours;
};

struct Mesh
{
Mesh operator=(Mesh &pMesh);
char mesh_name[64];
MeshFrame *frames;

VECTOR *lerpedVerts, *lerpedNorms;
TEXCOORD *tex_coords, *tex_coords2;

TRIANGLE_GROUP *triangle_groups;
int num_triangle_groups;

int num_vertices, num_triangles, num_frames;

Shader *shader;
bool use_shader;
void draw_LerpedMesh_NO_Shader ( UINT32 prevframe, UINT32 currframe, float frac);

void draw_Mesh_with_Shader ( int meshID, Shader *shader );
void draw_MultiTexturedMesh_with_Shader ( int meshID, Shader *shader, UINT32 frame );

void draw_SOLID_mesh_Cy_Nn_T1y_T2n_SHADn_array ( int meshID, Shader *shader, UINT32 frame );
void draw_SOLID_mesh_Cy_Nn_T1y_T2y_SHADn_array ( int skin1num, int skin2num, Shader *shader, UINT32 frame );

};

struct TRIANGLE_GROUP
{
TRIANGLE_GROUP() { indices=NULL; }
~TRIANGLE_GROUP() { if (indices) delete []indices; }

int primative_type; // GL_TRIANGLES , GL_TRIANGLE_STRIP
int num_indices;
unsigned int *indices;
};

http://members.xoom.com/myBollux

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.