Search in sources :

Example 16 with Line

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

the class Foundation method init.

@Override
protected void init() {
    super.init();
    resizeHouseMode = false;
    if (Util.isZero(uValue)) {
        uValue = 0.19;
    }
    if (Util.isZero(volumetricHeatCapacity)) {
        volumetricHeatCapacity = 0.5;
    }
    if (Util.isZero(solarReceiverEfficiency)) {
        solarReceiverEfficiency = 0.2;
    }
    if (Util.isZero(childGridSize)) {
        childGridSize = 2.5;
    }
    if (thermostat == null) {
        thermostat = new Thermostat();
    }
    mesh = new Mesh("Foundation");
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    mesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(6));
    mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
    mesh.setRenderState(offsetState);
    mesh.setModelBound(new BoundingBox());
    root.attachChild(mesh);
    if (foundationPolygon == null) {
        foundationPolygon = new FoundationPolygon(this);
    } else {
        foundationPolygon.draw();
    }
    root.attachChild(foundationPolygon.getRoot());
    sideMesh = new Mesh[4];
    for (int i = 0; i < 4; i++) {
        final Mesh mesh_i = new Mesh("Foundation (Side " + i + ")");
        mesh_i.setUserData(new UserData(this));
        mesh_i.setRenderState(offsetState);
        mesh_i.setModelBound(new BoundingBox());
        final MeshData meshData = mesh_i.getMeshData();
        meshData.setVertexBuffer(BufferUtils.createVector3Buffer(6));
        meshData.setNormalBuffer(BufferUtils.createVector3Buffer(6));
        mesh_i.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
        root.attachChild(mesh_i);
        sideMesh[i] = mesh_i;
    }
    boundingMesh = new Line("Foundation (Bounding)");
    boundingMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
    boundingMesh.setModelBound(new BoundingBox());
    Util.disablePickShadowLight(boundingMesh);
    boundingMesh.getSceneHints().setCullHint(CullHint.Always);
    root.attachChild(boundingMesh);
    outlineMesh = new Line("Foundation (Outline)");
    outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
    outlineMesh.setDefaultColor(ColorRGBA.BLACK);
    outlineMesh.setModelBound(new BoundingBox());
    Util.disablePickShadowLight(outlineMesh);
    root.attachChild(outlineMesh);
    linePatternMesh = new Line("Line Pattern");
    linePatternMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(2));
    linePatternMesh.setDefaultColor(new ColorRGBA(0, 0, 0, 0.75f));
    linePatternMesh.setModelBound(null);
    final BlendState blendState = new BlendState();
    blendState.setBlendEnabled(true);
    linePatternMesh.setRenderState(blendState);
    linePatternMesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    Util.disablePickShadowLight(linePatternMesh);
    root.attachChild(linePatternMesh);
    setLinePatternVisible(false);
    final UserData userData = new UserData(this);
    mesh.setUserData(userData);
    boundingMesh.setUserData(userData);
    setLabelOffset(-0.11);
    label = new BMText("Floating Label", "Undefined", FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
    Util.initHousePartLabel(label);
    label.setFontScale(0.5);
    label.setVisible(false);
    root.attachChild(label);
    azimuthArrow = new Line("Azimuth Arrow");
    azimuthArrow.setLineWidth(2);
    azimuthArrow.setModelBound(null);
    Util.disablePickShadowLight(azimuthArrow);
    azimuthArrow.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    azimuthArrow.setDefaultColor(ColorRGBA.WHITE);
    root.attachChild(azimuthArrow);
    solarReceiver = new Cylinder("Solar Receiver", 10, 10, 10, 0, true);
    solarReceiver.setDefaultColor(ColorRGBA.WHITE);
    solarReceiver.setRenderState(offsetState);
    solarReceiver.setModelBound(new BoundingBox());
    solarReceiver.setVisible(false);
    root.attachChild(solarReceiver);
    selectedMeshOutline = new Line("Outline of Selected Mesh");
    selectedMeshOutline.setLineWidth(2f);
    selectedMeshOutline.setStipplePattern((short) 0xf0f0);
    selectedMeshOutline.setModelBound(null);
    Util.disablePickShadowLight(selectedMeshOutline);
    selectedMeshOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
    selectedMeshOutline.setDefaultColor(new ColorRGBA(0f, 0f, 0f, 1f));
    root.attachChild(selectedMeshOutline);
    selectedNodeBoundingBox = new Line("Bounding Box of Selected Mesh");
    selectedNodeBoundingBox.setLineWidth(0.01f);
    selectedNodeBoundingBox.setStipplePattern((short) 0xf0f0);
    selectedNodeBoundingBox.setModelBound(null);
    Util.disablePickShadowLight(selectedNodeBoundingBox);
    selectedNodeBoundingBox.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(24));
    selectedNodeBoundingBox.setDefaultColor(new ColorRGBA(1f, 1f, 0f, 1f));
    root.attachChild(selectedNodeBoundingBox);
    updateTextureAndColor();
    if (points.size() == 8) {
        for (int i = 0; i < 4; i++) {
            points.add(new Vector3());
        }
    }
    if (importedNodeStates != null) {
        try {
            for (final Iterator<NodeState> it = importedNodeStates.iterator(); it.hasNext(); ) {
                final NodeState ns = it.next();
                final Node n = importCollada(ns.getSourceURL(), null);
                if (n == null) {
                    it.remove();
                    EventQueue.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                JOptionPane.showMessageDialog(MainFrame.getInstance(), Paths.get(ns.getSourceURL().toURI()).toFile() + " was not found!", "File problem", JOptionPane.ERROR_MESSAGE);
                            } catch (final HeadlessException e) {
                                e.printStackTrace();
                            } catch (final URISyntaxException e) {
                                e.printStackTrace();
                            }
                        }
                    });
                } else {
                    final ArrayList<Integer> reversedFaceMeshes = ns.getMeshesWithReversedNormal();
                    if (reversedFaceMeshes != null) {
                        for (final Integer i : reversedFaceMeshes) {
                            Util.reverseFace(Util.getMesh(n, i));
                        }
                    }
                    final ArrayList<Integer> deletedMeshes = ns.getDeletedMeshes();
                    if (deletedMeshes != null && !deletedMeshes.isEmpty()) {
                        final List<Mesh> toDelete = new ArrayList<Mesh>();
                        for (final Integer i : deletedMeshes) {
                            toDelete.add(Util.getMesh(n, i));
                        }
                        for (final Mesh m : toDelete) {
                            n.detachChild(m);
                        }
                    }
                    final HashMap<Integer, ReadOnlyColorRGBA> meshColors = ns.getMeshColors();
                    if (meshColors != null) {
                        for (final Integer i : meshColors.keySet()) {
                            Util.getMesh(n, i).setDefaultColor(meshColors.get(i));
                        }
                    }
                }
            }
        } catch (final Throwable t) {
            BugReporter.report(t);
        }
        setRotatedNormalsForImportedMeshes();
    }
}
Also used : ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) HeadlessException(java.awt.HeadlessException) Node(com.ardor3d.scenegraph.Node) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) BoundingBox(com.ardor3d.bounding.BoundingBox) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) BMText(com.ardor3d.ui.text.BMText) BlendState(com.ardor3d.renderer.state.BlendState) Thermostat(org.concord.energy3d.simulation.Thermostat) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) MeshData(com.ardor3d.scenegraph.MeshData) Line(com.ardor3d.scenegraph.Line) Cylinder(com.ardor3d.scenegraph.shape.Cylinder) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA)

