Jump to content
  • Advertisement
Sign in to follow this  
DarkZoulz

Attach mesh to bone?

This topic is 5394 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 all, I'm trying to attach a mesh containing a weapon to the hand bone of my skinned mesh hierarchy, but it doesn't seem to be working correctly. The weapon just kind of bops in place while the walk animation is played. What I do is, I find the frame for the hand that should be holding the weapon and then load a mesh containing the weapon and try to add it as a child to the frame. After that update my bones. Anyone have any ideas or know how to go about implementing this?

Share this post


Link to post
Share on other sites
Advertisement
What does bop mean? [lol]

Does the weapon move correctly, but it's position is way off? Or is it's position correct and it just doesn't move with the hand correctly?

First, if you are simply adding the gun as a child to the hand, you need to make sure the gun is already resting in the hand before you animate.

Say you have a matrix which puts the gun into the model's hand in the model's default pose, GunMatrix. So when the model's bones are not rotated at all, applying the GunMatrix as the world transform when rendering the gun should put the gun right into the model's hand.

Now, you also have HandMatrix which is the final matrix of the hand bone that you send to the shader, or that you update the hand's vertices with.

To place the gun in the hand as the model animates, simply set the world transform as GunMatrix * HandMatrix.

It would help a lot to know how your hierarchy is updated. If this doesn't work, please let us know if you're using the D3DX AnimationController, or if you have your own hierarchy system setup.

Share this post


Link to post
Share on other sites
Thanks for the reply! But I seem to have fixed it. =) Don't know exactly what was wrong, but it must have been something small and silly. Thanks anyway though!

Not using d3d9, btw.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!