MutterOberin's picture

Confusing Matrix4.Perspective


I just want to orbit around the center (0,0,0) so i tried it in this way first:

private void MakeCam()
            aspect = (float)w / (float)h;
            if (orthoView)
                GL.Ortho(-r * aspect, r * aspect, -r, r, -100, 100);
                //Matrix4 perspective = Matrix4.Perspective(60, aspect, 1, 10000);
                //Matrix4 perspective = Matrix4.CreatePerspectiveFieldOfView(60, aspect, 1, 1000);
                Matrix4 perspective = Matrix4.CreatePerspectiveOffCenter(-r * aspect, r* aspect, -r, r, 1, 1000);
               Matrix4 lookat = Matrix4.LookAt(0, -20, 10, 0, 0, 0, 0, 0, 1);
                GL.MultMatrix(ref perspective);
                GL.MultMatrix(ref lookat);
                //GL.LoadMatrix(ref lookat);

This is just a "orientation test" ! The Cam should be 10 in z (z is up axis and coord sys is right handed) and x axis should point to the right ...

If I use Matrix4.Perspective everything is upside down!!
If I use Matrix4.CreatePerspectiveFieldOfView there is a big red cross over OpenGL Panel !!
And the OffCenter stuff is kind of ok.

So I'm asking myself whats wrong with the perspective and CreatePerspective stuff

Kind Regards


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Inertia's picture

Be careful not to confuse radians and degrees (the inline docu should clarify what is expected and MathHelper.DegreeToRadians() does the conversion)

If that isn't helping, maybe tutorials about Cameras can.
Assuming you speak german:
The red book:

MutterOberin's picture

Thx a lot!

This was the problem. OpenGL and Tao use degrees, I think, so i made this mistake...