PDA

View Full Version : Beginner question: appropriate container for vertices and normal coordinates ?



abe_no_i
08-15-2012, 02:30 AM
Hallo everybody,

I am storing coordinates of a 3d model within 3 ArrayLists. One List for the vertices, 1 for the normals and one for the faces. It is working as long as there are not too many vertices in one 3d model. Trying to load a model consisting out of 12000 vertices for example causes trouble because I get an error indexoutofboundException or even a unknownsource exception when trying to get one element out of one list by using the get() method (for ArrayLists).
Isn't an ArrayList self-managing in "how much space is needed" for the 3d model ?

Or is the another "Container, Array, otherList,..." which is much better to store these coordinates when there are a lot of it?

Thanks, with kind regards
Alexander

Dark Photon
08-15-2012, 06:45 PM
I am storing coordinates of a 3d model within 3 ArrayLists. One List for the vertices, 1 for the normals and one for the faces. It is working as long as there are not too many vertices in one 3d model. Trying to load a model consisting out of 12000 vertices for example causes trouble because I get an error indexoutofboundException or even a unknownsource exception when trying to get one element out of one list by using the get() method (for ArrayLists).
Isn't an ArrayList self-managing in "how much space is needed" for the 3d model ?

Or is the another "Container, Array, otherList,..." which is much better to store these coordinates when there are a lot of it?

This is not really an OpenGL question. 12000 is not a lot of vertices. You probably want to ditch the container class you're using. You can flip over to using std::vector, or plain C++ array (e.g. new float foo[12000*3] ).

Down the road, you may want to interleave your vertex attribute arrays for performance/convenience, but fry your current fish first before even thinking about it.