----- Original Message -----
Sent: Wednesday, March 19, 2003 6:39
PM
Subject: Re: [JAVA3D] Fit image in
frame
Hi Jasmine,
I got good results
with:
BoundingSphere
fit=(BoundingSphere)objRoot.getBounds();
double
rad=fit.getRadius();
Point3d ctr=new
Point3d();
fit.getCenter(ctr);
View
view=universe.getViewer().getView();
Vector3d viewvector=new
Vector3d(ctr);
double
viewDistance=2.0*rad/Math.tan(View.getFieldofView()/2.0);
viewVector.z=viewDistance;
Transform3D viewTrf=new
Transform3D();
viewTrf.set(viewVector);
TransformGroup
vpTrans=universe.getViewingPlatform().getViewPlatformTransform();
vpTrans.setTransform(viewTrf);
This will shift your geometry to the
center of your canvas. After this you may set the radius of "fit" to your
liking (usually people like to have at least some space between the frame
borders and the geometry).
Please, give it a try. I am interested
to know if it worked for you as well.
Thanks, Dirk
----- Original Message -----
Sent: Wednesday, March 19, 2003 5:47
AM
Subject: [JAVA3D] Fit image in
frame
Hi all,
i am doing a program in which there is a
command. When selected, the displayed image has to be scaled to fit
it nicely into the frame. My question is that how do I knowhow
big/small I have to scale the image in order for it to fit in the
frame?
==
Jasmine
Kwok