Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - JonnyDee

Pages: [1]
Support / Orbiting camera
« on: August 26, 2003, 05:20:15 am »

I am currently trying to figure out how to rotate the camera around an object.  The effect i'm looking for is for the player object to always be maintained in the center of the view, whilst the camera orbits around the player and the player rotates so the camera is always looking at the same side of the player.  I have tried to use a dummy object which rotates around the player to give the coords to move the camera to, like this:

playerRotation = (float)(xDif * rotationMultiplier);

// Rotate the player and cameraHolder
cameraHolder.setRotationPivot(new SimpleVector(sphereX, sphereY, sphereZ));

cameraX = cameraHolder.getCenter().x;
cameraY = cameraHolder.getCenter().y;
cameraZ = cameraHolder.getCenter().z;

// Move the camera back to the cameraHolder and look at the player
  new SimpleVector(
theWorld.getCamera().lookAt(new SimpleVector(sphereX, sphereY, sphereZ));

Whilst debugging this code, i've found that cameraX, Y and Z don't change from the initial values.  I can see the player rotating and if I use align to align the camera to the player, the camera rotates when I move the mouse, as it should, but I can no longer see the player!  Am I using getCenter() incorrectly?  I tried using calcCenter() before getting the cameraHolder center to reset the camera position, but this sets cameraX, Y and Z to NaN.

Any help would be appriciated!



Pages: [1]