Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

RealityMonster

Comments on class structure....

This topic is 6516 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!