正对“骨头”准确地遇到一个模型对另一个模型附加的困难。我搜索了几个论坛,但没有结果。我看到很多人都问过同样的问题,但没有真正的结果,没有任何回应。发现线程:
https://gamedev.stackexchange.com/questions/21129/how-to-attach-two-xna-models-together
https://stackoverflow.com/questions/11391852/attach-model-xna
但我认为这是可能的。
这是我的代码示例,附有我的玩家手的“立方体”
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();
}
}