0

I have the following matrix in a game I'm reverse engineering to see how it works.

I managed to capture this matrix when a model is rendered:

     0.999971,     0.003148,     -0.006994,  0.000000
     0.000000,     0.911863,      0.410494,  0.000000
     0.006903,    -0.410485,      0.911844,  0.000000
-25014.388672, 11944.956055, -19475.357422,  1.000000

I started calculating the angle using the following:

Point CalculateRotatation(float ModelView[16])
{
    Point Result;
    Result.X = atan2(ModelView[9], ModelView[10]) * (180 / PI);
    Result.Y = atan2(-ModelView[8], ModelView[9]) * (180 / PI);
    Result.Z = atan2(ModelView[4], ModelView[0]) * (180 / PI);
    return Result;
}

I was following: http://db-in.com/blog/2011/04/cameras-on-opengl-es-2-x/

I'm not sure if I'm doing it correctly. The game does not using OpenGL-ES but I'm not sure that it matters.

Can any of you tell me if I'm on the right path or if my Calculate function is correct? The Y-value seems to be wrong. I know there are many threads like this and I looked through them but they don't seem to be doing what I have. They are using dot products and cross products. I just need confirmation or a little help.

EDIT: I know this much:

I know the calculations for the X and Y rotations are correct. If I change my character's view from left to right, the Z increases/decreases. If I change my character's view height, the X increases/decreases. The Y however I don't know if it is right or how to get it.. I have this diagram: enter image description here

4

1 回答 1

4

从旋转矩阵中提取固定角度可能有多个答案,因为它涉及反三角函数和平方根。例如,如果旋转序列为 xyz(行向量系统),则公式如下所示。

AngleX = atan2(m11, m22)
AngleY = atan2(-m02, sqrt(m00^2 + m01^2))
AngleZ = atan2(m01, m00)

但是,这并不是故事的结局。我相信这篇文章会帮助你找到更好的方法。祝你好运!

于 2013-07-19T16:42:27.440 回答