0

This function is supposed to give me the exact size of my near clipping plane.

public Vector2 NearplaneSize
    {
        get
        {
            float w = 2 * Mathf.Tan(Mathf.Deg2Rad(Fov) / 2) * ZNear;
            return new Vector2(w, w / AspectRatio);
        }
    }

I'm creating a plane like this:

Vector2 s = cam.NearplaneSize;
Mesh = PrimitiveFactory.CreatePlane(s.X / -2, s.Y / -2, -(cam.ZNear + 0.1f), s.X, s.Y, 1, 1, Quaternion.FromAxisAngle(Vector3.UnitX, Mathf.Deg2Rad(90)));

in front of the camera, but its slightly larger than half the screen. So obviously the calculation is wrong. I can't seem to find a better formula though.

Any ideas? Thanks

pixartist
  • 1,137
  • 2
  • 18
  • 40

1 Answers1

1

I don't know OpenTK, but due to old gluPerspective call, "Fov" is generally understood as fov y, not fovx.

So I assume that

float h = 2 * Mathf.Tan(Mathf.Deg2Rad(Fov) / 2) * ZNear;
return new Vector2(h * AspectRatio, h);

should do the trick.

Solkar
  • 1,228
  • 12
  • 22