I actually solved it myself. But it isn't really smart done.
I think there should be some method that's more obvious.
Ole Vilmann
Code to scale is included and you should use the getMinMaxVal
function included in mail from yesterday (mail with subject:
"Re: [JAVA3D] Extacting Shape3D's from the FltLoader"
Please make a remark, that I have rotated the coordinetes during
input, therefore I have the z - y switch of axis:
BranchGroup brGrp = (BranchGroup)switchGroup.getChild(i);
System.out.println("minmax: Number of children of BranchGroup =
" + brGrp.numChildren());
TransformGroup trGrp = (TransformGroup)brGrp.getChild(0);
Enumeration enum = brGrp.getAllChildren();
MinMaxVal minmax = new MinMaxVal();
getMinMaxVal(enum,minmax);
System.out.println("Min :" + minmax.min[0] + " " + minmax.min[1]
+ " "+ minmax.min[2]);
System.out.println("Max :" + minmax.max[0] + " " + minmax.max[1]
+ " "+ minmax.max[2]);
double x_mid = (minmax.max[0] + minmax.min[0])*0.5;
double y_mid = (minmax.max[1] + minmax.min[1])*0.5;
double z_mid = (minmax.max[2] + minmax.min[2])*0.5;
System.out.println("Mid :" + x_mid + " " + y_mid + " "+ z_mid);
Transform3D trans = new Transform3D();
trGrp.getTransform(trans);
System.out.println("minmax: originally transform = " + trans);
Vector3d translation = new Vector3d();
trans.get(translation);
// trans.setTranslation(translation);
double scale_val = 0.3;
double old_scale = trans.getScale();
trans.setScale(scale_val);
System.out.println("minmax: old_scale = " + old_scale + "
scale_val = " + scale_val);
System.out.println("minmax: translation = " + x_mid * (old_scale
- scale_val) + " " +
y_mid * (old_scale - scale_val) + " " + z_mid
* (old_scale - scale_val) + " " );
translation.x += x_mid * (old_scale - scale_val);
translation.y += z_mid * (old_scale - scale_val);
translation.z -= y_mid * (old_scale - scale_val);
trans.setTranslation(translation);
trGrp.setTransform(trans);
System.out.println("minmax: modified transform = " + trans);
-----Original Message-----
From: Magnus Olofsson [mailto:[EMAIL PROTECTED]]
Sent: 9. januar 2001 08:58
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Problems with scaling
Dear all.
I have tried to do the same thing but failed. Probably due to my own
incompetence.
Any one out there that have a snippet of code to share?
/Magnus
===========================================================================
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".