求高手赐教,本人正在学习基于C#的directx开发,在摄像机旋转遇到问题了,无法绕X轴旋转360度。附部分代码 25
当绕X轴旋转时,从90度旋转到-90度正常,再继续旋转时无法旋转过去,不能达到360度旋转,求高手赐教{caseKeys.Up:CamPostion.Subtract(C...
当绕X轴旋转时,从90度旋转到-90度正常,再继续旋转时无法旋转过去,不能达到360度旋转,求高手赐教
{case Keys.Up:
CamPostion.Subtract(CamTarget);
tempV4 = Vector3.Transform(CamPostion, Matrix.RotationQuaternion(Quaternion.RotationAxis(new Vector3(currentView.M11, currentView.M21, currentView.M31), -angleY)));
CamPostion.X = tempV4.X + CamTarget.X;
CamPostion.Y = tempV4.Y + CamTarget.Y;
CamPostion.Z = tempV4.Z + CamTarget.Z;
break;
case Keys.Down:
CamPostion.Subtract(CamTarget);
tempV4 = Vector3.Transform(CamPostion, Matrix.RotationQuaternion(Quaternion.RotationAxis(new Vector3(currentView.M11, currentView.M21, currentView.M31), angleY)));
CamPostion.X = tempV4.X + CamTarget.X;
CamPostion.Y = tempV4.Y + CamTarget.Y;
CamPostion.Z = tempV4.Z + CamTarget.Z;
break;
}
Matrix viewMatrix = Matrix.LookAtLH(CamPostion, CamTarget, new Vector3(0, 1, 0));
device.Transform.View = viewMatrix; 展开
{case Keys.Up:
CamPostion.Subtract(CamTarget);
tempV4 = Vector3.Transform(CamPostion, Matrix.RotationQuaternion(Quaternion.RotationAxis(new Vector3(currentView.M11, currentView.M21, currentView.M31), -angleY)));
CamPostion.X = tempV4.X + CamTarget.X;
CamPostion.Y = tempV4.Y + CamTarget.Y;
CamPostion.Z = tempV4.Z + CamTarget.Z;
break;
case Keys.Down:
CamPostion.Subtract(CamTarget);
tempV4 = Vector3.Transform(CamPostion, Matrix.RotationQuaternion(Quaternion.RotationAxis(new Vector3(currentView.M11, currentView.M21, currentView.M31), angleY)));
CamPostion.X = tempV4.X + CamTarget.X;
CamPostion.Y = tempV4.Y + CamTarget.Y;
CamPostion.Z = tempV4.Z + CamTarget.Z;
break;
}
Matrix viewMatrix = Matrix.LookAtLH(CamPostion, CamTarget, new Vector3(0, 1, 0));
device.Transform.View = viewMatrix; 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询