TSorcerer
11-22-2008, 05:57 PM
Hi there,
I have a very strange bug in my OpenGL application and I cannot spot the problem.
I have a very basic application, that loads some meshes from 3ds files, builds normals, texture maps and finally display lists. I can move around the scene using mouse and keyboard commands.
I recently added a "LookAt" function, that works pretty much like the gluLookAt function.
Now when I use the new LookAt method something really strange happens. First the camera movement continually gets slower until it completely halted. However, I can stil turn as normal, just cannot move the camera anymore from where it is sitting at this point. The FPS also doesn't change. It still renders each frame as before. Well, and this is also when the scene begins to dissappear. With the eye coords as the center a "black hole" begins to grow, swallowing everything until it fills the entire scene and everything is black. This process only happens when I use the LookAt method. I dont know why it happens or what the actual causes it. I suspect however, that for some reason either my Modelview-Matrix or my Projection-Matrix are "destroyed" or "infected" and this will get worse until said black hole appears and swallows my world :(
I really don't know what happens or why it would happen. It all boils down to the LookAt thing, so I'll give you that code snipept, maybe I'm doing something horrible wrong but just can't figure out what.
void CGLBaseObject::lookAt(const CVector& pos, const CVector &up)
{
CVector f = pos - this->fvPosition;
CVector r = f | up;
CVector u = r | f;
this->m_fmTransform.r = r;
this->m_fmTransform.u = u;
this->m_fmTransform.f = f;
this->m_fmTransform.orthonormalize();
}
m_fmTransform is an CMatrix object containing the modelview matrix which is loaded before the objects display list is rendered - in case of the camera nothing is rendered of course.
CMatrix::orthonormalize() simply normalizes the matrix' position, up and right components.
I believe the CVector class and the CMatrix class work fine, if someone believes the flaw could be located within those I could provide their code aswell.
Has anyone any suggestions what I should look for? Is this maybe even a common problem? Is it possible that this origins from some sort of floating point precision error or is OpenGL trying to tell me "Hey, bitch, use gluLookAt!"?!
Any suggestions, hints or links would be really helpfull.
Greets,
Daniel
I have a very strange bug in my OpenGL application and I cannot spot the problem.
I have a very basic application, that loads some meshes from 3ds files, builds normals, texture maps and finally display lists. I can move around the scene using mouse and keyboard commands.
I recently added a "LookAt" function, that works pretty much like the gluLookAt function.
Now when I use the new LookAt method something really strange happens. First the camera movement continually gets slower until it completely halted. However, I can stil turn as normal, just cannot move the camera anymore from where it is sitting at this point. The FPS also doesn't change. It still renders each frame as before. Well, and this is also when the scene begins to dissappear. With the eye coords as the center a "black hole" begins to grow, swallowing everything until it fills the entire scene and everything is black. This process only happens when I use the LookAt method. I dont know why it happens or what the actual causes it. I suspect however, that for some reason either my Modelview-Matrix or my Projection-Matrix are "destroyed" or "infected" and this will get worse until said black hole appears and swallows my world :(
I really don't know what happens or why it would happen. It all boils down to the LookAt thing, so I'll give you that code snipept, maybe I'm doing something horrible wrong but just can't figure out what.
void CGLBaseObject::lookAt(const CVector& pos, const CVector &up)
{
CVector f = pos - this->fvPosition;
CVector r = f | up;
CVector u = r | f;
this->m_fmTransform.r = r;
this->m_fmTransform.u = u;
this->m_fmTransform.f = f;
this->m_fmTransform.orthonormalize();
}
m_fmTransform is an CMatrix object containing the modelview matrix which is loaded before the objects display list is rendered - in case of the camera nothing is rendered of course.
CMatrix::orthonormalize() simply normalizes the matrix' position, up and right components.
I believe the CVector class and the CMatrix class work fine, if someone believes the flaw could be located within those I could provide their code aswell.
Has anyone any suggestions what I should look for? Is this maybe even a common problem? Is it possible that this origins from some sort of floating point precision error or is OpenGL trying to tell me "Hey, bitch, use gluLookAt!"?!
Any suggestions, hints or links would be really helpfull.
Greets,
Daniel