Advertisement

Camera movement

Started by October 13, 2002 11:18 AM
1 comment, last by arkansas 22 years, 4 months ago
Hi My Camera is only moving if i move the mouse or push a button. Usally its supposed to move as soon as i start the program. Why is that so.
Maybe you put your camera moving code before glLoadIdentity() perhaps?
Show us a little code, so we can help more...
Advertisement
Hey

Ok thats how I did it::

void InitCamera()
{
angle=25.0f;
posY=1.0f;
radians = float(PI*(angle-90.0f)/180.0f);

lookX = posLookX;
lookY = 0.0f;
lookZ = posLookZ;

cameraX = lookX + (float)sin(radians)*posY;
cameraZ = lookZ + (float)cos(radians)*posY;
cameraY = lookY + posY/2.0f;

posLookX+=0.1f;
posLookZ-=0.1f;
}


int RenderScene()
{

Init();

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear Screen and Depth Buffer
glLoadIdentity(); //Reset the current Modelview matrix

InitCamera();

glTranslatef(0.0,-30.0,-10.0);
gluLookAt(cameraX,cameraY,cameraZ,lookX,lookY,lookZ,0.0,1.0,0.0);

InitFields();

return 0;

}

This topic is closed to new replies.

Advertisement