How to attach two XNA models together?
- by jeangil
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();
}