hmm… okay i am writing a 3d engine(isn’t everyone?) but i am trying to stay away from glu library not glut or glaux but glu.h… and so i put together some thoughts and came up with a glulookat replacement… but it doesn’t seem to work in theory it should but maybe i am missing something small.
all the functions do what they sound like…
vec is declared as
typdef float vec[3];
used an array for various reasons as opposed to a struct.
the last parameter of functions is always the result… i replaced gltranslatef with just adding the values to the matrix.
Maybe someone could help me… maybe i am forgetting to set a certain modelview matrix or something…
void lookAt(float eyex, float eyey, float eyez,
float centerx,float centery,float centerz,
float upx, float upy, float upz)
{
vec F,f={0},UP, up={0},s={0},u={0};
matrix M;
F[0]=centerx-eyex;
F[1]=centery-eyey;
F[2]=centerz-eyez;
UP[0]=upx;
UP[1]=upy;
UP[2]=upz;
NormalizeVector(F,&f);
NormalizeVector(UP,&up);
MultiplyVecs(f,up,&s);
MultiplyVecs(s,f,&u);
Reverse(f,&f);
ZeroMemory(&M,MATRIX4SIZE);
M[0][0]= s[0]; M[0][1]= s[1]; M[0][2]= s[2]; M[0][3]= 0;
M[1][0]= u[0]; M[1][1]= u[1]; M[1][2]= u[2]; M[1][3]= 0;
M[2][0]= f[0]; M[2][1]= f[1]; M[2][2]= f[2]; M[2][3]= 0;
M[3][0]= -eyex; M[3][1]= -eyey; M[3][2]= -eyez; M[3][3]= 1;
glMultMatrixf(M);
//glTranslatef (-eyex, -eyey, -eyez);
}
thanks a ton…
Dan