How attach a model with another model on a specific bone?
Posted
by
Mehdi Bugnard
on Game Development
See other posts from Game Development
or by Mehdi Bugnard
Published on 2012-12-18T12:13:35Z
Indexed on
2012/12/18
17:15 UTC
Read the original article
Hit count: 330
I meet a difficulty attached to a model to another model on a "bone" accurate. I searched several forums but no result. I saw that many people have asked the same question but no real result see no response. Thread found :
How to attach two XNA models together?
How can I attach a model to the bone of another model?
http://stackoverflow.com/questions/11391852/attach-model-xna
But I think it is possible.
Here is my code example attached a "cube" of the hand of my player
private void draw_itemActionAttached(Model modelInUse)
{
Matrix[] Model1TransfoMatrix = new Matrix[this.player.Model.Bones.Count];
this.player.Model.CopyAbsoluteBoneTransformsTo(Model1TransfoMatrix);
foreach (ModelMesh mesh in modelInUse.Meshes)
{
foreach (BasicEffect effect in mesh.Effects)
{
Matrix model2Transform = Matrix.CreateScale(1f) * Matrix.CreateFromYawPitchRoll(0, 0, 0);
effect.World = model2Transform * Model1TransfoMatrix[0]; //root bone index
effect.View = arcadia.camera.View;
effect.Projection = arcadia.camera.Projection;
}
mesh.Draw();
}
}
© Game Development or respective owner