Original Post
hello, I am trying to build a view matrix from parameters eye,at,up. The problem is this, in documentation it says the matrix is build like this: now the probelm is that my at and eye vectors are allways the same distance from each other, they just get rotated or translated as a pair, so they allways keep the same distance. Thus in f I allways get the same vector for the f is their subtraction. Then , becouse the up vector is allways the same too , my grCross3(f,upn,s) and grCross3(s,f,u) are allways the same value. So my view matrix is never translated but only rotated. Also I get a strange viewing result. How do I build a correct view matrix by eye,at,up parameters?
void grViewMatrixLookAt(float* eye,float* at,float* up,float* res)
{
grIdentity(res);
float f[3],s[3],u[3],upn[3];
grSubVector3(at,eye,f);
grNormalize3(f,f);
grNormalize3(up,upn);
grCross3(f,upn,s);
grCross3(s,f,u);
*(res) = s[0];
*(res+1) = u[0];
*(res+2) = -f[0];
*(res+4) = s[1];
*(res+5) = u[1];
*(res+6) = -f[1];
*(res+8) = s[2];
*(res+9) = u[2];
*(res+10) = -f[2];
}