OpenGL Class Model structure for 3d object

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

Recommended Posts

I am in the process of making a 3d FPS game in C++/openGL. I am at the stage where I can load 3d models. I have already written a very basic importer which processes the famous collada dae format and it returns a list of triangles and polygon lists. Till now, it renders the model fine. My problem is, as the model grows larger, moving around becomes very slow. And, this is just one model that I am loading at a time. My question is: 1. How should I model a class which can represent this .dae object file? As of now, I just take the triangles and the list of polygons and put them between a glBegin() / glEnd() construct! 2. Any suggestions on how I can speed up ? Please let me know if I need to provide more details. I'd appreciate any help. Thanks (check out some of the screenies @ my blog )

Share on other sites
Assuming they're static models (non-animated), compiling a list should improve performance a bit.

Share on other sites
Yes, I'm taking one step at a time. I am just worried about static models for now.

My classes looks something like this:
class Model {public:list<Triangle*> GetTriangles();list<PrimPolygon*> GetPolygons();protected:list<Triangle*> m_Triangles;list<PrimPolygon*> m_Polygons;}class Vertex{boost::unordered_map<Semantic, float*> m_Attributes;}enum Semantic{   Position = 0,   Color = 1,   Normal = 2,   TexCoord = 3};class Triangle{protected:Vertex *m_V1, *m_V2, *m_V3;}class PrimPolygon{protected:   std::vector<Vertex*> m_Vertices;   size_t m_N;}

//I have ommitted get/set methods, but this is my overall structure

Share on other sites
Your Get functions return the lists by value, making an unnecessary copy. You should return a const reference instead:

const list<Triangle*> & GetTriangles();const list<PrimPolygon*> & GetPolygons();

Also, using VBOs should improve performance.

Share on other sites
Thanks Gage64,

I actually did that for returning polygons, but I wasn't sure if that would be a wise thing to do, because if I have to move the model around, they would be const and be problematic. But then, I think multiplying by transformation matrices should take care of that ?

Also, what do you suggest about my model class ? Should I organise it in a different manner or is it okay or do you have any recommendations for me ?

Thanks

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• Forum Statistics

• Total Topics
633661
• Total Posts
3013227
×