Search in sources :

Example 1 with Mesh

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

the class Door method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(uValue)) {
        uValue = 2;
    }
    if (Util.isZero(volumetricHeatCapacity)) {
        volumetricHeatCapacity = 0.5;
    }
    mesh = new Mesh("Door");
    mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip);
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    mesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(4));
    mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(4), 0);
    updateTextureAndColor();
    mesh.setModelBound(new BoundingBox());
    mesh.setUserData(new UserData(this));
    root.attachChild(mesh);
    outlineMesh = new Line("Door (Outline)");
    outlineMesh.setLineWidth(2);
    outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6 + 2 * 4));
    outlineMesh.setDefaultColor(ColorRGBA.BLACK);
    outlineMesh.setModelBound(new BoundingBox());
    Util.disablePickShadowLight(outlineMesh);
    root.attachChild(outlineMesh);
}
Also used : Line(com.ardor3d.scenegraph.Line) BoundingBox(com.ardor3d.bounding.BoundingBox) Mesh(com.ardor3d.scenegraph.Mesh)

Example 2 with Mesh

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

the class Floor method init.

@Override
protected void init() {
    super.init();
    mesh = new Mesh("Floor");
    root.attachChild(mesh);
    mesh.getMeshData().setIndexMode(IndexMode.TriangleStrip);
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    mesh.setModelBound(new BoundingBox());
    mesh.setRenderState(offsetState);
    outlineMesh = new Line("Floor (Outline)");
    outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
    outlineMesh.setDefaultColor(ColorRGBA.BLACK);
    outlineMesh.setModelBound(new BoundingBox());
    Util.disablePickShadowLight(outlineMesh);
    /* no need to attach because floor outline is only need in print preview */
    updateTextureAndColor();
    mesh.setUserData(new UserData(this));
}
Also used : Line(com.ardor3d.scenegraph.Line) BoundingBox(com.ardor3d.bounding.BoundingBox) Mesh(com.ardor3d.scenegraph.Mesh)

Example 3 with Mesh

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

the class Foundation method pickMesh.

public void pickMesh(final int x, final int y) {
    selectedMesh = null;
    if (importedNodes != null) {
        final PickResults pickResults = new PrimitivePickResults();
        pickResults.setCheckDistance(true);
        final Ray3 pickRay = SceneManager.getInstance().getCamera().getPickRay(new Vector2(x, y), false, null);
        for (final Node node : importedNodes) {
            for (final Spatial s : node.getChildren()) {
                if (s instanceof Mesh) {
                    PickingUtil.findPick(s, pickRay, pickResults, false);
                }
            }
        }
        if (pickResults.getNumber() > 0) {
            final Pickable pickable = pickResults.getPickData(0).getTarget();
            if (pickable instanceof Mesh) {
                selectedMesh = (Mesh) pickable;
                drawMeshSelection(selectedMesh);
            }
        } else {
            setMeshSelectionVisible(false);
        }
    }
}
Also used : PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) ReadOnlyVector2(com.ardor3d.math.type.ReadOnlyVector2) Vector2(com.ardor3d.math.Vector2) Spatial(com.ardor3d.scenegraph.Spatial) Pickable(com.ardor3d.intersection.Pickable) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) PrimitivePickResults(com.ardor3d.intersection.PrimitivePickResults) PickResults(com.ardor3d.intersection.PickResults) Ray3(com.ardor3d.math.Ray3)

Example 4 with Mesh

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

the class Foundation method setMovePointsVisible.

public void setMovePointsVisible(final boolean visible) {
    final int n = points.size();
    for (int i = n - 4; i < n; i++) {
        final Spatial editPoint = pointsRoot.getChild(i);
        ((Mesh) editPoint).setVisible(visible);
        final SceneHints sceneHints = editPoint.getSceneHints();
        sceneHints.setAllPickingHints(visible);
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Mesh(com.ardor3d.scenegraph.Mesh) SceneHints(com.ardor3d.scenegraph.hint.SceneHints) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 5 with Mesh

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

the class Foundation method drawImportedNodes.

public void drawImportedNodes() {
    if (importedNodes != null) {
        final int n = importedNodes.size();
        if (n > 0) {
            Node ni;
            final Vector3 c = getAbsCenter();
            // the absolute center is lifted to the center of the bounding box that includes walls when there are
            c.setZ(height);
            // FIXME: Why negate?
            final Matrix3 matrix = new Matrix3().fromAngles(0, 0, -Math.toRadians(getAzimuth()));
            for (int i = 0; i < n; i++) {
                ni = importedNodes.get(i);
                if (root.getChildren().contains(ni)) {
                    final Vector3 relativePosition = importedNodeStates.get(i).getRelativePosition();
                    if (relativePosition != null) {
                        final Vector3 vi = matrix.applyPost(relativePosition, null);
                        ni.setTranslation(c.add(vi, null));
                        ni.setRotation(matrix);
                        for (final Spatial s : ni.getChildren()) {
                            if (s instanceof Mesh) {
                                final Mesh m = (Mesh) s;
                                m.updateModelBound();
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) Matrix3(com.ardor3d.math.Matrix3)

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