Jump to content
  • Advertisement
Sign in to follow this  
mark_grocki

OpenGL Doing skeletal animation with VBOs and OpenGL matrices

This topic is 5007 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have code that properly loads an MS3D file and builds the skeletal animation matrices per bone... each vertex is assigned a bone ID. Using immediate mode, I just spin through each triangle and transform each vertex by its bone matrix... this is all done with my matrix code. This was in immeditate mode - I want to move to vertex arrays and Vertex Buffer Objects. I have the vertex array stuff working, I take my "base" set of vertices and transform them by the proper bone matrix, and then send that "transformed" array of verts to the glVertexPointer. Now, the way I understand VBOs, you can send the arrays to the video memory and then just bind them again when you need them to render. You don't have to send the vertices to the vidmem each time. That works fine for static stuff - what about skeanimated stuff? I'm trying to figure how I can use the OpenGL matrices to do this (which are probably faster than my matrix implementation)... maybe split my triangles by the bones that influence them, and use an index array to reference each set of triangles, but the problem is, some triangles have multiple bones (from each vertex) influencing them. So what's the proper solution? Do I need vertex programs for this? Do I need to create a new VBO every time I animate? Or should I just use VBO only for the static stuff? Vertex programs are way out of my scope right now, but any insight would be appreciated. I saw this in another post: "I personally wouldn't want to mess with Vertex Arrays and dynamic objects" "Why not? Each frame, or each time the object changes (is animated) you change the values in the vertex array and/or normal array. As long as you don't add or remove vertices, you can render the object the same way (glDrawElements or glDrawArrays) as your static objects." But this doesn't necessarily talk about VBOs. This means I can change an element in a vertex array without having to do glVertexPointer again? (this is assuming I'm not using CVA's) Thanks - Mark Grocki

Share this post


Link to post
Share on other sites
Advertisement
i dunno if this works, but if you want to use VBOs for skelanims, i think you have to use a vertex program that does the matrix stuff for any vertex of the model...but, i say it again, it's only a though :)

Share this post


Link to post
Share on other sites
I would either

a) do as you said and store in a dynamic VBO and in local memory, then map the array each frame and copy the transformed vertecies from the initial "inverted" position in local memory to the VBO.

b) What I personally did was set up a boneid VBO and send the bone matricies to the vertex program as constants each frame (using the boneid vbo to index into the constant matrix array I just passed), and use the vertex program to animate. The only overhead is copying the updated transformation matricies each frame, instead of computing new vertex positions each frame on the CPU.

Share this post


Link to post
Share on other sites
For static models, I use display lists, for animated models, I just do it in Immediate mode. I know that is probably the slowest way, but I haven't ran into any problems yet performance wise. As long as you are culling as much as you can object wise and not drawing anything heavy like an unoptimized terrain, I think Immediate mode is fast enough as long as you are only draing the animated models this way and the rest in VA/VBO's. But then, I haven't made anything overly complex yet either.

Share this post


Link to post
Share on other sites
Quote:
Original post by Firewalker
I would either

a) do as you said and store in a dynamic VBO and in local memory, then map the array each frame and copy the transformed vertecies from the initial "inverted" position in local memory to the VBO.

b) What I personally did was set up a boneid VBO and send the bone matricies to the vertex program as constants each frame (using the boneid vbo to index into the constant matrix array I just passed), and use the vertex program to animate. The only overhead is copying the updated transformation matricies each frame, instead of computing new vertex positions each frame on the CPU.


Ah, so I can setup an "arbitary" VBO to store some other non-vertex type of information? I think that's how I would do it if I even knew how to use VPs.

In your (a) solution, I guess I don't understand the point of using a VBO since it's changing every frame... isn't just passing a new glVertexPointer basically the same thing? They're both taking time to transfer to the video memory.

Thanks

Share this post


Link to post
Share on other sites
It can save you some transfer time, as in theory the gfx card could upload the data via DMA while its performing another operation, instead of on demand streaming via VA. At worse it'll be the same speed.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!