我在尝试串联移动简单模型时遇到问题。我有 20 个较小的模型连接到一个较大的模型。它本质上是一个带有多个外部大炮的飞碟。我见过其他问题,比如这个,看起来几乎是我想要的。但是,这只会创建绘图转换。我实际上需要在 3d 空间中移动子模型,因为它们可以被独立破坏,因此需要碰撞检测。这是我旋转父级的方式(在 Update() 函数中):
angle += 0.15f;
RotationMatrix = Matrix.CreateRotationX(MathHelper.PiOver2) * Matrix.CreateRotationZ(MathHelper.ToRadians(angle) * MathHelper.PiOver2);
我已经尝试了很多解决方案,但定位总是关闭,所以它们看起来并不真正依附。这是我得到的最接近的:
cannons[x].RotationMatrix = Matrix.CreateRotationX(MathHelper.PiOver2) *
Matrix.CreateRotationZ(MathHelper.ToRadians(angle + cannons[x].angle) *
MathHelper.PiOver2);
cannons[x].position.X = (float)(Math.Cos(MathHelper.ToRadians(angle + cannons[x].originAngle) *
MathHelper.PiOver2) * 475) + position.X;
cannons[x].position.Y = (float)(Math.Sin(MathHelper.ToRadians(angle + cannons[x].originAngle) *
MathHelper.PiOver2) * 475) + position.Y;
我在那段代码中做错了什么?或者,如果我的方法完全关闭,那么这样做的正确方法是什么?