I create a camera matrix with the following code segment and multiply the matrix for all objects but it doesn’t seem to work correctly. Any ideas?
void myLookAt (
float eyex, float eyey, float eyez,
float centerx, float centery, float centerz,
float upx, float upy, float upz)
vector3 y (upx, upy, upz);
vector3 f (centerx - eyex, centery - eyey, centerz - eyez);
vector3 uprime (upx, upy, upz);
vector3 s, u;
uprime.normalize(); f.normalize(); s = CrossProduct (f, uprime); s.normalize(); u = CrossProduct (s, f); m = s.x; m = s.y; m = s.z; m = 0.0; m = u.x; m = u.y; m = u.z; m = 0.0; m = -f.x; m = -f.y; m = -f.z; m = 0.0; m = 0.0; m = 0.0; m = 0.0; m = 1.0;
Then in the drawing code I do the following after setting the viewing frustum
/**/ myLookAt (
center.x, center.y, center.z,
up.x, up.y, up.z); // Up vector
glTranslated (-eye.x, -eye.y, -eye.z);
then I draw the objects. However, there seems to a problem. Any help would be appreciated.