John,
For what it is worth I solved the problem by setting up two consecutive
TransformGroups in my scene graph.
sceneTG = new TransformGroup(sceneT3D);
sceneTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
bg.addChild(sceneTG);
InitMouseBehavior(sceneTG);
Transform3D bodyT3D = new Transform3D();
bodyTG = new TransformGroup(bodyT3D);
bodyTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
sceneTG.addChild(bodyTG);
Note that my InitMouseBehavior uses the standard rotate, zoom, and pan
behaviors just like your code (note that your objTransform = my sceneTG).
In order to center my objects I capture a bounding sphere for the objects of
interest and translate my objects to be at the center of bounding sphere
(using bodyTG). Then I "back-up" the sceneTG by translating according to
the radius.
public void Center(SceneComponent sc)
{
BoundingSphere b = (BoundingSphere)
sc.GetRootNode().getBounds();
Point3d mid = new Point3d();
b.getCenter(mid);
Vector3d trans = new Vector3d(-mid.x, -mid.y, -mid.z);
Transform3D t3d = new Transform3D();
t3d.setTranslation(trans);
bodyTG.setTransform(t3d);
t3d = new Transform3D();
t3d.set(new Vector3d(0.0,0.0,-b.getRadius()));
sceneTG.setTransform(t3d);
}
This allows me the luxury of not messing with the viewing platform stuff
(which I'm still a little hazy on). I would be interested in hearing how
others have solved this problem
John
----- Original Message -----
From: Dickinson, John <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, January 07, 2000 1:44 PM
Subject: [JAVA3D] Need to view entire object at startup.
> As in the interactive java3d tutorials, I have created an interactive
object
> viewer using the mouse interactive classes (e.g.:
>
> MouseRotate myMouseRotate = new MouseRotate();
> myMouseRotate.setTransformGroup(objTransform);
> myMouseRotate.setSchedulingBounds(new BoundingSphere());
> objRoot.addChild(myMouseRotate);
>
> MouseTranslate myMouseTranslate = new MouseTranslate();
> myMouseTranslate.setTransformGroup(objTransform);
> myMouseTranslate.setSchedulingBounds(new BoundingSphere());
> objRoot.addChild(myMouseTranslate);
>
> MouseZoom myMouseZoom = new MouseZoom();
> myMouseZoom.setTransformGroup(objTransform);
> myMouseZoom.setSchedulingBounds(new BoundingSphere());
> objRoot.addChild(myMouseZoom);
> )
>
> I center my objects on the origin of objRoot so that rotations etc. occur
on
> the spot and don't swing the object wildly through space but... given that
> the objects can be of very differing scales I am not sure how to arrange
so
> that the object fills the screen at start up.
>
> The code:
> // method returns a branchgroup scene to view the objRoot object
> BranchGroup scene = createSceneGraph(filename);
> // SimpleUniverse is a Convenience Utility class
> SimpleUniverse simpleU = new SimpleUniverse(canvas3D);
> // This will move the ViewPlatform back a bit so the
> // objects in the scene can be viewed.
> simpleU.getViewingPlatform().setNominalViewingTransform();
> // added to ensure objects wouldn't get clipped in background so soon
> canvas3D.getView().setBackClipDistance(1000.00d);
> simpleU.addBranchGraph(scene);
>
> Creates a view of the object in a universe space but the
> setNominalViewingTransform() usually isn't far enough away from the
objects
> to allow a good view.
>
> Given that I know the objects bounding box, how do I use this information
to
> set an initial zoom factor or create an initial viewing platform transfrom
> to get a good view of the whole object?
>
> I hope this isn't too confusing.
> John
>
>
===========================================================================
> 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".