I'm confused... which function?
All I did was write a Camera class with some basic methods, and then I tried to make the pointer. I don't have anything in my code about it, which I assume is bad.
Code:
// amera.cpp: implementation of the Camera class.
//
//////////////////////////////////////////////////////////////////////
#include "amera.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
Camera::Camera()
:Object(),upperLimit(30.0f),lowerLimit(-60.0f),bounceAmount(0.12f),walkBias(0.0f)
{
}
Camera::~Camera()
{
}
//////////////
//Rotation
//////////////
void Camera::lookUp(GLfloat amount)
{
rotX+=amount;
if(rotX > upperLimit)
rotX=upperLimit;
else if(rotX < lowerLimit)
rotX=lowerLimit;
}
void Camera::setUpDownLimits(GLfloat newLower, GLfloat newUpper)
{
upperLimit = newUpper;
lowerLimit = newLower;
}
//////////////
//Movement
//////////////
//PI divided 180 = 0.01745329252f
void Camera::moveForward(GLfloat amount)
{
x-=(GLfloat)(sin(rotY*0.01745329252f)* amount);
z+=(GLfloat)(cos(rotY*0.01745329252f)* amount);
bounce();
}
void Camera::moveLeft(GLfloat amount)
{
x-=(GLfloat)(sin((rotY+90)*0.01745329252f)* amount);
z+=(GLfloat)(cos((rotY+90)*0.01745329252f)* amount);
bounce();
}
void Camera::bounce()
{
walkBias+=bounceAmount;
if(walkBias >= 360.0f) //Calculate bounce
walkBias -=360.0f;
y+=(float)(sin(walkBias*0.01745329252f))/1.5f; //Make player bounce
}
////////////
//Draw
///////////
void Camera::draw()
{
glRotatef(rotX, 1.0f, 0.0f, 0.0f);
glRotatef(rotY, 0.0f, 1.0f, 0.0f);
glRotatef(rotZ, 0.0f, 0.0f, 1.0f);
glTranslatef(x, y, z);
}