【发布时间】:2013-08-21 16:27:40
【问题描述】:
我在尝试串联移动简单模型时遇到问题。我有 20 个较小的模型连接到一个较大的模型。它本质上是一个带有多个外部大炮的飞碟。我见过其他问题,比如this one,看起来几乎是我想要的。但是,这只会创建绘图转换。我实际上需要在 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;
我在该代码中做错了什么?或者,如果我的方法完全不可行,那么正确的做法是什么?
【问题讨论】: