Miechu
May 2nd, 2006, 07:42 PM
i've implemented almost a camera ;)
i've got 6 variables:
float x_rotation;
float y_rotation;
float x_translation;
float y_translation;
float z_translation;
i do camera rotation like this:
x_rotation += (point.y-last_x);
y_rotation += (point.x-last_y);
where point is a struct for mouse position, and last_x/y is for last mouse pos...
now when i want to move i do it like this:
z_translation+=0.2f; //forward
z_translation-=0.2f; //backward
x_translation+=0.2f;//strafe
x_translation-=0.2f;//strafe
now for drawing:
glTranslatef(x_translation,y_translation,z_translation);
glRotatef(x_rotation,1.0f,0.0f,0.0f);
glRotatef(y_rotation,0.0f,1.0f,0.0f);
now the problem is, that this effects in being 'on a stick' - when i move somewhere & rotate (with mouse) - i'm rotating realetivly to (0,0,0), but i move correctly...
now if i change the drawing to:
glRotatef(x_rotation,1.0f,0.0f,0.0f);
glRotatef(y_rotation,0.0f,1.0f,0.0f);
glTranslatef(x_translation,y_translation,z_translation);
i'm rotating just fine... but i'm moving always absolutly... strafe is not always strafe - just moving on the x-axis...
i don't know if anyone will undersand this problem... but if there is a one... please explain it to me... (i'm lame in 3d math)
i've got 6 variables:
float x_rotation;
float y_rotation;
float x_translation;
float y_translation;
float z_translation;
i do camera rotation like this:
x_rotation += (point.y-last_x);
y_rotation += (point.x-last_y);
where point is a struct for mouse position, and last_x/y is for last mouse pos...
now when i want to move i do it like this:
z_translation+=0.2f; //forward
z_translation-=0.2f; //backward
x_translation+=0.2f;//strafe
x_translation-=0.2f;//strafe
now for drawing:
glTranslatef(x_translation,y_translation,z_translation);
glRotatef(x_rotation,1.0f,0.0f,0.0f);
glRotatef(y_rotation,0.0f,1.0f,0.0f);
now the problem is, that this effects in being 'on a stick' - when i move somewhere & rotate (with mouse) - i'm rotating realetivly to (0,0,0), but i move correctly...
now if i change the drawing to:
glRotatef(x_rotation,1.0f,0.0f,0.0f);
glRotatef(y_rotation,0.0f,1.0f,0.0f);
glTranslatef(x_translation,y_translation,z_translation);
i'm rotating just fine... but i'm moving always absolutly... strafe is not always strafe - just moving on the x-axis...
i don't know if anyone will undersand this problem... but if there is a one... please explain it to me... (i'm lame in 3d math)