The mouse rotator, zoom, and translate classes as they come in the Java3D are
not very practical. As you observe, the rotator rotates about the origin which may
have no particular significance, the zoom zooms about the origin, and the translate
translates with an arbitrary scale. It is possible to do the following:
1) Have the translator translate such that the image follows the mouse. This always
works
without difficulty provided that you insert the transformation in the appropriate
position in the Java3D data structures. In my opinion, a mouse translator to do this
should be included in the Java3D distribution since it is so straightforward and
so useful. If I can get permission to do so from my employer and anyone is interested,
I will post code to do this.
2) Have the mouse-zoom zoom about the initial click point and the the rotator rotate
about
a line passing through the initial click point. The difficulty with both of these
schemes
is that there is in general no good way to map from the 2-D screen coordinates to
the 3-D coordinates that you need to set up the transformations properly. Options
include:
a) Having the initial click actually pick some object and get a 3-D position from that
object.
This works only if there is a pickable object at the click point.
b) Pick a nominal depth point, say the midpoint of the 3-D world, to give you an
unambiguous 2-D to 3-D map. This can work o.k. if you don't need an exact 3-D origin
for the transformations and the depth is not huge compared to the width and height.
c) Use a 3-D mouse or simulate 3-D mouse behavior in some way.
d) Invert the 3-D to 2-D transform and hope for the best. Curiously, this actually
seems to work fairly well in practice although I could not tell you exactly what is
the result in general. Mathematically, this requires inverting a singular matrix,
but Java3D is able to do it anyway.
Identifying a point in 3-space with a 2-D screen and a 2-D mouse is a major
headache. I hope someone solves this problem soon!!
Jim Schatzman
At 09:28 PM 10/10/2000 +0000, you wrote:
> I have a problem using MouseRotate, when I use it, I do not know around
>which point it is rotating if I hold on the mouse left button, the object
>rotates without my control,sometimes, it is out of the screen, it is better
>to assign a fixed point around which the object rotates. How can I setup the
>rotation point to a fixed position,so that the object will rotate around
>that point?
>
>The following is part of the code I used:
> MouseRotate behavior = new MouseRotate();
> behavior.setTransformGroup(objTrans);
> behavior.setFactor(0.001);
> objTrans.addChild(behavior);
> behavior.setSchedulingBounds(bounds);
>
>
>
> Thanks.
>
>David
>_________________________________________________________________________
>Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.
>
>Share information about yourself, create your own public profile at
>http://profiles.msn.com.
>
>===========================================================================
>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".
===========================================================================
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".