• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0

Inverse Bine Pose

6 posts in this topic

Hi guys,

I'm having some problems implementing basic skeletal animation. I'm not concerned with skinning at the moment, just bone movements. I understand the concept, but am missing something.

I have a simple setup like this:


float4x4 transforms[2];

// root
matrixTranslation(&translation,&pose.joints[0].pos); // the pose's root joint position
matrixRotationQuaternion(&rotation,&pose.joints[0].q); // the pose's root joint orientation
matrixMultiply(&transforms[0],&rotation,&translation); // combine

// child
matrixTranslation(&translation,&pose.joints[1].pos); // the pose's child joint position
matrixRotationQuaternion(&rotation,&pose.joints[1].q); // the pose's child joint orientation
matrixMultiply(&temp,&rotation,&translation); // combine
matrixMultiply(&transforms[1],&temp,&transforms[0]); // incorporate parent's transformation
// then I would use the transforms I made to transform the actual vertices

I don't know where to take into account the inverse_bind_pose, or if I'm doing it right at all.


I also don't understand why there is a position/translation in the pose joint; when the parent joint is rotated doesn't that automatically change the child's position/translation since the imaginary bone between them is rigid ?

I can give more code and structs if needed.


edit: title should be Bind pose, not Bine

Edited by Endemoniada

Share this post

Link to post
Share on other sites

I also don't understand why there is a position/translation in the pose joint; when the parent joint is rotated doesn't that automatically change the child's position/translation since the imaginary bone between them is rigid ?


Not really sure what you mean here exactly, parent transforms affect child transforms, as youve done, where is this "pose joint" thats confusing you coming from?


Bones dont really exist, theyre just the space between a parent transform and a child transform, where each transform is a joint that affects the child joints below it.


Ex, an arm: shoulder joint <-> elbow joint <-> wrist joint, each "<->" would be a bone i guess

Edited by NumberXaero

Share this post

Link to post
Share on other sites

The way it works is like this: the animation stream will provide the location of each bone in parent-space, which is the space relative to the bone's parents. Then, you have to create a buffer of model-space transforms for each bone by transforming each bone by it's parent's model-space transform. Then, once you have model space transforms, you need to determine how the current model space transform differs from the original pose's model space transform for each bone. This difference is what you use to transform your verts.


In some (very) pseudo code:

bone[0] = root;
bone[1] = anim_stream[1];
bone[2] = anim_stream[2];
bone[n] = anim_stream[n];

model_space_bone[n] = model_space_bone[parent_of(n)] * bone[n]; 

// ok, so what can we tell from model_space_bone[n]?
// we know the original pose's model space transformation for bone[n]
// therefore model_space_bone[n] = D * bone_pose[n] where bone_pose[n] is the
// transform of the bone in it's original pose.
// this means the current model_space_bone[n] is actually just some 
// transformation (D) from the original model space position. We need to 
// find D, because that's what we'll use to transform our verts

// doing some matrix math: 

model_space_bone[n] * inv_bone_pose[n] = D * bone_pose[n] * inv_bone_pose[n];
D = model_space_bone[n] * inv_bone_pose[n]

bone_pose_space_bone[n] = D = model_space_bone[n] * inv_bone_pose[n]

// vertex transformation uses bone_pose_space_bone[n], as this transformation
// represents the transformation of that bone from it's original pose
// to the pose it's in currently

projected_vert = proj_mtx * view_mtx * model_mtx * bone_pose_space_bone[bone_idx] * vert_pos;

Share this post

Link to post
Share on other sites

First, you may want to review the subject in this article about animation using matrices.


Second, it's not clear where you're getting the translation/rotation data from which you're creating matrices.


That being said, the inverse bind pose is the matrix inverse of a bone's world transform, which you appear to be calculating for the child in your OP - IF the child's position and rotation are relative to it's parent.


[ninja'd by Samith - wink.png ]

Edited by Buckeye

Share this post

Link to post
Share on other sites

I guess I'll try to understand it after I actually get it to work.


This is what I'm working with (from Game Engine Architecture):

struct Joint {
 float4x4 inv_bind_pose; // matrix
 int parent;
struct Skeleton {
 int joint_count;
 Joint* joints;
struct JointPose {
 float4 rotation; // quaternion
 float3 translation;
struct SkeletonPose {
 int joint_count;
 JointPose* joints;
// it's already confusing because of the different joint types

1) Are the inv_bind_pose matrices relative to the root joint (which would have it's inv_bind_pose as identity) ?

2) Are the rotations and translations in the JointPose structs relative to their parents ?

3) How do I put it all together ?







Share this post

Link to post
Share on other sites

1) Its the transform of the joint at the time it was bound to the mesh, inverted. World coordinates.
2) Yes
3) ....

I use world/local terminology (local = parent relative, world = global = model)

A) Using the joint local  transforms, compute each joints world transform,  childJointWorld = parentJointWorld * childJointLocal
-> Convert to matrices first, or use quaternions/vector3 then convert, your choice, in the end youll need a world matrix to combine with the jointInvBindPose matrix

QWorld = QParentWorld * QLocal    // rotate part
TWorld = TParentWorld + (QParentWorld * (SParentWorld * TLocal)   // translate part
SWorld = SParentWorld * SLocal   // scale part

-> If a joint has no parent, world = local

B) Now you have all joint world transforms, lets call this next one jointSkinMatrix = jointWorld * jointInvBindPose
C) The model probably has skin matrix / bind matrix / bind shape matrix, whatever its called this gets applied to all the original vertices, so you can do this once and store the modified model


Long version....

vec3 skinnedVertex = vec3(0, 0, 0)
For Each Vertex v
    For Each Joint Affecting Vertex v
        skinnedVertex += ((jointWorld * jointInvBindPose) * (bindShapeMatrix * v)) * jointWeight


Again, some of this depends on matrices or quaternion use, compute on gpu or cpu, but thats the general idea. Normals, same thing, but wouldnt be translated, and would have to be normalized for correct lighting.

Edited by NumberXaero

Share this post

Link to post
Share on other sites

Hey guys,

After reading your posts, going over Buckeye's article (which I'll have to get back to since it's more advanced than what I want right now), and reading a paper by Frank Luna, I was able to get it working.

I wanted to get a simple system up and running before using an importer/exporter. I load a model (.obj) that looks like three bones and create the joints by hand.

Everything seems to be fine, I can setup my bind pose structures, then put it in any other pose I like (by rotating the individual joints.)

I'm doing it like this:


 Ci = Li * Pi

where C is the combined matrix, L is the local matrix, and P is the parent's local matrix

then I finalize them:


 Fi = Oi * Ci

where F is the final matrix, O is the offset matrix, and C is computed above.

For the offset matrix I use the inverse_bind_matrix. Are those normally the same thing ?

There is something that is nagging me. I don't understand why I would need translations in each pose, if I'm not using scaling it seems I can set them up along with the inverse_bind_pose in the skeleton since they will never change. Maybe I'm missing something ?


Thanks a lot.



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 0