Enix591

All right. I'm trying to make a free roam camera. A Camera i can use to inspect my 3d world. So far, in my world, i have a very small sky box, and two even smaller meshes inside of it. Everything is fine except the camera class.

Currently the camera is positioned at {0,0,-50} and has a target of {0,0,0}.

In the beginning of the app im outside of the skybox looking straight at it, when i press left or right, the box will move to the left of the screen, then to the right, and back. What i want to see is the skybox leaving the screen, then eventually coming back on the other side.

Here is my function to rotate the camera(Move its target around it.):

public void RotateYCamera(float amount)

{

Matrix tMatrix = new Matrix();

tMatrix.RotateY(amount);

Target.TransformCoordinate(tMatrix);

}

Note: Im using mdx and c#.




Re: Game Technologies: DirectX 101 Free Roam Camera Problems

Robert Dunlop

To rotate the camera in this way (by rotating the target around the camera), you need to transform a vector that is relative to the camera as the origin. You example camera setup quickly bears out that the above would not work - no matter how much you rotate 0,0,0 around the y axis, it will still be 0,0,0.

Instead, you need to convert the target into an offset from the camera location, transform it, then calculate a new target location from the transformed offset, something like:

Vector3 vLook = Target - Eye;
vLook.TransformCoordinate(tMatrix);
Target = Eye + vLook;





Re: Game Technologies: DirectX 101 Free Roam Camera Problems

Enix591

Thanks, that fixed the problem.