LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Abe_No_I on August 15, 2012, 09:31:04

Title: Beginner question: appropriate container for vertices and normal coordinates ?
Post by: Abe_No_I on August 15, 2012, 09:31:04
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
Title: Re: Beginner question: appropriate container for vertices and normal coordinates ?
Post by: abcdef on August 15, 2012, 10:48:18
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 :


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.