Thats great!
However, in my case, whenever I'm using parallel projection, the code merely moves the image into the center
of the frame, and does not resize it to fit the frame.
I tried adjusting the radius but it results in different sizes in the 2 different projections.
What range of values would be good for the radius?
Do you have any idea what else is the cause for this?
 
Regards,
Jasmine
 
 
 
----- Original Message -----
Sent: Thursday, March 20, 2003 7:14 PM
Subject: Re: [JAVA3D] Fit image in frame

 
Jasmine,
 
Honestly speaking, I never used parallel projection. So, I tried it out, changed the ProjectionPolicy and it worked as well with parallel projections.
 
Regards, Dirk
----- Original Message -----
Sent: Thursday, March 20, 2003 6:58 AM
Subject: Re: [JAVA3D] Fit image in frame

Hi Dirk,
 
I have tried the codes, and it works well for perspective projection. Is there any chance that this method works for parallel projection as well?
 
 
Regards,
Jasmine
 
----- 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

Reply via email to