0

我正在尝试制作类似的东西 - 让我们称之为使用现代 OpenGL 的飞行模拟器。我正在尝试使用偏航、俯仰和滚动来旋转我的平面对象。但似乎对象围绕全局坐标系旋转(我的意思是,如果我的对象面向矢量 (0,0,1) 滚动操作像它应该的那样工作,但是如果我将它转向面对例如 (1,0,0) 它的行为就像俯仰)

我的转换矩阵是这样计算的:

  transformation_matrix = perspective_projection_matrix *
                        camera_rotation_matrix *
                        camera_translation_matrix *
                        translation_matrix *
                        rotation_matrix *
                        scale_matrix;

旋转矩阵是

rotation_matrix = rotation_z * rotation_y * rotation_x;

我试图在平移之前添加局部旋转矩阵,但它看起来更糟(对象现在围绕空间中的某个点飞行,始终面向默认)

我应该怎么做才能在局部坐标系中用偏航、俯仰和滚动来旋转像典型平面这样的物体?

编辑

我还注意到旋转是在全局坐标系中执行的,相机位置为 (0,0,0) 不是这样,我的错

4

1 回答 1

1

The plane's orientation will ultimately be the concatenation of many discrete rotations around different axes. This is not the same as simply summing the individual rotations. They are not independent.

For example, if you pitch up 90 degrees, roll 90 degrees, and then pitch down 90 degrees, the resulting orientation will not be a roll of 90 degrees, but instead a yaw of 90 degrees.

Instead, keep a persistant matrix which represents the orientation of your plane, and then apply roll, pitch, and yaw rotations to it as appropriate.

于 2013-03-01T14:18:53.873 回答