Hi all, i made a quaternion camera and it works perfectly. Now I try to draw a skybox (which works with my other camera class) but it stays in the origin.
I translate it to the camera coordinates i get from CQuatCam.GetPos(). Also if i try to spawn objects at the camera position using this function to get the coords they spawn at 0,0,0.
When I print the coordinates to the screen (after i got them with this same GetPos() function) they seem to be right... Strange eh?!?
Here is the relevant code for the camera.
const float HALFRADTODEG = 360 / 3.141592;
void CQuadCam::CameraView()
{
float angle = (acos(orient.W) * HALFRADTODEG);
float scale = sqrt(orient.X*orient.X + orient.Y*orient.Y + orient.Z*orient.Z);
float ax = orient.X / scale;
float ay = orient.Y / scale;
float az = orient.Z / scale;
glRotatef(angle, ax, ay, az);
glTranslatef(pos.X, pos.Y, pos.Z);
}
TVec3 CQuadCam::GetPos()
{return pos;}
and code for the display loop:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
QuadCam.MouseLook(); // changes rotation quat according to mouse coords.
QuadCam.CameraView(); // rotates and translates
FrustumCuller.UpdateFrustum(); // gets the fustrum for culling
SkyBox.DrawSkyBox(QuadCam.GetPos()); // this is where i draw the skybox
DrawGrid(); // this grid DOES work correctly.
////////////////////////
glColor3f(0,1,0);
sprintf(fpstext, "FPS:%f", fps);
Print(20,20,fpstext);
Print(20,40,checktext);
////////////////////////
glTranslatef(0,0,-4);
glColor3f(1,0,0);
glutSolidCube(1); // This cube also does work correctly
glTranslatef(0,0,4);
ParticleHandler.DrawParticles(); //Particles should go after all rendering, but before overlay because they don''t write to the depth mask
ColorOverlay.DrawOverlay();
glutSwapBuffers();
framecount++;
if (FPSTimer.Read() >= 1000)
{
fps = float(framecount*1000)/FPSTimer.Read();
FPSTimer.Start();
framecount = 0;
}