Hi ,

once you have the boundingbox and the radius try the following


 // SceneGroupBounds is your BoundingBox
Point3d center = new Point3d();
 SceneGroupBounds.getCenter(center);
 double radius = SceneGroupBounds.getRadius();
 Vector3d temp = new Vector3d(center);

Transform3D viewTrans = new Transform3D();
 Transform3D eyeTrans = new Transform3D();

 viewTrans.set(temp);

 // pull the eye back far enough to see the whole object
 double eyeDist = 1.4*radius / Math.tan(cam.getview().getFieldOfView() / 2.0);
temp.x=0.0;
temp.y=0.0;
 temp.z = eyeDist;

 eyeTrans.set(temp);
 viewTrans.mul(eyeTrans);

 // set the view transform
 cam.getTrans().setTransform(viewTrans); //cam.getTrans() return the TG of the
viewplatform


you get your object in the center but you still will have my probleme when you
rotate either your view or your object.


Mohammed

Thijs Maenhout schrieb:

> Hi ,
> I'am having kind of the same problem as you:
> I want to make the scene (consisting of transformgroups, behaviors and
> shape3ds) fit into the canvas3d.  Therefore I have to change the
> viewTransformation (translate and rotate it).  I'am able to get the center
> and the radius of my scene (with a spherbounding).  But i can't figure out
> how i have to use this information to fit my object.  Because I'am loading
> VRML files , I don't want to translate my objects to the origin.
>
> Any help would be appreciated.  TNX A LOT
>
> -----Original Message-----
> From: Mohammed Akacem [mailto:[EMAIL PROTECTED]]
> Sent: dinsdag 24 oktober 2000 15:27
> To: [EMAIL PROTECTED]
> Subject: Re: [JAVA3D] Rotation Matrix
>
> Hi Boris,
>
> my point is that I don't want to translate the object to the origine because
> my
> objects kann have 500.000 triangles or more( and that will cost me too much
> time). Until now I have translated my objects to the origine and it works
> fine(
> and that is done with the A Matrix you suggest I should use). What I was
> thinking about is(I don't know if this is possible) to translate the
> coordinate
> origin to the center of the boundingbox und rotate my objects(using the
> MouseRoate behavior).
>
> Mohammed
>
> Epelman Boris schrieb:
>
> > Hi!
> >
> > You need to perform the following transformation:
> >
> > T*A*R*A^(-1)*T^(-1)*M
> > where
> >
> > M is your object
> > T is the object's transform that holds all bthe transformations performed
> >   on the object till now.
> > A this matrix brings the center of the object to (0,0,0) if the object was
> >   not originally created at the origin.
> > R your rotation matrix
> >
> > Tell me if it helped.
> >
> > Boris
> >
> >
> ===========================================================================
> > 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".
>
> ===========================================================================
> 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".

Reply via email to