use of com.ardor3d.bounding.BoundingVolume in project energy3d by concord-consortium.
the class Heliodon method updateSize.
public void updateSize() {
Scene.getRoot().updateWorldBound(true);
final BoundingVolume bounds = Scene.getRoot().getWorldBound();
if (bounds == null) {
root.setScale(1);
} else {
final double scale = (Util.findBoundLength(bounds) / 2.0 + bounds.getCenter().length()) / 5.0;
System.out.println("Heliodon scale = " + scale);
if (!Double.isInfinite(scale)) {
root.setScale(scale);
}
}
root.updateGeometricState(0);
if (SceneManager.getInstance() != null) {
SceneManager.getInstance().refresh();
}
}
use of com.ardor3d.bounding.BoundingVolume in project energy3d by concord-consortium.
the class CameraControl method getCurrentExtent.
// the extent that depends on the camera orientation (not a perfect solution)
private static double getCurrentExtent() {
double extent = 10;
final BoundingVolume volume = Scene.getRoot().getWorldBound();
if (volume instanceof BoundingBox) {
final BoundingBox box = (BoundingBox) volume;
final ReadOnlyVector3 cameraDirection = SceneManager.getInstance().getCamera().getDirection();
final Vector3 e1 = box.getExtent(null);
final double extent1 = Math.abs(e1.cross(cameraDirection, null).length());
final Vector3 e2 = new Matrix3().applyRotationZ(Math.PI / 2).applyPost(e1, null);
final double extent2 = Math.abs(e2.cross(cameraDirection, null).length());
extent = 0.45 * (extent1 + extent2);
}
return extent;
}
Aggregations