Search in sources :

Example 1 with BoundingVolume

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();
    }
}
Also used : BoundingVolume(com.ardor3d.bounding.BoundingVolume)

Example 2 with BoundingVolume

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;
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) BoundingBox(com.ardor3d.bounding.BoundingBox) BoundingVolume(com.ardor3d.bounding.BoundingVolume) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Matrix3(com.ardor3d.math.Matrix3)

Aggregations

BoundingVolume (com.ardor3d.bounding.BoundingVolume)2 BoundingBox (com.ardor3d.bounding.BoundingBox)1 Matrix3 (com.ardor3d.math.Matrix3)1 Vector3 (com.ardor3d.math.Vector3)1 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)1