Example 17 with Line

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

the class FoundationPolygon method init.

@Override
protected void init() {
    super.init();
    root.getSceneHints().setAllPickingHints(false);
    final Line line = new Line("Foundation Polygon");
    line.setLineWidth(3);
    line.getMeshData().setIndexMode(IndexMode.LineLoop);
    line.setModelBound(new BoundingBox());
    // line.setStipplePattern((short) 0xf);
    Util.disablePickShadowLight(line);
    root.attachChild(line);
    mesh = line;
    setVisible(visible);
}
Also used : Line(com.ardor3d.scenegraph.Line) BoundingBox(com.ardor3d.bounding.BoundingBox)

Example 18 with Line

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

the class Wall method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(wallThickness)) {
        wallThickness = defaultWallThickness;
    }
    if (Util.isZero(uValue)) {
        uValue = 0.28;
    }
    if (Util.isZero(volumetricHeatCapacity)) {
        volumetricHeatCapacity = 0.5;
    }
    if (Util.isZero(columnRadius)) {
        columnRadius = 1;
    }
    if (Util.isZero(railRadius)) {
        railRadius = 0.1;
    }
    neighbors = new Snap[2];
    if (thicknessNormal != null) {
        thicknessNormal.normalizeLocal().multiplyLocal(wallThickness);
    }
    mesh = new Mesh("Wall");
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
    // mesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
    mesh.setRenderState(offsetState);
    mesh.setModelBound(new BoundingBox());
    root.attachChild(mesh);
    backMesh = new Mesh("Wall (Back)");
    backMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
    backMesh.setDefaultColor(ColorRGBA.LIGHT_GRAY);
    backMesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
    backMesh.setRenderState(offsetState);
    backMesh.setModelBound(new BoundingBox());
    root.attachChild(backMesh);
    surroundMesh = new Mesh("Wall (Surround)");
    surroundMesh.getMeshData().setIndexMode(IndexMode.Quads);
    surroundMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
    surroundMesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(12));
    surroundMesh.setDefaultColor(ColorRGBA.GRAY);
    surroundMesh.setRenderState(offsetState);
    surroundMesh.setModelBound(new BoundingBox());
    root.attachChild(surroundMesh);
    invisibleMesh = new Mesh("Wall (Invisible)");
    invisibleMesh.getMeshData().setIndexMode(IndexMode.Quads);
    invisibleMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    invisibleMesh.getSceneHints().setCullHint(CullHint.Always);
    invisibleMesh.setRenderState(offsetState);
    invisibleMesh.setModelBound(new BoundingBox());
    root.attachChild(invisibleMesh);
    windowsSurroundMesh = new Mesh("Wall (Windows Surround)");
    windowsSurroundMesh.getMeshData().setIndexMode(IndexMode.Quads);
    windowsSurroundMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
    windowsSurroundMesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(1));
    windowsSurroundMesh.setDefaultColor(ColorRGBA.GRAY);
    windowsSurroundMesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
    windowsSurroundMesh.setRenderState(offsetState);
    /* lets not use bounds for this mesh because when there are no windows its bounds is set to center 0,0,0 which shifts the overall bounds toward zero */
    windowsSurroundMesh.setModelBound(null);
    root.attachChild(windowsSurroundMesh);
    outlineMesh = new Line("Wall (Outline)");
    outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
    outlineMesh.setDefaultColor(ColorRGBA.BLACK);
    outlineMesh.setModelBound(null);
    Util.disablePickShadowLight(outlineMesh);
    root.attachChild(outlineMesh);
    updateTextureAndColor();
    final UserData userData = new UserData(this);
    mesh.setUserData(userData);
    backMesh.setUserData(userData);
    surroundMesh.setUserData(userData);
    invisibleMesh.setUserData(userData);
    columns = new Mesh("Columns");
    columns.getMeshData().setIndexMode(IndexMode.Quads);
    columns.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(500));
    columns.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(500));
    columns.setRenderState(offsetState);
    columns.setModelBound(new BoundingBox());
    root.attachChild(columns);
    rails = new Mesh("Railings");
    rails.getMeshData().setIndexMode(IndexMode.Quads);
    rails.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1000));
    rails.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(1000));
    rails.setRenderState(offsetState);
    rails.setModelBound(new BoundingBox());
    root.attachChild(rails);
    steelFrame = new Mesh("Steel Frame");
    steelFrame.getMeshData().setIndexMode(IndexMode.Quads);
    steelFrame.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1000));
    steelFrame.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(1000));
    steelFrame.setRenderState(offsetState);
    steelFrame.setModelBound(new BoundingBox());
    root.attachChild(steelFrame);
}
Also used : Line(com.ardor3d.scenegraph.Line) BoundingBox(com.ardor3d.bounding.BoundingBox) Mesh(com.ardor3d.scenegraph.Mesh)

