How to implement joints and bones in openGL?

Now I am launching my own openGL infrastructure and know how to draw 3d objects ... etc.

But how do you define the relationships between 3d objects that a joint can have? Or how do you define a 3D object as a "bone"? Are there any good resources?

+8
opengl
source share
2 answers

But how do you define the relationships between 3d objects that a joint can have?

OpenGL does not care about these things. I have a clean API. Thus, you must unleash your creativity and determine such structures yourself. The usual approach to skeletal animation has a bone / rig system, where each bone has an orientation (represented by a quaternion or 3 × 3 matrix) and a list of bones attached to it further, that is, some kind of tree.

I would define this structure as

typedef float quaternion[4]; struct Bone { quaternion orientation; float length; int n_subbones; Bone *subbones; }; 

In addition to this, you need the core from which the drilling rig begins. I would do it like this:

 typedef float vec3[3]; struct GeomObjectBase { vec3 position; quaternion orientation; }; struct BoneRig { struct GeomObjectBase gob; struct Bone pivot_bone; } 

Then you will need some functions that iterate through this structure, generate a matrix palette from it so that it can be applied to the model grid.

Note: I use freeglut

Completely irrelevant

+7
source share

Since OpenGL is just a graphics library, not a three-dimensional modeling model, the task of defining and using "bones" falls on you.

There are various ways to implement it, but the general idea is this:

You treat every part of your model as a bone (for example, head, trunk, lower legs, upper legs, etc.).
Each bone has a parent to which it is connected (for example, the parent of the left lower leg is the upper left leg).
Thus, each bone has children.

enter image description here

Now you define each bone position as a relative position to the parent bone. When displaying a bone, you now multiply its relative position with the relative position of the parent bone to get the absolute position.

To visualize:
Think of it as a doll. When you take the doll’s hand and move it, the relative position (and rotation) of the hand will not change. His absolute position will change because you have moved one of your parents.

When I tried skeletal animations, I learned most of this link: http://content.gpwiki.org/index.php/OpenGL:Tutorials:Basic_Bones_System

+9
source share

All Articles