I have gotten a camera to wokr and I had
the function to move correctly, but it the camera was not staying on the floor:
/*Mouse View Events*/
void glCLeft() {m_angle -= 1.5f; }
void glCRight() {m_angle += 1.5f;}
void glCUp() {m_height += 1.5f;}
void glCDown() {m_height -= 1.5f;}
/*Keyboard movement events */
void glCMLeft() {camerax += 1.0f;}
void glCMRight(){camerax -= 1.0f;}
void glCMUp() {cameraz += 1.0f;}
void glCMDown() {cameraz -= 1.0f;}
Whereas the Render:
void System::Render()
{
// clear screen and depth buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// load the identity matrix (clear to default position and orientation)
glLoadIdentity();
glRotatef(m_height, 1.0f ,0.0f ,0);
glRotatef(m_angle, 0.0f ,1.0f ,0);
glTranslatef(camerax * SINE(m_angle),cameray, cameraz * COS(m_angle));
/*Draw floor*/
glPushMatrix();
glBindTexture(GL_TEXTURE_2D, m_textureObjectOne);
glDrawFloor();
glPopMatrix();
}
And COS and SINE are defined as:
#include <math.h>
#ifndef __GL_COMPONENT
#define __GL_COMPONENT
#define PI 3.14159
#define TWO_PI PI*2.0
#define HALF_PI PI/2.0
#define SINE(x) (float)sin((PI/180.0f) * x)
#define COS(x) (float)cos((PI/180.0f) * x)
When I preass ‘A’ or ‘D’ to strafe, it moves on its original X Y axis, not the one I am loking at.
Can I get help?
~Axesor