Search in sources :

Example 11 with Spatial

use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.

the class Roof method hideGableRoofParts.

private void hideGableRoofParts() {
    if (gableEditPointToWallMap == null) {
        return;
    }
    // Two Options: hide using estimating direction with wall. Or, hide using roof part number (it be wrong))
    for (final List<Wall> walls : gableEditPointToWallMap.values()) {
        for (final HousePart wall : walls) {
            final Vector3[] base_i = { wall.getAbsPoint(0), wall.getAbsPoint(2) };
            for (final Spatial roofPart : getRoofPartsRoot().getChildren()) {
                final ReadOnlyVector3[] base = findBasePoints((Mesh) ((Node) roofPart).getChild(0), null);
                if (base != null && isSameBasePoints(base_i[0], base_i[1], base[0], base[1])) {
                    roofPart.getSceneHints().setCullHint(CullHint.Always);
                    roofPart.getSceneHints().setAllPickingHints(false);
                    break;
                }
            }
        }
    }
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Example 12 with Spatial

use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.

the class Roof method setAnnotationsVisible.

@Override
public void setAnnotationsVisible(final boolean visible) {
    super.setAnnotationsVisible(visible);
    final CullHint cull = visible ? CullHint.Inherit : CullHint.Always;
    if (roofPartsRoot != null) {
        for (final Spatial roofPart : roofPartsRoot.getChildren()) {
            if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                ((Node) roofPart).getChild(1).getSceneHints().setCullHint(cull);
                ((Node) roofPart).getChild(2).getSceneHints().setCullHint(cull);
            }
        }
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 13 with Spatial

use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.

the class Roof method drawRoof.

private void drawRoof() {
    applyOverhang(wallUpperPoints, wallNormals);
    processRoofEditPoints(wallUpperPoints);
    computeGableEditPoints();
    ensureEditPointsInside();
    final PolygonWithHoles polygon = makePolygon(wallUpperPoints);
    applySteinerPoint(polygon);
    MeshLib.fillMeshWithPolygon(mesh, polygon, null, true, null, null, null, false);
    MeshLib.groupByPlanar(mesh, roofPartsRoot);
    hideGableRoofParts();
    int roofPartIndex = 0;
    for (final Spatial child : roofPartsRoot.getChildren()) {
        ((Mesh) ((Node) child).getChild(0)).setUserData(new UserData(this, roofPartIndex, false));
        ((Mesh) ((Node) child).getChild(REAL_MESH_INDEX)).setUserData(new UserData(this, roofPartIndex, false));
        roofPartIndex++;
    }
    final List<Window> windows = new ArrayList<Window>();
    for (final HousePart part : children) {
        if (part instanceof Window && part.isDrawable()) {
            windows.add((Window) part);
        }
    }
    MeshLib.applyHoles(roofPartsRoot, windows);
    setAnnotationsVisible(Scene.getInstance().areAnnotationsVisible());
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) PolygonWithHoles(org.concord.energy3d.util.PolygonWithHoles) ArrayList(java.util.ArrayList) Mesh(com.ardor3d.scenegraph.Mesh) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint)

Example 14 with Spatial

use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.

the class Roof method drawDashLines.

private void drawDashLines() {
    if (container == null) {
        return;
    }
    if (lockEdit) {
        for (final Spatial roofPart : roofPartsRoot.getChildren()) {
            if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                final Node roofPartNode = (Node) roofPart;
                final Mesh dashLinesMesh = (Mesh) roofPartNode.getChild(5);
                dashLinesMesh.setVisible(false);
            }
        }
    } else {
        for (final Spatial roofPart : roofPartsRoot.getChildren()) {
            if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
                final Node roofPartNode = (Node) roofPart;
                final Mesh roofPartMesh = (Mesh) roofPartNode.getChild(0);
                final Mesh dashLinesMesh = (Mesh) roofPartNode.getChild(5);
                final List<ReadOnlyVector3> result = computeDashPoints(roofPartMesh);
                if (result.isEmpty()) {
                    dashLinesMesh.setVisible(false);
                } else {
                    dashLinesMesh.setVisible(true);
                    FloatBuffer vertexBuffer = dashLinesMesh.getMeshData().getVertexBuffer();
                    if (vertexBuffer == null || vertexBuffer.capacity() < result.size() * 3) {
                        vertexBuffer = BufferUtils.createVector3Buffer(result.size());
                        dashLinesMesh.getMeshData().setVertexBuffer(vertexBuffer);
                    }
                    vertexBuffer.limit(result.size() * 3);
                    vertexBuffer.rewind();
                    for (final ReadOnlyVector3 p : result) {
                        vertexBuffer.put(p.getXf()).put(p.getYf()).put(p.getZf());
                    }
                    dashLinesMesh.getMeshData().updateVertexCount();
                    dashLinesMesh.updateModelBound();
                }
            }
        }
    }
    updateDashLinesColor();
}
Also used : ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) FloatBuffer(java.nio.FloatBuffer)

Example 15 with Spatial

use of com.ardor3d.scenegraph.Spatial in project energy3d by concord-consortium.

the class Roof method getArea.

// return the area WITH overhang
@Override
public double getArea() {
    if (areaByPartWithOverhang == null) {
        return 0;
    }
    double a = 0;
    for (final Spatial roofPart : roofPartsRoot.getChildren()) {
        if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
            final Node roofPartNode = (Node) roofPart;
            final Mesh roofPartMesh = (Mesh) roofPartNode.getChild(REAL_MESH_INDEX);
            final Double d = areaByPartWithOverhang.get(roofPartMesh);
            if (d != null) {
                a += d;
            }
        }
    }
    return a;
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh)

Aggregations

Spatial (com.ardor3d.scenegraph.Spatial)57 Mesh (com.ardor3d.scenegraph.Mesh)36 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)33 Node (com.ardor3d.scenegraph.Node)26 CullHint (com.ardor3d.scenegraph.hint.CullHint)26 Vector3 (com.ardor3d.math.Vector3)24 TPoint (org.poly2tri.triangulation.point.TPoint)18 PickResults (com.ardor3d.intersection.PickResults)15 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)15 Ray3 (com.ardor3d.math.Ray3)15 Point (org.poly2tri.geometry.primitives.Point)14 FloatBuffer (java.nio.FloatBuffer)13 ArrayList (java.util.ArrayList)12 HousePart (org.concord.energy3d.model.HousePart)12 CancellationException (java.util.concurrent.CancellationException)10 Foundation (org.concord.energy3d.model.Foundation)10 Roof (org.concord.energy3d.model.Roof)9 Calendar (java.util.Calendar)7 UserData (org.concord.energy3d.model.UserData)6 Window (org.concord.energy3d.model.Window)6