format layout

This is a discussion on format layout within the Game Programming forums, part of the General Programming Boards category; I've got a basic setup like this: model class, each model has: a 'heap' of vertices a 'heap' of triangles ...

  1. #1
    Shadow12345
    Guest

    format layout

    I've got a basic setup like this:

    model class, each model has:
    a 'heap' of vertices
    a 'heap' of triangles
    a 'heap' of meshes
    and a 'heap' of materials

    each mesh stores indices into the heap of materials and triangles
    each triangle stores indices into the heap of vertices. This seems to be a pretty good way to store a model if you don't intend on using triangle strips of some variant to draw models (which I'm not). I was wondering if 'you people' think it would be too costly to instead of having indexes into the different 'heaps' if i should just copy the appropriate values themselves into the data structures and separating the large heaps of data into smaller heaps of data specific to each mesh and triangle. This will mean more memory will be used in the process but it seems it will make things a bit simpler.

    Well post your thoughts. I'll probably implement skeletal animations before I make my final decision, I'm just throwing this out there to maybe see what to expect.

    thanks

    EDIT: Just to make things clear I am biased towards copying the same values into each individual structure instead of keeping the large heap. for example instead of having a triangle that indexes to vertices 1, 2, and 3, while having another triangle that indexes to triangles 2, 3, and 4 of the smae heap I would rather just copy 1, 2, and 3 to the first triangle and then copy 2, 3, and 4 to the other triangle. This means it would use 33% more memory but it would simplifiy things. Now that I think about it I might jsut try to find an effective way of just doing triangle strips, but I don't want to make things too difficult before I even get a chance to make anything. poly I expect you to reply to this post
    Last edited by Shadow12345; 12-31-2002 at 03:13 PM.

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,267
    depends on what your goals are?

    ease of use, or memory usage.

    if you are learning on a complex format use the easy route and don't get bogged down on the memory.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    If you're just getting started, then be simple about it. The simple solution is usually the best, anyways.

    If you don't want to do skeletal animation or anything it's just realy quick.

    All you want is an array of vertices and an array of triangles -- where each vertex is a class with an x, y, and z coordinate and each triangle is a class with the INDICES of three vertices. You say you want to copy the vertex data to each triangle because it's "easier," but it's really just as simple (if not, more simple) to just use an index and you'll save yourself the trouble of having to go back later and changing everything to indices (because it's really pretty important that you do so, 1/3 the memory usage for triangles is pretty big and you get the added efect of being able to translate a vertex in the array and therefor changing the associated vertex in all the triangles. Besides, if you don't index the vertices from within the triangle, then there's really no sense at all in keeping an array of vertices in memory in the first place.

    That's all you really need to get started. Don't bother with texture mapping or anything at first, those can be easily added later on.
    Last edited by Polymorphic OOP; 01-02-2003 at 08:32 AM.

  4. #4
    Shadow12345
    Guest
    All you want is an array of vertices and an array of triangles -- where each vertex is a class with an x, y, and z coordinate and each triangle is a class with the INDICES of three vertices. You say you want to copy the vertex data to each triangle because it's "easier," but it's really just as simple (if not, more simple) to just use an index and you'll save yourself the trouble of having to go back later and changing everything to indices (because it's really pretty important that you do so, 1/3 the memory usage for triangles is pretty big and you get the added efect of being able to translate a vertex in the array and therefor changing the associated vertex in all the triangles. Besides, if you don't index the vertices from within the triangle, then there's really no sense at all in keeping an array of vertices in memory in the first place.
    I agree totally, it's pointless to copy the same vertices to specific triangles when you can easily just index into the vertex array. In fact this entire model loading routine consists of hierarchies of data structures indexing in to other data structures. I've already got the loading portion working (spent an hour at least debugging and making sure it loads correctly, did this by writing data items to disk over and over and checking and double checking). It gets kind of confusing but I've also finished writing the drawing routine (everything I've done is similar to tutorials, but honest to goodness I didn't copy anything, I took a lot of notes determining what should be done, and how, and I wrote everything on my own from my notes). This is how the drawing routine works, and this is where it gets somewhat confusing (for me) and will only get more confusing when I add texturing (which isn't all that hard in opengl) and animations (which will probably suck ass).

    Draw():
    Loop through each mesh of the model
    -Loop through each triangle of the current mesh of the model
    -Loop through each vertex of the current triangle of the current mesh

    Do you want me to send the executable as soon as I've got it drawing a wireframe properly, or do you want me to hold off until I have texturing?

  5. #5
    Shadow12345
    Guest
    This is what I have so far, I added a background bitmap for no particular reason. It loads a static (non animated) model applying texture. It uses indices into arrays to access what it needs.

    EDIT: i had to take out the background texture because cprog won't let me upload stuff over 195KB
    Attached Files Attached Files
    Last edited by Shadow12345; 01-03-2003 at 12:42 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. GradeInfo
    By kirksson in forum C Programming
    Replies: 23
    Last Post: 07-16-2008, 04:27 PM
  2. function returning hour in either 12 or 24 hour format
    By stanlvw in forum C Programming
    Replies: 4
    Last Post: 01-01-2008, 06:02 AM
  3. Compression/Decompression Wave File and MP3
    By cindy_16051988 in forum Projects and Job Recruitment
    Replies: 51
    Last Post: 04-29-2006, 07:25 AM
  4. Seeking Format Advice
    By PsychoBrat in forum Game Programming
    Replies: 3
    Last Post: 10-05-2005, 06:41 AM
  5. Can't Format C
    By caroundw5h in forum Tech Board
    Replies: 40
    Last Post: 04-26-2004, 10:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21