Recommended Posts

I'm back again to wreak havoc. This time, I have dipping my toes into Assimp - related goodness. Following a couple of tutorials on the web, I took the concepts and made my own static model class that uses an STL vector of vertex array objects for storing the mesh info. Now, using a simple .obj model file I can get PARTS of it to render to the screen, in experimenting I have tried GL_TRIANGLE_STRIP, GL_TRIANGLES and even turning off back face culling but the model is rendering....sporadically!

//bool Init(int numVertices,...) takes a number of vertices for the objectdata to hold
//and a variable number of arguments that should be passed in the format data, components
//where data is the pointer to the data and components represents the number of elems in each
//vertex, e.g 3 for a normal, 4 for a normalised vertex, x for number of bones etc
//so a call like Init(indices,30,vertices,3) creates an index buffer and uses the data in vertices
//and knows there are 30 vertices and 3 components in each vertex

This loop assumes that meshFace->mNumIndices == 3, which could cause problems if your mesh is not triangulated

You've written destructors for some of your classes, but no copy constructors or assignment operators. I almost freaked out when I saw standard containers being used to store ObjectDatas but then realised that you were actually storing pointer-to-ObjectDatas ;)http://www.drdobbs.c...three/184401400

Destructors delete/[]ing things that haven't been initialised. If ObjectData::Init is not called for some reason, bad things will happen when that object's destructor is called. I prefer one-step initialisation, but if that's not an option then be sure to initialise member pointers to nullptr in your constructors.
Edited July 25, 2012 by teutonicus

1

Share this post

Link to post

Share on other sites

Thank you so much for that! A true "schoolboy" error! That saved me a lot of time! As for assignment operators/copy constructors maybe i should write some but back them private, I don't want any inadvertent copying of reams of data.

As for initialisation I always do the meat in the init functions as I can return a bool if anything is wrong.