XNA에서 비행 시뮬레이터 프로그램 (Star Fox 64와 유사)을 쓰고 있습니다. 회전에 문제가 있습니다. 내 생각은 위치에 대한 속도와 벡터에 대한 벡터를 갖는 것입니다. 내가 허용하는 컨트롤은 오일러의 각도가 문제를 일으킬 수 있도록 쿼터니언을 사용하려고합니다.XNA Quaternion.createFromAxisAngle
아직 그래픽 렌더링에 익숙하지 않지만 Quaternion.createFromAxisAngle (벡터, 롤) (롤은 내 속도 벡터 주위로 회전 함)를 사용할 수 있다고 생각했지만 제대로 작동하지 않습니다. 기본적으로 피치 또는 요를 회전하려고 할 때마다 아무 일도 일어나지 않습니다. 롤 때, 그것은 작동하지만 예상했던대로하지 않습니다. createFromAxisAngle 메서드를 적절하게 사용합니까? 감사. 당신이 요, 피치, & 롤 변수로 배의 방향을 저장에 대한 단호
public override void UpdatePositions()
{
float sinRoll = (float)Math.Sin(roll);
float cosRoll = (float)Math.Cos(roll);
float sinPitch = (float)Math.Sin(pitch);
float cosPitch = (float)Math.Cos(pitch);
float sinYaw = (float)Math.Sin(yaw);
float cosYaw = (float)Math.Cos(yaw);
m_Velocity.X = (sinRoll * sinPitch - sinRoll * sinYaw * cosPitch - sinYaw * cosPitch);
m_Velocity.Y = sinPitch * cosRoll;
m_Velocity.Z = (sinRoll * sinPitch + sinRoll * cosYaw * cosPitch + cosYaw * cosPitch);
if (m_Velocity.X == 0 && m_Velocity.Y == 0 && m_Velocity.Z == 0)
m_Velocity = new Vector3(0f,0f,1f);
m_Rotation = new Vector3((float)pitch, (float)yaw, (float)roll);
m_Velocity.Normalize();
//m_QRotation = Quaternion.CreateFromYawPitchRoll((float)yaw,(float)pitch,(float)roll); This line works for the most part but doesn't allow you to pitch up correctly while banking.
m_QRotation = Quaternion.CreateFromAxisAngle(m_Velocity,(float)roll);
m_Velocity = Vector3.Multiply(m_Velocity, shipSpeed);
m_Position += m_Velocity;
}
감사합니다. Seb, 내 블로그입니다! =) 나는 언젠가 그것을 썼다. 얼마나 많은 사람들이 유용하다고 생각하는지 알고 놀랐다. thattolleyguy의 질문에 대한 나의 대답은 블로그 본질의 미니 버전이었습니다. –