2012-06-15 3 views
0

Я попытался повернуть некоторые вершины, используя разные способы вращения - GL.Rotate, Matrix4.CreateRotationX и Matrix4.RotateX. К моему удивлению, они дали разные результаты. Вот функция, которая создает три матрицы и выводит их на консоль.GL.Rotate и Matrix4.CreateRotationX различные выходы

private void for_debug() 
    { 
     Vector3 CubeRotationAnglesInDeg = new Vector3(15, 29, 84); 

     Matrix4 XCubeRotationMatrix1 = Matrix4.CreateRotationX(Helper.ToRadians(CubeRotationAnglesInDeg.X)), 
       YCubeRotationMatrix1 = Matrix4.CreateRotationY(Helper.ToRadians(CubeRotationAnglesInDeg.Y)), 
       ZCubeRotationMatrix1 = Matrix4.CreateRotationZ(Helper.ToRadians(CubeRotationAnglesInDeg.Z)); 
     Matrix4 finalMatrixMine1 = XCubeRotationMatrix1 * YCubeRotationMatrix1 * ZCubeRotationMatrix1; 


     Matrix4 XCubeRotationMatrix2 = Matrix4.RotateX(Helper.ToRadians(CubeRotationAnglesInDeg.X)), 
       YCubeRotationMatrix2 = Matrix4.RotateY(Helper.ToRadians(CubeRotationAnglesInDeg.Y)), 
       ZCubeRotationMatrix2 = Matrix4.RotateZ(Helper.ToRadians(CubeRotationAnglesInDeg.Z)); 
     Matrix4 finalMatrixMine2 = XCubeRotationMatrix2 * YCubeRotationMatrix2 * ZCubeRotationMatrix2; 


     GL.MatrixMode(MatrixMode.Modelview); 
     GL.LoadIdentity(); 
     GL.Rotate(CubeRotationAnglesInDeg.X, Vector3.UnitX); 
     GL.Rotate(CubeRotationAnglesInDeg.Y, Vector3.UnitY); 
     GL.Rotate(CubeRotationAnglesInDeg.Z, Vector3.UnitZ); 
     Matrix4 finalMatrixOpen; 
     GL.GetFloat(GetPName.ModelviewMatrix, out finalMatrixOpen); 

     Console.WriteLine(finalMatrixMine1.Column0); 
     Console.WriteLine(finalMatrixMine1.Column1); 
     Console.WriteLine(finalMatrixMine1.Column2); 
     Console.WriteLine(finalMatrixMine1.Column3); 
     Console.WriteLine(); 

     Console.WriteLine(finalMatrixMine2.Column0); 
     Console.WriteLine(finalMatrixMine2.Column1); 
     Console.WriteLine(finalMatrixMine2.Column2); 
     Console.WriteLine(finalMatrixMine2.Column3); 
     Console.WriteLine(); 

     Console.WriteLine(finalMatrixOpen.Column0); 
     Console.WriteLine(finalMatrixOpen.Column1); 
     Console.WriteLine(finalMatrixOpen.Column2); 
     Console.WriteLine(finalMatrixOpen.Column3); 
     Console.WriteLine(); 

     Console.WriteLine(); 
     Console.WriteLine(); 
     Console.WriteLine(); 
     Console.WriteLine(); 
    } 

И вот ToRadians функционировать

public static float ToRadians(float degrees) 
    { 
     return degrees * (float)(Math.PI/180f); 
    } 

Является ли это нормальным, а что я могу сделать, чтобы сделать результаты одно и то же?

Edit: Вот вывод

(0.09142262, -0.9475183, 0.3063508, 0) 
(0.8698285, 0.2257573, 0.4386708, 0) 
(-0.4848096, 0.2263682, 0.8448178, 0) 
(0, 0, 0, 1) 

(0.09142262, -0.9475183, 0.3063508, 0) 
(0.8698285, 0.2257573, 0.4386708, 0) 
(-0.4848096, 0.2263682, 0.8448178, 0) 
(0, 0, 0, 1) 

(0.09142266, -0.8698285, 0.4848096, 0) 
(0.9737504, -0.02382383, -0.2263682, 0) 
(0.2084515, 0.4927787, 0.8448178, 0) 
(0, 0, 0, 1) 
+0

Просьба также опубликовать результат - это поможет людям, которые не могут/не хотят воссоздать ваш образец. – Ani

ответ

0

Я подозреваю, что вы должны поместить свои команды GL.Rotate() в обратном порядке, чтобы получить желаемый результат.

 Смежные вопросы

  • Нет связанных вопросов^_^