From: H. H. <hen...@gm...> - 2008-08-28 21:14:15
|
I am unable to get glmMatLookAt4f function working. I am following the formula given in the gluLookAt manpage, but still no luck. Could somebody take a look at my code? The test case gives me a failure. Here is my local copy of the function (the repos version is outdated). GLMmat4f * glmMatLookAt4f (GLMmat4f *out, const GLMvec3f *eye, const GLMvec3f *center, const GLMvec3f *up) { GLMmat4f t; GLMvec3f f, s, u; assert (out); assert (eye); assert (center); assert (up); /* FIXME: not working */ /* FIXME: unoptimal implementation */ glmVecSub3f (&f, center, eye); glmVecNormalize3f (&f, &f); glmVecNormalize3f (&u, up); glmVecCross3f (&s, &f, &u); glmVecCross3f (&u, &s, &f); out->m00 = s.x; out->m01 = s.y; out->m02 = s.z; out->m03 = 0.0f; out->m10 = u.x; out->m11 = u.y; out->m12 = u.z; out->m13 = 0.0f; out->m20 = -f.x; out->m21 = -f.y; out->m22 = -f.z; out->m23 = 0.0f; out->m30 = 0.0f; out->m31 = 0.0f; out->m32 = 0.0f; out->m33 = 1.0f; glmMatIdentity4f (&t); t.m03 = -eye->x; t.m13 = -eye->y; t.m23 = -eye->z; glmMatMul4f (out, out, &t); return out; } -- Henri 'henux' Häkkinen |