> Date:         Mon, 30 Dec 2002 13:38:44 -0500
> From: Roy Duffy <[EMAIL PROTECTED]>
>
> I'd like to be able to get the current field of view in my application
> but it always gives me the same value and I don't understand why.  I'm
> using a WindowEyepointPolicy of View.RELATIVE_TO_WINDOW and the
> WindowResizePolicy and WindowMovementPolicy are left to default.  With
> this configuration, when I resize the window, it shows more or less of
> the scene, but all objects stay the same size, which is exactly what I
> want.  But when I call View.getFieldOfView(), it always reports the same
> number (0.78...) and I don't understand how this is possible.
> [...]

getFieldOfView() returns only the user-set value or the default, so it's valid
only when the eyepoint policy is RELATIVE_TO_FIELD_OF_VIEW.  The default field
of view is 45 degrees (about 0.785398).

There isn't a method for directly obtaining the effective field of view since
field of view doesn't make much sense for some viewing configurations.  For
RELATIVE_TO_FIELD_OF_VIEW you can get the current value from getFieldOfView()
and for RELATIVE_TO_WINDOW you can derive it from the physical eye position and
the physical width of the window.

To get the physical eye position, call Canvas3D.getCenterEyeInImagePlate().
This is the position of the center eye in meters relative to the origin of the
screen.  With the RELATIVE_TO_WINDOW policy only the Z component of the center
eye is used (the X and Y components are set to the middle of the window).  Use
Canvas3D.getPhysicalWidth() to get the width of the canvas in meters.  Then
compute the field of view as:

  2.0 * atan(0.5 * canvasWidth / eyeZ)

The RELATIVE_TO_FIELD_OF_VIEW policy automatically sets the physical eye
position X and Y components centered in the window, with a Z offset that
produces the desired field of view.

Note that we're talking about physical eye positions here -- by default, the
position of the eye in virtual coordinates is the origin of the view platform,
so moving the eye around in physical coordinates only alters the projection.

> So I'm partly writing this out of simple curiosity about what actually
> happens when I resize the window.  But I also really need to find the
> actual visible field of view in my window.

Java 3D doesn't use a camera as the view model, so a lot can happen when
resizing the window.  Java 3D constructs a view from the physical position of
the user's eyes relative to the physical positions of the image plates.  It
then uses a view platform to position and orient that physical configuration
into the virtual world and from there computes the correct projections of the
virtual world onto the physical image plates.

This was done in order to abstract display environments such as caves,
head-mounted displays, multi-screen walls, and desktop windows into a unified
view model.  But it does mean that simple actions such as resizing a window can
have effects on a lot of different things such as scale, eye position,
projections, and clipping.  Java 3D by default tries to emulate the camera
model as much as possible.

The documentation is confusing but mostly correct.  Look over the view model
stuff in the Specification and javadoc -- if you have specific questions I'll
be happy to help you decode it.

-- Mark Hood

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA3D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to