Display field of view

Hello all,

I am preparing a test / demo of an adventure game like Alone

in the Dark series. I need to know what a camera is seeing in order
to set a rectangle tied to that camera. Then, when the actor enters
in that rectangle the engine will change the current camera position
and orientation to the camera related to the rectangle.

The rectangle will be on the ground "virtually". I would calculate

the intersection between the view frustrum and the ground in order
to obtain the polygon vertex. I believe is called the view frustrum (?).

Is there any way to visualize the field of view of a len?.

Ideas, comments, criticism are welcome.



In Panda3D 1.1, you can do camera.node().showFrustum() to visualize the camera’s frustum (use hideFrustum() to turn it off again). You can also do this in 1.0.5, but there’s a few more calls you have to make.

You can also use camera.node().isInView(Point3(x, y, z)) to ask if a particular point is within the frustum of the camera. You should translate this point into the space of the camera first, with something like this:

point = camera.getRelativePoint(avatar, Point3(0, 0, 5))
if camera.node().isInView(point):
  print "head in view"