I asked a bit on IRC about my problem, but I will broaden it up here.

(OpenGL 4.x)

My current problem: I have a 3D model with an armature (skeleton) that has a few bones. Each bone has a different weight on all vertexes. What is the best way of rendering the model with the bone system?

I have each bone's matrix (for translation/scale/rot) per frame available, plus the weight of each bone on each vertex. How should this data be used? How should I package the bone weight for all bones affecting it and send it to the shaders?

<edit>

I am doing this to learn about OpenGL. Therefore, all models, shaders, and math is done on my own. I currently can render static models. The think that I am completely stuck on is how do I get the matrices for, say, 2 bones affecting a vertex and their weights to a shader? Do I send them all at once to the GPU and have it calculate everything? If I know that, I can play around with it until I get it working (probably). The other thing to think about is pose animation where I blend multiple animations (not important for now, just need any animation for a start).
I've found the OpenGL Step by Step guide which is exceedingly useful, but I'm in way over my head with matrix maths. I know how to technically perform matrix operations, but I don't really understand why it works, which is what I really need to know to use it effectively.

Anyways, the OGLSbS guide on skeletal animation is here: http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html
Hopefully you'll be able to wrestle more understanding out of it than I can.
There's 2 ways I know of that you can do this. Since you're using OpenGL 4.x, the best way would probably be to organize your vertices into structs containing the position, normals, texcoords, weights, and bone indices for each vertex and writing a shader program.
Here's a good example on the OpenGL wiki

If you're wanting to be compatible with older versions of OpenGL, you can just use glTranslate / glRotate / glScale functions, read the transformation matrix into a buffer with glGetMatrix, and multiply the matrix with the position of each vertex.

Cycling through and multiplying the matrices for each individual vertex would be slow though, the best approach would be to organize your vertices into groups that are skinned to the same bones, pre-multiplying the matrices for those bones, and then just multiplying those matrices by your vertex weights and positions.
Hi.

This is something i've got to tackle soon. What i think you do, is choose in advance how many bones max can affect a vertex. Then this becomes a constant in calculating your weights which wind up in another matrix to be multiplied in the vertex shader.
@hugh9860: I literally just picked this project up again. Smile

I am using the MD5 format for storing mesh, bone, and animation data. I haven't gone on from there yet as I am fighting multiple vector math libraries being used.

Max bones, ok, not hard. I will edit this post with more info once MD5 loading is done on my side. I will probably be very confused as I have not touched animated anything really, nor GLSL too much.
What do you think of the MD5 format. I ended up using .obj format then extending it as i needed to. As you know, obj doesnt have any animation or skinning capability.

So my extensions were basically to handing better materials, but now i'm at the stage where i need to add animation. My choices are, either to stick with "extended obj" or jump ship to something like md5.

what are you doing about tools and exporters. i couldnt find any handy source code libraries for MD5.

so, anyway, first i have to tackle storing the usual animation stuff; position, rotation and scale. Then i have to tackle skinning. One other thing i was wondering; back in the day, skinning was just a vertex problem. im wondering if now there's a fragment shader part as well.

not looked into this yet.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement