> This solution only solves half of my problem. When the window is
> resized, it will still screw stuff up. I also have another issue where
> I want to click on the screen and display on object where the user
> clicked. However, if the user clicks too close to the edge of the
> window I want to make sure the whole object still is displayed.

> >Is there a way to find out if an object is in the current View or not?
> >I have an object that I would like to stay on the edge of the screen no
> >matter how I resize the window or move the viewpoint. Is there a better
> >or different way to do what I am wanting to do?

You can use Canvas3D.getVworldProjection() to obtain the transform from
the vworld viewing frustum to canonical clipping coordinates ([-1 .. +1]
in X, Y, Z).  So you can take your object in world coordinates,
transform its bounds by the projection matrix, divide X, Y, Z by W, and
compare the transformed bounds to clipping coordinate bounds.  You'll
have to use the Vector4f or Vector4d variants of Transform3D.transform()
to handle W correctly.

For more efficiency, you can compare X, Y, and Z to W before the
division (X, Y, and Z are in the range [-W .. +W] if the point is
visible) to determine if the point is in the view frustum.  This is how
the graphics hardware does it.

The only problem with the above is that you'll get a 1-frame latency
between your current view platform position and the result obtained by
getVworldProjection().  This might be an issue if you're continually
moving the view from frame to frame.  To workaround this problem, use
com.sun.j3d.utils.universe.ViewInfo.

ViewInfo also provides methods to fix the apparent location of an object
relative to physical coordinate systems such as eye, coexistence
coordinates, or image plate coordinates.

-- 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