views:

772

answers:

2

I am writing iphone application where in I need to rotate cube. The rotation on vertical and horizontal axis is working fine. Also, rotating cube from bottom right to top left and from top left to bottom right is working fine.(I am using glrotateef(angle, 1.0, 1.0, 0.0) to rotate from top left to bottom right).

The issue here is, I want to rotate from bottom left to top right and from top right to bottom left. And I could not get the solution. I tried different approaches like

glRotateef(angle, -1.0, -1.0, 0.0) glRotateef(angle, -1.0, -1.0, 0.0) etc.. All of them are not working. Please guide me on this (what is the exact rotation I need to use). Thanks in advance.

+1  A: 

Did you try glRotatef(angle, -1.0, 1.0, 0.0) or glRotatef(angle, 1.0, -1.0, 0.0)?

erelender
Thanks much :) it worked. I was struggling with it for the past 3 days.Now I can move forward:)thank you again.
Vineyard
+1  A: 

rotating around the individual axis can be done as following:

 glRotatef(angle, 1.0, 0.0, 0.0)   //rotate around x axis
 glRotatef(angle, 0.0, 1.0, 0.0)   //rotate around y axis
 glRotatef(angle, 0.0, 0.0, 1.0)   //rotate around z axis

Look out with doing more than 1 rotation at the same time. (so anything else than the 3 above, or combining them). The order of rotations is really important. If done incorrectly they can produce 'gimbal lock'

Toad