简体   繁体   English

如何在iPhone OpenGL ES中使用glRotatef()反转旋转?

[英]How to REVERSE rotation with glRotatef() in iPhone OpenGL ES?

I am trying to rotate a 3D model in both forward (counter-clockwise) and reverse (clockwise) rotation directions in orthographic mode. 我正在尝试在正交模式下正向(逆时针)和反向(顺时针)旋转3D模型。 glRotatef() automatically executes a forward rotation but I cannot get a reverse rotation. glRotatef()自动执行正向旋转,但我无法反向旋转。 I have tried the following methods and none of them give me results: 我尝试了以下方法,但都没有给我结果:

   //(Provide a negative rotation angle of -1 degree)
    glrotatef(-1.0, 0.0, 1.0, 0.0);

    //(Set a negative axis)
    glrotatef(1.0, 0.0, -1.0, 0.0);

Is this a limitation in OpenGL ES 1.1? 这是OpenGL ES 1.1中的限制吗? How can I get REVERSE (clockwise) rotation in OpenGL ES? 如何在OpenGL ES中获得REVERSE(逆时针)旋转?

尝试使用359度角。

Your code is doing the same operation twice. 您的代码执行两次相同的操作。 If you had left the angle at -1.0 and inverted the rotation axis, you would be rotating the other way. 如果将角度保留为-1.0并反转了旋转轴,则将以另一种方式旋转。 Or if you left the rotation axis alone and negated the angle, you would also rotate the other way. 或者,如果您不理会旋转轴并否定角度,则也将以其他方式旋转。 Instead, you negated the rotation angle and inverted the rotation axis, so you end up doing the same thing twice. 取而代之的是,您否定了旋转角度反转了旋转轴,因此最终两次执行相同的操作。

You should also keep in mind your high school geometry, where angles are mod 360 . 您还应该记住角度为mod 360的高中几何。 This is why a rotation is 359 degrees is the same as rotating by -1 degrees. 这就是为什么旋转359度与旋转-1度相同的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM