Original Post
I dont want to use gluLookAt() and I have implemented a simple camera class. I have three vectors for my camera, m_pos , m_view (which is not the point I look at, but the direction of viewing) and m_up. When I initialize the class I declare :
m_pos = {0.0f,0.0f,0.0f};
m_view = {0.0f,0.0f,-1.0f}; // Look to negative z axis direction
m_up = {0.0f,1.0f,0.0f}; // Up is the positive y axis
and then I use cross product of m_view and m_up (m_view x m_up)to calculate the m_right vector. I normalize it after that.
In my camera render function (i.e. similar to gluLookAt()) I do these:
void MyCamera::Render()
{
float mat[16];
float tx = - Dot(m_right,m_pos);
float ty = - Dot(m_up,m_pos);
float tz = - Dot(m_view,m_pos);
mat[0] = m_right.x; mat[4] = m_right.y; mat[8] = m_right.z;
mat[1] = m_up.x; mat[5] = m_up.y; mat[9] = m_up.z;
mat[2] = m_view.x; mat[6] = m_view.y; mat[10] = m_view.z;
mat[3] = mat[7] = mat[11] = 0.0f;
mat[12] = tx; mat[13] = ty; mat[14] = tz; mat[15] = 1.0f;
glMultMatrixf(mat);
}
and I use this function in my DrawGL() function exactly after my glLoadIdentity() function. I then draw my other objects usinf glTranslate() and glRotate(). But nothing is shown on screen. What it might be wrong? I know that the camera matrix is the inverse of the camera''s world matrix (if i treat it as an object)so if camera''s world matrix is T * R , the inverse will be inverse(R) * inverse(T) which (I think) is the matrix I construct. So what''s wrong? Thanks in advance.