Example 19 with Line

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

the class Roof method setOriginal.

@Override
public void setOriginal(final HousePart original) {
    final Roof originalRoof = (Roof) original;
    this.original = original;
    root.detachChild(pointsRoot);
    root.detachChild(roofPartsRoot);
    roofPartsRoot = originalRoof.roofPartsRoot.makeCopy(true);
    root.attachChild(roofPartsRoot);
    for (int i = 0; i < roofPartsRoot.getNumberOfChildren(); i++) {
        final UserData orgUserData = (UserData) ((Node) originalRoof.roofPartsRoot.getChild(i)).getChild(0).getUserData();
        final Mesh mesh = (Mesh) ((Node) roofPartsRoot.getChild(i)).getChild(0);
        mesh.setUserData(new UserData(this, orgUserData.getEditPointIndex(), false));
        roofPartsRoot.getChild(i).setUserData(originalRoof.roofPartsRoot.getChild(i).getUserData());
        final Line outlineMesh = (Line) ((Node) roofPartsRoot.getChild(i)).getChild(4);
        outlineMesh.setLineWidth(printOutlineThickness);
    }
    drawAnnotations();
    root.updateWorldBound(true);
}
Also used : Line(com.ardor3d.scenegraph.Line) Node(com.ardor3d.scenegraph.Node) 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 20 with Line

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

