Beginner question: appropriate container for vertices and normal coordinates ?

Started by Abe_No_I, August 15, 2012, 09:31:04

Previous topic - Next topic

Abe_No_I

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

abcdef

Alexander

I saw you posted in the opengl forums too (you might struggle with asking java questions there and strictly speaking asking java questions here is probably the wrong place but I'll try and help). Its hard to answer your question as there isn't enough information. You should post :


  • Some code showing what you are doing
  • The stack trace of the error
  • More details of what exatly you are storing in the ArrayList (floats, Vectors etc)

You are correct when you say java self manages arraylists. The error you are getting is normally caused when you are trying to get something at an index that doesn't exist. So you check your array size and index number to make sure everything is valid. Also you should remember that indexes start at 0 so if its only happening when you get the last one you know where your issue is.