Murat, Try this code (which I adapted from J3DFly):
/** * Set the transform so that everything inside the BoundingSphere is * visible within the view frustum */ private void setViewpoint( TransformGroup tg, BoundingSphere sceneBounds, View view ) { Transform3D viewTrans = new Transform3D(); // point the view at the center of the object Point3d center = new Point3d(); sceneBounds.getCenter(center); double radius = sceneBounds.getRadius(); Point3d eyePos = new Point3d(center); Vector3d up = new Vector3d(); // pull the eye back far enough to see the whole object double eyeDist = radius / Math.tan(view.getFieldOfView() / 2.0); int showAllAxis = 2; // fudge to look down Z axis switch( showAllAxis ) { case 0 : eyePos.x += eyeDist; up.y = 1; break; case 1 : eyePos.y += eyeDist; up.z = -1; break; case 2 : eyePos.z += eyeDist; up.y = 1; break; case 3 : eyePos.x -= eyeDist; up.y = 1; break; case 4 : eyePos.y -= eyeDist; up.z = -1; break; case 5 : eyePos.z -= eyeDist; up.y = 1; break; } viewTrans.setIdentity(); viewTrans.lookAt( eyePos, center, up ); viewTrans.invert(); // If we have moved the model behind the back clip distance then change // the back clip distance if (view.getBackClipDistance()<eyeDist) { view.setBackClipDistance( eyeDist ); view.setFrontClipDistance(eyeDist/3000); System.out.println("Back Clip reset to "+eyeDist); } tg.setTransform(viewTrans); // set the view transform } // end setViewpoint() Good Luck. - John Wright Starfire Research "A. Murat Tanyer" wrote: > > Hi all, > > I'm looking for some help or some code examples. > > The problem is this: I loaded an object from VRML to my Java3d scene. > How can I find a good point for the 'viewer' to capture all of the image > in the scene. > > The bounding sphere of the scene has a radius 'r' and a center point > (x,y,z). > > I really got stuck with this for several days. I think I need your help. > > Thanking you in advance for your help. > > Murat > > =========================================================================== > 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".