Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: Beginner question: appropriate container for vertices and normal coordinates ?

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2012
    Posts
    4

    Beginner question: appropriate container for vertices and normal coordinates ?

    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

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,190
    Quote Originally Posted by abe_no_i View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •