|
It
should work! I am using basicaly the same mechanism, except that I'm
preparing several views from which you can look at the object. The one you
described is only looking along z direction from + to -.
Here
is another algorithm where you can also specify rotation
angles rx, ry, rz in radians. The values 0, 0, 0
generates the same transform as in your algorithm. Try experimenting with
various angles to see which one fits you best. Some tips: if the upward
direction for your model is along +z axis, you should try rx = Math.PI / 3; ry =
0.0; rz = Math.PI / 4. If the upward direction is along +y axis, then
try rx = -Math.PI / 6; ry = Math.PI / 4; rz
= 0.0
BoundingSphere
fit=(BoundingSphere)objRoot.getBounds();
double
rad=fit.getRadius();
Point3d ctr=new
Point3d();
fit.getCenter(ctr);
View
view=universe.getViewer().getView();
double
viewDistance=2.0*rad/Math.tan(View.getFieldofView()/2.0);
Transform3D dist = new Transform3D(); dist.set(new Vector3d(0, 0, viewDistance)); Transform3D rotation = new Transform3D(); rotation.setEuler(new Vector3d(rx, ry, rz)); rotation.mul(dist); Transform3D viewTrf = new Transform3D(); viewTrf.set(new Vector3d(center.x, center.y, center.z)); viewTrf.mul(rotation); TransformGroup
vpTrans=universe.getViewingPlatform().getViewPlatformTransform();
vpTrans.setTransform(viewTrf);
Cheers,
Florin
|
