Search in sources :

Example 16 with Mesh

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

the class Roof method drawHeatFlux.

@Override
public void drawHeatFlux() {
    FloatBuffer arrowsVertices = heatFlux.getMeshData().getVertexBuffer();
    final Foundation foundation = getTopContainer();
    final int cols = (int) Math.max(2, foundation.getAbsPoint(0).distance(foundation.getAbsPoint(2)) / Scene.getInstance().getHeatVectorGridSize());
    final int rows = (int) Math.max(2, foundation.getAbsPoint(0).distance(foundation.getAbsPoint(1)) / Scene.getInstance().getHeatVectorGridSize());
    arrowsVertices = BufferUtils.createVector3Buffer(rows * cols * 6);
    heatFlux.getMeshData().setVertexBuffer(arrowsVertices);
    final ReadOnlyVector3 o = foundation.getAbsPoint(0);
    final ReadOnlyVector3 u = foundation.getAbsPoint(2).subtract(o, null);
    final ReadOnlyVector3 v = foundation.getAbsPoint(1).subtract(o, null);
    final Vector3 a = new Vector3();
    double g, h;
    boolean init = true;
    for (int j = 0; j < cols; j++) {
        h = j + 0.5;
        for (int i = 0; i < rows; i++) {
            g = i + 0.5;
            a.setX(o.getX() + g * v.getX() / rows + h * u.getX() / cols);
            a.setY(o.getY() + g * v.getY() / rows + h * u.getY() / cols);
            a.setZ(o.getZ());
            if (insideWalls(a.getX(), a.getY(), init)) {
                ReadOnlyVector3 b = null;
                Node node = null;
                Mesh mesh = null;
                for (final Spatial child : roofPartsRoot.getChildren()) {
                    if (child.getSceneHints().getCullHint() != CullHint.Always) {
                        node = (Node) child;
                        mesh = (Mesh) node.getChild(REAL_MESH_INDEX);
                        b = findRoofIntersection(mesh, a);
                        if (b != null) {
                            break;
                        }
                    }
                }
                if (b != null) {
                    final ReadOnlyVector3 normal = (ReadOnlyVector3) node.getUserData();
                    final double heat = calculateHeatVector(mesh);
                    drawArrow(b, normal, arrowsVertices, heat);
                }
            }
            if (init) {
                init = false;
            }
        }
        heatFlux.getMeshData().updateVertexCount();
        heatFlux.updateModelBound();
    }
    updateHeatFluxVisibility();
}
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) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) TPoint(org.poly2tri.triangulation.point.TPoint) TriangulationPoint(org.poly2tri.triangulation.TriangulationPoint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint)

Example 17 with Mesh

use of com.ardor3d.scenegraph.Mesh 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 18 with Mesh

use of com.ardor3d.scenegraph.Mesh 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 19 with Mesh

use of com.ardor3d.scenegraph.Mesh 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)

Example 20 with Mesh

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

the class Roof method computeOrientedBoundingBox.

@Override
public void computeOrientedBoundingBox() {
    orgCenters.clear();
    for (final Spatial roofPartNode : roofPartsRoot.getChildren()) {
        if (roofPartNode.getSceneHints().getCullHint() != CullHint.Always) {
            final Mesh roofPartMesh = (Mesh) ((Node) roofPartNode).getChild(0);
            computeOrientedBoundingBox(roofPartMesh);
            orgCenters.put((Node) roofPartNode, new Vector3(roofPartMesh.getWorldBound().getCenter()));
        }
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3)

Aggregations

Mesh (com.ardor3d.scenegraph.Mesh)69 Spatial (com.ardor3d.scenegraph.Spatial)36 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)33 Node (com.ardor3d.scenegraph.Node)31 CullHint (com.ardor3d.scenegraph.hint.CullHint)28 Vector3 (com.ardor3d.math.Vector3)25 FloatBuffer (java.nio.FloatBuffer)18 TPoint (org.poly2tri.triangulation.point.TPoint)16 Line (com.ardor3d.scenegraph.Line)15 ArrayList (java.util.ArrayList)15 BoundingBox (com.ardor3d.bounding.BoundingBox)12 Point (org.poly2tri.geometry.primitives.Point)12 HousePart (org.concord.energy3d.model.HousePart)11 OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)10 PickResults (com.ardor3d.intersection.PickResults)10 PrimitivePickResults (com.ardor3d.intersection.PrimitivePickResults)10 Ray3 (com.ardor3d.math.Ray3)10 Foundation (org.concord.energy3d.model.Foundation)10 ColorRGBA (com.ardor3d.math.ColorRGBA)8 Calendar (java.util.Calendar)8