Trying to use gluLookAt. Im rotating around like rhe camera is on an sphere with an radius from the center of the object:
void calculateAndLook(){
//regner ut posisjon i kuleskallet
eye[Y] = radius * sin(xzrotM_PI/180);
eye[X] = radius * cos(xzrotM_PI/180) * sin(yrotM_PI/180);
eye[Z] = radius * cos(xzrotM_PI/180) * cos(yrot*M_PI/180);
//renger ut hva som er opp, tangenten til kuleskallet
up[Y] = 1.0 * sin(xzrot*M_PI/180);
up[X] = 1.0 * cos(yrot*M_PI/180);
up[Z] = 1.0 * sin(yrot*M_PI/180);
//center er i origo
center[X] = 0.0f;
center[Y] = 0.0f;
center[Z] = 0.0f;
printf("X:%f Y:%f Z:%f
",eye[X],eye[Y],eye[Z]);
float length = sqrt(eye[X]eye[X] + (eye[Z])(eye[Z]) + eye[Y]*eye[Y]);
printf("length: %f
", length);
//ser
gluLookAt(eye[X],eye[Y],eye[Z],center[X],center[Y],center[Z],up[X],up[Y],up[Z]);
}
but this dousnt work right.Im inside the box when i start the program. But when i change center[Z] to -7, the rotation goes completly amok.