This project is read-only.

Orthographic camera

Dec 2, 2009 at 9:09 PM

Hey StatusUnknown,

Thank you for your hard work on Xen and keep up great work!

Here is 3d world begginer so sorry for stupid questions or ideas ;-) I was actually inspired by nice article about my favorite game series

I was trying to get orthographic camera working and used Camera3D in following way (in Initialise()):

camera = new Camera3D();
camera.Position = new Vector3(0,22,60);
camera.Projection.NearClip = 1;
camera.Projection.FarClip = 1000f;
camera.Projection.FieldOfView = MathHelper.PiOver4;

camera.Projection.Orthographic = true;
camera.Projection.Region = new Vector4(0, 0, 1024.0f, 768.0f);
camera.LookAt(Vector3.Zero, cameraPosition, Vector3.Up);

What I got was just region 0,0,1,1 (as it is correctly noted in comment ;-))

After checking xen sources, I might have found the problem in Projection.cs.

protected virtual void CalculateProjectionMatrix(out Matrix projection)
if (orthographic)
	Matrix.CreateOrthographic(1, 1, near, far, out projection);

It seems to me Region property is not taken in account. Am I right? I might just have different understanding of Region...

Thank you for your response.


Dec 2, 2009 at 9:46 PM

Hmm, after experimenting for a while I found it works correctly. Sorry for confusion.

cameraPosition = new Vector3(200,20,50);
camera.Projection.Region = new Vector4(-10, -10, 10, 10);


PS: camera coordinates are just some random test which allows to see anything;-) , not trimetric one...