PDA

View Full Version : Dynamic Object Storage Question



GoatNat
04-18-2001, 09:34 AM
Hello all,
I am currently working on a small object creation system (similar to a map editor i suppose) and i'm to the point where im ready to store created objects in a structure. I’m having an issue with the actual layout of this structure. I’ve tried a few different layouts, the Brush ->> Faces ->> Vertices but since in that structure each vertice is physically independent from the others I cant really do “shared” vertices for when I try to deform a vertice on my object that it will deform all faces that should be affected. So when I have a box object I will have 8 vertices and can pull and push each one. This is just one of the issues im facing right now, if anyone has had any prior experience with object/map/model creation and can lend me their $0.02 on this subject I’d really apretiate it, even moreso links and/or texts on this subject would GREAT!

Thank you!
Nat

Rob The Bloke
04-18-2001, 05:40 PM
sorry, this will be my £0.02 worth, not sure how much'll be left over when you convert currency....

my method, this is what I use to to skinned animation, hopefully you'll get the idea.

define classes that hold vertices, normals etc. These are then refernced by the faces as index numbers (ie a face may use vertices 7, 8 & 22 say... ). This should allow you to share vertices, however speed becomes a question. To draw stuff like this you'd need to use glBegin()/glEnd(). To get some extra drawing speed, you can't use display lists cos the data changes. Vertex arrays cant use shared data so your almost in a catch22.

The way I blag it is to use vertex arrays and the shared data. Each shared vertex, normal or whatever, has an array of indices that reference the positions in which that vertex is used in the openGL vertex array, each time the vertex is updated, the vertices in the vertex arrays are updated.


[This message has been edited by Rob The Bloke (edited 04-18-2001).]

Deiussum
04-19-2001, 04:39 AM
Rob,

I'm not quite sure what you mean by vertex arrays not being able to use shared vertices, but if you mean what I think, then you can use vertex arrays the way you are describing and use glDrawElements.

glDrawElements takes an array of indices into the vertex arrays exactly the way you are using them and you don't have to use glBegin/glEnd.

You do need to make sure that the indices for normals, texcoords, color, etc, all match up with the indices of the vertices, but that isn't really all that bad. The only thing that you'd have to do is if you want to assign the same vertex different tex coords (or normals, etc.) then you'd have to duplicate that vertex.

Sorry if this is something you already know and I missed the meaning of your post.