Ok, I'm done with forward and backward movement with gluLookAt()
function.
I subtract eyeX
from atX
, and eyeZ
from atZ
. Names of each variables are xVector
and zVector
. And I add it with some multiplication with constant.
From now on, I have to calculate side movement vector. But how can I get that one? Is there any way to move a camera from side to side with z and x vectors?
I use C, so there's no vector class or some kinds of high-level class/functions.
I need you guys' help now.
This is my function for camera movement processing,
void cameraProc() {
int xInc, zInc;
at[0] += xTheta;
at[1] += yTheta;
if (keys['w']) {
eye[0] += xInc*SPD;
at[0] += xInc*SPD;
eye[2] += zInc*SPD;
at[2] += zInc*SPD;
}
if (keys['a']) {
//How?
}
if (keys['s']) {
eye[0] -= xInc*SPD;
at[0] -= xInc*SPD;
eye[2] -= zInc*SPD;
at[2] -= zInc*SPD;
}
if (keys['d']) {
//And how?
}
printf("\nEye : %f %f %f\n", eye[0], eye[1], eye[2]);
printf("At : %f %f %f\n", at[0], at[1], at[2]);
gluLookAt(eye[0], eye[1], eye[2], at[0], at[1], at[2], up[0], up[1], up[2]);
at[0] -= xTheta;
at[1] -= yTheta;
}
P.s. xTheta
and yTheta
is variables to spin the camera.