Jump to content
  • Advertisement
Sign in to follow this  

Skeletal Animation - Visualizing a Bone

This topic is 4484 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

Hello everyone! For almost two months I've been trying to solve a small problem. So the situation is this, I have a hierarchy of "joints", each of them representing a local coordinate system, relative to one another (see Figure 1). Every joint has a final (global) and a relative (local) transformation matrices. The line between two joints represents a "bone" (Figure 1 - d). I need to visualize a bone using a 3-D object (for example a box (Figure 2)). The bone object needs to be positionned between the parent and child joints with correct rotation angle (Figure 3). The question is, how can I calculate the transformation matrix for the bone object with the data given? Any ideas are welcome! Thanks in advance! Scheme

Share this post

Link to post
Share on other sites
Here's something that I'm using. Granted, I don't have actual bone objects, but for each joint, I simply have a pointer to the parent and a list of children, and the bones are drawn between them.

This was given to me by a guy named "someusername." If you're out there, thanks.

void drawBone( const util::CVector3d& p1, const util::CVector3d& p2, float radius,
const video::CColor& c = video::CColor(0.0f,0.0f,0.0f), float width=1.0f ) const
m_boneDraw.generatePoints(p1.distanceBetween(p2), width, radius);

util::CVector3d localZ( p2 - p1 );
localZ.normalize(); // the direction from the start point to end point

// assuming that the up vector for the world is (0,1,0)
util::CVector3d localX;
localX = localZ.crossProduct( util::CVector3d(0,1,0) );

// find the local y axis
util::CVector3d localY;
localY = localX.crossProduct( localZ );

// create the matrix
// http://www.gamedev.net/community/forums/viewreply.asp?ID=2391549
util::CMatrix m;

// normalize, just in case

m(0,0) = localX.x; m(1,0) = localY.x; m(2,0) = localZ.x;
m(0,1) = localX.y; m(1,1) = localY.y; m(2,1) = localZ.y;
m(0,2) = localX.z; m(1,2) = localY.z; m(2,2) = localZ.z;

m(3,0) = p1.x; m(3,1) = p1.y; m(3,2) = p1.z;

// transform so we have the right rotation, etc
m_sceneManager->getVideoDriver()->transform(video::WORLD_MATRIX, m);

// draw the bone
m_boneDraw.render(m_sceneManager, c);

// done with drawing bone

It does use all my object types, but it shouldn't really be that hard to figure out.

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!