Reputation: 1378
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.
Upvotes: 1
Views: 1594
Reputation: 15925
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'
Upvotes: 1
Reputation: 6295
Did you try glRotatef(angle, -1.0, 1.0, 0.0) or glRotatef(angle, 1.0, -1.0, 0.0)?
Upvotes: 3