Original Post
I am trying to create a camera where it moves in a circle about a fixed 3D point. I have been using the following code and it results in a square like movement. The midX, midY, midZ variables are midpoints on a grid I have set up. I basically want the camera to rotate around the grid while always facing in the middle of the grid. How can I make the camera move in a circle around a fixed point and also always have the camera facing that fixed point? Thank you for your help. EDIT: Please remember 'source' tags in future... [Edited by - jollyjeffers on March 28, 2007 9:33:31 AM]
if (rotateCamera)
{
if (vEye.Z >= midZ && vEye.X <= midX)
{
//z movement
vEye.Z -= moveSpeed * elapsedTime;
//vLook.Z -= elapsedTime;
//x movement
vEye.X -= moveSpeed * elapsedTime;
//vLook.X += elapsedTime;
}
else if (vEye.Z <= midZ && vEye.X <= midX)
{
vEye.Z -= moveSpeed * elapsedTime;
//vLook.Z += elapsedTime;
vEye.X += moveSpeed * elapsedTime;
//vLook.X -= elapsedTime;
}
else if (vEye.Z <= midZ && vEye.X >= midX)
{
vEye.Z += moveSpeed * elapsedTime;
//vLook.Z -= elapsedTime;
vEye.X += moveSpeed * elapsedTime;
//vLook.X -= elapsedTime;
}
else
{
vEye.Z += moveSpeed * elapsedTime;
//vLook.Z -= elapsedTime;
vEye.X -= moveSpeed * elapsedTime;
//vLook.X += elapsedTime;
}
}