How to attach two XNA models together?
Posted
by
jeangil
on Game Development
See other posts from Game Development
or by jeangil
Published on 2011-12-15T14:52:02Z
Indexed on
2012/09/12
15:52 UTC
Read the original article
Hit count: 284
I go back on unsolved question I asked about attaching two models together, could you give me some help on this ?
For example, If I want to attach together Model1 (= Main model) & Model2 ? I have to get the transformation matrix of Model1 and after get the Bone index on Model1 where I want to attach Model2 and then apply some transformation to attach Model2 to Model1
I wrote some code below about this, but It does not work at all !! (6th line of my code seems to be wrong !?)
Model1TransfoMatrix=New Matrix[Model1.Bones.Count];
Index=Model1.bone[x].Index;
foreach (ModelMesh mesh in Model2.Meshes)
{
foreach(BasicEffect effect in mesh.effects)
{
matrix model2Transform = Matrix.CreateScale(0.1.0f)*Matrix.CreateFromYawPitchRoll(x,y,z);
effect.World= model2Transform *Model1TransfoMatrix[Index];
effect.view = camera.View;
effect.Projection= camera.Projection;
}
mesh.draw();
}
© Game Development or respective owner