• Advertisement
Sign in to follow this  

Attach mesh to bone

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

I couldn't find anything on google that is related to the subject of attaching a mesh (e.g a sword) to a bone when doing skeletal animation.

 

What's the popular term of this subject? Is there a good guide you can link me to?

Share this post


Link to post
Share on other sites
Advertisement

What do you mean? Like, how to go about creating a framework for skeletal animation? Are you using your own engine and mesh/animation format?

Share this post


Link to post
Share on other sites

Attachment is simply get the world transform of the bone or just a point which is in the skeleton and set your mesh based on it.

You have to param position offset and rotation offset to have it correct visually.

Edited by Alundra

Share this post


Link to post
Share on other sites

What do you mean? Like, how to go about creating a framework for skeletal animation? Are you using your own engine and mesh/animation format?

I created a framework for skeletal animation, I just haven't implemented "mesh attaching" yet. I'm asking about that.

I use COLLADA animated models made by people on the net.

Share this post


Link to post
Share on other sites

Attachment is simply get the world transform of the bone or just a point which is in the skeleton and set your mesh based on it.

You have to param position offset and rotation offset to have it correct visually.

You mean I have to manually add these offsets, based on eye?

 

Every SceneNode in my system may have a Bone object attached to it.

Each bone has its "finalMatrix" which is boneOffsetMatrix * boneToRootMatrix. (boneToRootMatrix is the multiplications of boneAnimationMatrix * boneParent->boneAnimationMatrix to the top of the hierarchy)

When I try to draw a small sphere with an arbitrary bone's finalMatrix I get the wrong position.

Here's an example of what I do:

SceneNode *wrist = rootNode->findFirstNode("wrist_jnt_rt"); //right wrist node
Bone *wristBone = wrist->bone();

shaderProgram->setUniform("ProjectionMatrix", perspectiveProjectionMatrix);
shaderProgram->setUniform("CameraMatrix", CameraMatrix);
shaderProgram->setUniform("ModelMatrix",wristBone->finalMatrix);

RenderSphere sph( Sphere(glm::vec3(0,0,0), 1.f) );
sph.draw();

glutSwapBuffers();

The sphere is drawn in the wrong place. It also doesn't rotate the same as the right wrist.

Edited by Pilpel

Share this post


Link to post
Share on other sites
You mean I have to manually add these offsets, based on eye?

Yes.

 

When I try to draw a small sphere with an arbitrary bone's finalMatrix I get the wrong position.

Maybe you are not in the same space, you have to use the bone world position + the position of the scene node unless your bone matrix is already in the good space.

Edited by Alundra

Share this post


Link to post
Share on other sites

I found the solution. The correct matrix is

shaderProgram->setUniform("ModelMatrix", modelTransformationMatrix * wristBone->nodeMatrixToRoot);
 

 

You mean I have to manually add these offsets, based on eye?

Yes.

 

Any helper tools that may help me with this? I don't want to have to build my app 100 times just to adjust a mesh.

Share this post


Link to post
Share on other sites

If you have an editor or bind key to move in-game to see the result you can adjust visually directly to have the good value, if not, you have no choice.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement