I have addressed both of your problems in my application. The first can be
don using my modified behaviors. Look at this page:
http://www.sigda.org/Eric/java3d/behaviors/index.htm
Second, you can set the translate/zoom/rotate factors using the setFactor()
method of the behaviors.
I used the callback methods and did it there. Here is my callback method:
static class myPickingCallbackClass extends Object implements
PickingCallback
{
public void transformChanged(int type, TransformGroup tg)
{
// Must test to see if a TransformGroup is not null
before calling
// loadStarProperties Method.
// Otherwise get a nullpointer exception in Method
if ((tg != null) && !(usingViewer) &&
!CheckboxMenuItemToolsOrbitStar.getState())
{
// usingViewer = false;
previousStar = currentStar;
SetCurrentStarFromTransformGroup(tg);
loadStarProperties(currentStar);
double distanceToObject =
findDistanceToObject(currentStar,meViewer);
(pickTranslate.translate).setFactor((0.001334)*distanceToObject);
//(0.02) 0.001334 * distance 15
(pickRotate.drag).setFactor(0.03);
(pickZoom.zoom).setFactor((0.002667)*distanceToObject);
// (0.04) 0.002667 * distance 15
notSaved = true; // Set to true
since just made a change
}
}
}
Basically all that I do is called a method called findDistanceToObject()
and pass it the transform group of the object I am moving and the viewers
transformgroup. It then uses the Pythagorean theorem to find the
distance. I then use that value to set the translate and zoom factors of
the behaviors.
The only downside to this method is that if something is very far away and
the zoom and translate factors have been set higher as a result of a zoom
or translate, when you click on a closer object to zoom or translate, its
initial motion is large but then it quickly sets the Factor to something
more appropriate for a close object.
I suppose that I could have modified the behaviors more to handle this
directly in them before the translate / zoom occurs but I didn't . Maybe a
later improvement.
At 11:13 AM 02/07/2001 +0000, you wrote:
>Hi,
>I am using the MouseRotate, MouseZoom and MouseTranslate from the sun
>package.
>
>1)
>when I zoom an object it's not moving away perpendiculare to the viewer,
>
>that mean when I zoom an object I have to translate it to the center so
>I can fully see it again . I suspect that has to do with the projection
>Mode (perspective oder orthogonal) how can I fix this?.(I am translating
>
>my object to the center to view them).
>
>2) When I translate my objects, they sometime move quickly sometime not.
>
>I know I can set the translation factor, but as my objects are very
>different in their bounding box, setting the translation factor will do
>only for few of them. Is there away to solve this ? do I have to set the
>
>Translation factor at run time?(depending on the bouding box?).
>
>thanks for any help?
>Mohammed
>
>===========================================================================
>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".
***********************************************************************
Eric Reiss
Manager MEMS Lab
Swanson New Product Incubator
School of Engineering - University of Pittsburgh
3700 O'Hara Street
647 Benedum Hall
Pittsburgh, PA 15261
Phone: 412-624-9696
Email: [EMAIL PROTECTED]
http://www.sigda.acm.org/Eric/
***********************************************************************
===========================================================================
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".