Hi:
There is very useful code in the archives that helped me (a search for
BoundingSphere or getRadius should do). The help in the archives suggests
that the content branch needs to be live, but we didn't find that to be
necessary:
This is a snippet of what we do:
private static final float EYE_DISTANCE = 5.0f;
private void autoScale() {
BoundingSphere bounds = (BoundingSphere)contentBranch.getBounds();
if(bounds.getRadius() > 0.0) {
double screenRadius = EYE_DISTANCE *
Math.tan(universe.getViewer().getView().getFieldOfView() / 2.0);
double scale = 0.6 * screenRadius / bounds.getRadius();
// Get the centre of the content.
Point3d centre = new Point3d();
bounds.getCenter(centre);
if(!isTranslateToCentre) {
centre.x = 0.0;
centre.y = 0.0;
}
// Centre and scale the content branch to display at the correct size
on the screen.
Transform3D transform = new Transform3D();
transform.setScale(scale);
transform.setTranslation(
new Vector3d(-centre.x * scale, -centre.y * scale, -centre.z *
scale));
scaleNode.setTransform(transform);
}
}
Regards,
Geoff.
----- Original Message -----
From: "Daniel Moscoso" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, April 27, 2001 12:27 AM
Subject: [JAVA3D] Automatic calculation of scale
Hi all !!
I'm developing applets that use loaders for OBJ and 3DS files. The scale I
have to set to the loaded BranchGroups of the files always depend on the
model.
Is there any way to calculate the scale to represent a model to fit exactly
the Canvas3D ?
Thanks in advanced !!
Dani
--
Diese E-Mail enth�lt vertrauliche und/oder rechtlich gesch�tzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail
irrt�mlich erhalten haben, informieren Sie bitte sofort den Absender und
vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte
Weitergabe dieser Mail ist nicht gestattet.
This e-mail may contain confidential and/or privileged information. If you
are not the intended recipient (or have received this e-mail in error)
please notify the sender immediately and destroy this e-mail. Any
unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
===========================================================================
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".