Sign in to follow this  
WaveMax

LookAtLH not working with OrthoLH

Recommended Posts

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.
	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 );


But I want it to be orthogonally.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ortho projection doesn't depend on the z coordinate. You must scale the objects to get the zoom effect when using an ortho projection.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this