Hey there.
I want to make the camera moving along a circular path around the zero point (0,0,0).
So to calculate the position for the camera I use cos(deg) for the x movement and sin(deg) for the z movement in order to move along the path.
To obtain the zero point centered on the screen I just calculate deg + 180.
When you change your position with deg = 10° you have to turn arround with 190° to obtain the zero point centered.
Since glRotate() does work with degrees I thought this might work.
To put this in a code I did :
static float deg = 0;
deg+=0.1;
if (deg > 360.0)
{
deg = 360.0 - deg;
}
static float temp = 0;
temp = deg + 180.0;
if (temp >= 360.0) temp = 360.0 - temp;
glRotatef(m_Camera.m_Rotate.y , 0.0, 1.0, 0.0);
glTranslatef( cos(inRad(deg)), 0, sin(inRad(deg)) );
glutSolidSphere(2,80,80);
This kinda doesn’t work like I want to.
For example, when I move the camera with 45° degrees I have to rotate by 145° to maintain the zero point centered on the screen.
For 90° I have to turn by 180°
EDIT :
Ok, problem is I have to change
temp = deg + 180.0;
to this
temp = deg + 90.0;
But can someone explain why it’s not working or why it’s only working with +90 ?
How does OpenGL rotate ? Clockwise or Counter-clockwise ?
Thanks in advance