the class HousePart method init.

/* if an attribute is transient but is always needed then it should be set to default here */
protected void init() {
    orgHeight = height;
    flattenCenter = new Vector3();
    isPrintVertical = false;
    if (id == 0) {
        id = Scene.getInstance().nextID();
    }
    root = new Node(toString());
    pointsRoot = new Node("Edit Points");
    sizeAnnotRoot = new Node("Size Annotations");
    sizeAnnotRoot.getSceneHints().setAllPickingHints(false);
    angleAnnotRoot = new Node("Angle Annotations");
    angleAnnotRoot.getSceneHints().setAllPickingHints(false);
    labelsRoot = new Node("Labels");
    labelsRoot.getSceneHints().setAllPickingHints(false);
    setAnnotationsVisible(Scene.getInstance().areAnnotationsVisible());
    // Set up a reusable pick results
    for (int i = 0; i < points.size(); i++) {
        addNewEditPointShape(i);
    }
    root.attachChild(pointsRoot);
    root.attachChild(sizeAnnotRoot);
    root.attachChild(angleAnnotRoot);
    root.attachChild(labelsRoot);
    gridsMesh = new Line("Grids");
    gridsMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(2));
    gridsMesh.setDefaultColor(new ColorRGBA(0, 0, 1, 0.25f));
    gridsMesh.setModelBound(null);
    final BlendState blendState = new BlendState();
    blendState.setBlendEnabled(true);
    gridsMesh.setRenderState(blendState);
    gridsMesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    Util.disablePickShadowLight(gridsMesh);
    root.attachChild(gridsMesh);
    setGridsVisible(false);
    heatFlux = new Line("Heat Flux");
    heatFlux.setLineWidth(1);
    heatFlux.setModelBound(null);
    Util.disablePickShadowLight(heatFlux);
    heatFlux.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    heatFlux.setDefaultColor(ColorRGBA.YELLOW);
    root.attachChild(heatFlux);
    if (color == null) {
        if (this instanceof Foundation) {
            color = Scene.getInstance().getFoundationColor();
        } else if (this instanceof Door) {
            color = Scene.getInstance().getDoorColor();
        } else if (this instanceof Roof) {
            color = Scene.getInstance().getRoofColor();
        } else if (this instanceof Wall) {
            color = Scene.getInstance().getWallColor();
        } else {
            color = ColorRGBA.LIGHT_GRAY;
        }
    }
}
Also used : Line(com.ardor3d.scenegraph.Line) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) Node(com.ardor3d.scenegraph.Node) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) CullHint(com.ardor3d.scenegraph.hint.CullHint) BlendState(com.ardor3d.renderer.state.BlendState)

Aggregations

Line (com.ardor3d.scenegraph.Line)20 Mesh (com.ardor3d.scenegraph.Mesh)15 BoundingBox (com.ardor3d.bounding.BoundingBox)14 ColorRGBA (com.ardor3d.math.ColorRGBA)10 Node (com.ardor3d.scenegraph.Node)10 CullHint (com.ardor3d.scenegraph.hint.CullHint)9 BMText (com.ardor3d.ui.text.BMText)9 OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)8 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)6 BlendState (com.ardor3d.renderer.state.BlendState)5 OffsetState (com.ardor3d.renderer.state.OffsetState)5 Box (com.ardor3d.scenegraph.shape.Box)5 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)4 Cylinder (com.ardor3d.scenegraph.shape.Cylinder)4 Vector3 (com.ardor3d.math.Vector3)3 FloatBuffer (java.nio.FloatBuffer)3 CullState (com.ardor3d.renderer.state.CullState)2 ArrayList (java.util.ArrayList)2 AngleAnnotation (org.concord.energy3d.shapes.AngleAnnotation)2 PvModuleSpecs (org.concord.energy3d.simulation.PvModuleSpecs)2