I have been working on a simple quaternion camera, but I cannot seem to get it to work. When I call my rotation function nothing happens. I got this code from quaternion camera examples. Here is my code:
What might be wrong with this code?Code:quaternion View = {0.0,0.0,0.0,0.0}; const Vec WORLD_YAXIS = {0.0f, 1.0f, 0.0f}; const Vec WORLD_XAXIS = {1.0f, 0.0f, 0.0f}; inline void fromAxisAngle(const Vec &axis, float degrees, quaternion *a) { float halfTheta = (degrees * 3.1415926f) / 180.0f * 0.5f; float s = sinf(halfTheta); a->w = cosf(halfTheta), a->x = axis.x * s, a->y = axis.y * s, a->z = axis.z * s; } void rotate(float headingDegrees, float pitchDegrees) { pitchDegrees = -pitchDegrees; headingDegrees = -headingDegrees; quaternion rot; if (headingDegrees != 0.0f) { fromAxisAngle(WORLD_YAXIS, headingDegrees,&rot); mult(rot,View); } // Rotate camera about its local x axis. // Note the order the quaternions are multiplied. That is important! if (pitchDegrees != 0.0f) { fromAxisAngle(WORLD_XAXIS, pitchDegrees,&rot); mult(View,rot); } } void render() { //Clear color buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); rotate(40,40); gluLookAt(-xpos,-ypos,-zpos,View.x,View.y,View.z,0,1,0); //Render quad...



LinkBack URL
About LinkBacks


