device.Transform.World = Matrix.Identity;
Vector3 cameraPosition = new Vector3(0.0f, 0.0f, mousePos.Z);
Vector3 cameraTarget = new Vector3(0.0f, 0.0f, 0.0f);
device.Transform.View = Matrix.LookAtLH(cameraPosition, cameraTarget, new Vector3( 0.0f, 1.0f, 0.0f ) );
// Doesn't work
device.Transform.Projection = Matrix.OrthoLH(Width, Height, 1.0f, 100.0f);
// Works
float ratio = ( (float)Width / (float) Height);
device.Transform.Projection = Matrix.PerspectiveFovLH( (float)(Math.PI / 4), ratio, 1.0f, 100.0f );
LookAtLH not working with OrthoLH
Hi to all,
I've a problem with the view and projection matrix.
I've set the view matrix so I can zoom (change the camera Z posizion) using the mouse wheel.
It works if I set the projection matrix using PerspectiveFovLH, but it stop working if I use OrthoLH.
But I want it to be orthogonally.
Ortho projection doesn't depend on the z coordinate. You must scale the objects to get the zoom effect when using an ortho projection.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement