1

I have been working on my low level OpenGL understanding, and I've finally come to how to animate 3D models. Nowhere I look tells me how to do Skeletal animation. most things use some kind of 3D engine and just say "Load the Skeleton" or "Apply the Animation" but not how to load a skeleton, or how to actually move the vertices.

I'm assuming each bone has a 4x4 Matrix of the Translation/Rotation/Scale for the vertices its attached too that way when the bone is moved the vertices attached also move by the same amount.

for skeletal animation I was guessing that you would pass the Bone(s) to the shader, that way in the vertex shader I move the current vertex before it goes to the fragment shader. If I have a keyframed animation I send the current bone and the new bone to the shader along with the current time between frames and interpolate the points between bones based on how much time there is between keyframes.

Is this the correct way to animate a mesh? or is there a better way

Snowdrama
  • 405
  • 1
  • 6
  • 17
  • 2
    Almost correct, but each vertex usually influenced by multiple bones by some amount - like multiplier for each bone, and sum of multipliers equal to 1. It's more about how artists making it. Also, it may be good idea to limit bones to just rotations (no translate/scale) and use quaternions for smooth interpolation (but again, depends on actual data). – keltar Nov 18 '13 at 03:23
  • Makes sense, vertices around say an elbow would be affected by the upper and lower arm bones. My understanding is that's related to the "Weight" or some modifier of how much a vertex is effected by a specific bone. Obviously translate and scale would be only necessary in special cases where the animation required something like the model's arm to grow. Still have to fully learn Quaternions I've been studying them for a little less then week now. – Snowdrama Nov 18 '13 at 03:35

1 Answers1

3

Well - the method of animation depends on the format, and the data that's written in it. Some formats supply you in vectors, some use matrices. I gotta admit I came to this site to ask a similar question, but I've specified the format (was using *.x files, you can check the topic), and I got an answer.

You're idea of the subject is correct. If you want a sample implementation, you can find one on the OpenGL wiki.

Community
  • 1
  • 1
Paweł Stawarz
  • 3,952
  • 2
  • 17
  • 26
  • Ok That makes sense, just like textures, the format determines the stored data. I dont have a format yet, because I wasn't sure what I needed to export from blender yet. – Snowdrama Nov 18 '13 at 03:24
  • 1
    Check the links I gave in my post, they can help you. And about the format: There aren't too many open formats that can store skeletal animation. That's why I've used the *.x format. Blender can export to it for sure. – Paweł Stawarz Nov 18 '13 at 03:27