Use of VBO's with frame animation MD2's/MD3's (etc) = benefits?

Moderator
Posts: 1,140
Joined: 2005.07
Post: #16
What you're going to have to do is re-organize the vertices (with the normals, texture coordinates, etc.) so they will all fit with the same array. The way I did it with my obj loader (before I save in my own format) is to essentially get the indices and insert the raw vertex into a tree. (with the sum of all the values being the compare key) If it encounters the same vertex, it just returns the index that was there, otherwise it returns the new index. After every vertex is entered, I then fill a set of arrays with the vertex arrays in the order that I inserted them. (determined by the index I store in them) Since I implemented this using an AVL tree, it's decently fast (< 1 second with a model that has around 23,000 polygons in a debug build), and produces an optimum result for use with OpenGL.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #17
akb825 Wrote:(with the sum of all the values being the compare key)

You mean you allow more than one vertex with the same key?

What I've done in the past for OBJs is use a 64-bit integer, with each of the 3 original indices occupying 21 bits, so that every v/vt/vn triple produces a unique key.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #18
It's possible that they have the same key, but I do the final equality testing by each component. If they are equal, but not "truly" equal, I default to left.

Edit: I now see where this can possibly break down, though... when I rotate nodes to balance the tree, what was once on the left is now on the right. However, the sum is a float where I check with == (since I always calculate the exact same way, so if they had the exact same numbers to begin with, they'd have the exact same end value), so the probability of that is very low. I do have a couple dozen cases where that happens in a model I have with 23000 or so polygons, so I'll probably change this...
Quote this message in a reply
Jones
Unregistered
 
Post: #19
I think I understand your method. I meant something of the like when I said 'shift things around so they line up'. My statement was vague because I wasn't entirely sure how to yet.

I *have* tried simply stacking the texture coordinates in a 3D array with a stride of 4bytes (1 float), but it still looks messed up (just in a different fashion).

What I'm wondering is... how can this model (test model) have like... 300 vertices and 2037 texture coordinates. Annoyed

It's just... way to out of proportion.

EDIT: I have realized something lately...

It was completely and utterly ******** to write a completely unique class (handles everything differently) for each model type I want to load. Annoyed
Quote this message in a reply
Jones
Unregistered
 
Post: #20
Quick Question:

How likely is it that system the game will run on (Mac OS X and Windows) will support the GL_ARB_vertex_buffer_object extension and glDrawRangeElementsEXT? I can make do with glDrawElements, and I'm pretty sure that the EXT range command is reasonably common. Not sure about VBO's though.
Quote this message in a reply
Moderator
Posts: 1,140
Joined: 2005.07
Post: #21
I'm fairly sure that every context will support GL_EXT_draw_range_elements. According to arekkusu's OpenGL profile page, all cards since the Radeon 7200 support GL_ARB_vertex_buffer_object.
Quote this message in a reply
Jones
Unregistered
 
Post: #22
akb825 Wrote:I'm fairly sure that every context will support GL_EXT_draw_range_elements. According to arekkusu's OpenGL profile page, all cards since the Radeon 7200 support GL_ARB_vertex_buffer_object.

That's good news, thanks.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Unbinding VBO's Bersaelor 2 4,102 Aug 2, 2010 08:29 AM
Last Post: Bersaelor
  N-Body with GLSL and VBO's (how to approach)? mcMike 4 5,702 May 24, 2008 11:06 AM
Last Post: mcMike
  help about VBO's bonanza 5 3,497 Sep 6, 2007 10:57 PM
Last Post: bonanza