Search in sources :

Example 96 with ReadOnlyVector3

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

the class PyramidRoof 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) {
        pickContainer(x, y, Wall.class);
        recalculateEditPoints = true;
    } else {
        final ReadOnlyVector3 base = new Vector3(getAbsPoint(0).getX(), getAbsPoint(0).getY(), getCenter().getZ());
        final Vector3 p = Util.closestPoint(base, Vector3.UNIT_Z, x, y);
        if (p != null) {
            snapToGrid(p, getAbsPoint(editPointIndex), getGridSize());
            height = Math.max(0, p.getZ() - base.getZ());
        }
    }
    postEdit(editState);
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 97 with ReadOnlyVector3

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

the class PyramidRoof method processRoofEditPoints.

@Override
protected void processRoofEditPoints(final List<? extends ReadOnlyVector3> wallUpperPoints) {
    final ReadOnlyVector3 center = getCenter();
    if (recalculateEditPoints) {
        recalculateEditPoints = false;
        points.get(0).set(toRelative(center));
        computeHeight(wallUpperPoints);
        applyHeight();
    } else {
        applyHeight();
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3)

Example 98 with ReadOnlyVector3

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

the class Roof method insideWalls.

public boolean insideWalls(final double x, final double y, final boolean init) {
    if (walls.isEmpty()) {
        return false;
    }
    if (init) {
        if (underlyingWallVerticesOnFoundation == null) {
            underlyingWallVerticesOnFoundation = new ArrayList<Vector2>();
        } else {
            underlyingWallVerticesOnFoundation.clear();
        }
        walls.get(0).visitNeighbors(new WallVisitor() {

            @Override
            public void visit(final Wall currentWall, final Snap prev, final Snap next) {
                int pointIndex = 0;
                if (next != null) {
                    pointIndex = next.getSnapPointIndexOf(currentWall);
                }
                pointIndex++;
                addUnderlyingWallVertex(currentWall.getAbsPoint(pointIndex == 1 ? 3 : 1));
                addUnderlyingWallVertex(currentWall.getAbsPoint(pointIndex));
            }

            private void addUnderlyingWallVertex(final ReadOnlyVector3 v3) {
                final Vector2 v2 = new Vector2(v3.getX(), v3.getY());
                boolean b = false;
                for (final Vector2 x : underlyingWallVerticesOnFoundation) {
                    if (Util.isEqual(x, v2)) {
                        b = true;
                        break;
                    }
                }
                if (!b) {
                    underlyingWallVerticesOnFoundation.add(v2);
                }
            }
        });
        if (underlyingWallPath == null) {
            underlyingWallPath = new Path2D.Double();
        } else {
            underlyingWallPath.reset();
        }
        final Vector2 v0 = underlyingWallVerticesOnFoundation.get(0);
        underlyingWallPath.moveTo(v0.getX(), v0.getY());
        for (int i = 1; i < underlyingWallVerticesOnFoundation.size(); i++) {
            final Vector2 v = underlyingWallVerticesOnFoundation.get(i);
            underlyingWallPath.lineTo(v.getX(), v.getY());
        }
        underlyingWallPath.lineTo(v0.getX(), v0.getY());
        underlyingWallPath.closePath();
    }
    return underlyingWallPath != null ? underlyingWallPath.contains(x, y) : false;
}
Also used : WallVisitor(org.concord.energy3d.util.WallVisitor) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ReadOnlyVector2(com.ardor3d.math.type.ReadOnlyVector2) Vector2(com.ardor3d.math.Vector2) Path2D(java.awt.geom.Path2D) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint)

Example 99 with ReadOnlyVector3

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

the class Roof method setGable.

public void setGable(final int roofPartIndex, final boolean isGable, final UndoManager undoManager) {
    final ArrayList<ReadOnlyVector3> roofPartMeshUpperPoints = new ArrayList<ReadOnlyVector3>();
    final Wall wall = findGableWall(roofPartIndex, roofPartMeshUpperPoints);
    if (wall != null) {
        if (undoManager != null) {
            undoManager.addEdit(new MakeGableCommand(this, wall, roofPartMeshUpperPoints));
        }
        setGable(wall, isGable, true, roofPartMeshUpperPoints);
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) ArrayList(java.util.ArrayList) MakeGableCommand(org.concord.energy3d.undo.MakeGableCommand)

Example 100 with ReadOnlyVector3

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

the class Roof method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(uValue)) {
        uValue = 0.15;
    }
    if (Util.isZero(overhangLength)) {
        overhangLength = 2;
    }
    if (Util.isZero(volumetricHeatCapacity)) {
        volumetricHeatCapacity = 0.5;
    }
    orgCenters = new HashMap<Node, ReadOnlyVector3>();
    wallNormals = new ArrayList<ReadOnlyVector3>();
    walls = new ArrayList<Wall>();
    roofPartPrintVerticalMap = new HashMap<Spatial, Boolean>();
    dashPointsCache = new HashMap<Mesh, List<ReadOnlyVector3>>();
    roofPartsRoot = new Node("Roof Meshes Root");
    root.attachChild(roofPartsRoot);
    mesh = new Mesh("Roof");
    mesh.setModelBound(null);
    getEditPointShape(0).setDefaultColor(ColorRGBA.CYAN);
    // cleanup
    if (gableEditPointToWallMap != null) {
        for (final List<Wall> wallList : gableEditPointToWallMap.values()) {
            final Iterator<Wall> walls = wallList.iterator();
            while (walls.hasNext()) {
                if (Scene.getInstance().getParts().indexOf(walls.next()) == -1) {
                    walls.remove();
                }
            }
        }
    }
}
Also used : Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Spatial(com.ardor3d.scenegraph.Spatial) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)125 Vector3 (com.ardor3d.math.Vector3)88 CullHint (com.ardor3d.scenegraph.hint.CullHint)60 FloatBuffer (java.nio.FloatBuffer)45 TPoint (org.poly2tri.triangulation.point.TPoint)44 Point (org.poly2tri.geometry.primitives.Point)34 PolygonPoint (org.poly2tri.geometry.polygon.PolygonPoint)32 Mesh (com.ardor3d.scenegraph.Mesh)25 Spatial (com.ardor3d.scenegraph.Spatial)25 ArrayList (java.util.ArrayList)23 Node (com.ardor3d.scenegraph.Node)18 PickingHint (com.ardor3d.scenegraph.hint.PickingHint)18 Ray3 (com.ardor3d.math.Ray3)16 PickResults (com.ardor3d.intersection.PickResults)15 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)15 ArdorVector3Point (org.poly2tri.triangulation.point.ardor3d.ArdorVector3Point)15 TriangulationPoint (org.poly2tri.triangulation.TriangulationPoint)13 Matrix3 (com.ardor3d.math.Matrix3)10 CancellationException (java.util.concurrent.CancellationException)10 Vector2 (com.ardor3d.math.Vector2)9