Search in sources :

Example 1 with Plane

use of com.ardor3d.math.Plane in project energy3d by concord-consortium.

the class CustomRoof method setPreviewPoint.

@Override
public void setPreviewPoint(final int x, final int y) {
    final Foundation foundation = getTopContainer();
    if (foundation != null && foundation.getLockEdit()) {
        return;
    }
    final EditState editState = new EditState();
    if (editPointIndex == -1) {
        recalculateEditPoints = true;
        pickContainer(x, y, Wall.class);
    } else if (editPointIndex == 0) {
        final ReadOnlyVector3 base = getCenter();
        final Vector3 p = Util.closestPoint(base, Vector3.UNIT_Z, x, y);
        if (p == null) {
            return;
        }
        snapToGrid(p, getAbsPoint(editPointIndex), getGridSize());
        height = Math.max(0, p.getZ() - container.getPoints().get(1).getZ());
        final double z = container.getPoints().get(1).getZ() + height;
        for (final Vector3 v : points) {
            v.setZ(z);
        }
    } else {
        final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
        final Vector3 p = new Vector3();
        if (pickRay.intersectsPlane(new Plane(Vector3.UNIT_Z, points.get(0).getZ()), p)) {
            snapToGrid(p, getAbsPoint(editPointIndex), getGridSize(), false);
            snapToWallsPolygon(p);
            points.get(editPointIndex).set(toRelative(p));
        }
    }
    postEdit(editState);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector2(com.ardor3d.math.Vector2) Plane(com.ardor3d.math.Plane) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) Ray3(com.ardor3d.math.Ray3)

Aggregations

Plane (com.ardor3d.math.Plane)1 Ray3 (com.ardor3d.math.Ray3)1 Vector2 (com.ardor3d.math.Vector2)1 Vector3 (com.ardor3d.math.Vector3)1 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)1