Search in sources :

Example 61 with Mesh

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

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

the class Rack method addPrintMesh.

@Override
protected void addPrintMesh(final List<Mesh> list, final Mesh mesh) {
    if (mesh.getSceneHints().getCullHint() != CullHint.Always) {
        final Mesh newMesh = mesh.makeCopy(false);
        final MaterialState material = new MaterialState();
        switch(sampleSolarPanel.getColorOption()) {
            case SolarPanel.COLOR_OPTION_BLACK:
                material.setDiffuse(ColorRGBA.BLACK);
                break;
            case SolarPanel.COLOR_OPTION_BLUE:
                material.setDiffuse(ColorRGBA.BLUE);
                break;
            case SolarPanel.COLOR_OPTION_GRAY:
                material.setDiffuse(ColorRGBA.GRAY);
                break;
            default:
                material.setDiffuse(mesh.getDefaultColor());
        }
        newMesh.setRenderState(material);
        newMesh.getMeshData().transformVertices((Transform) mesh.getWorldTransform());
        newMesh.getMeshData().transformNormals((Transform) mesh.getWorldTransform(), true);
        list.add(newMesh);
    }
}
Also used : Mesh(com.ardor3d.scenegraph.Mesh) MaterialState(com.ardor3d.renderer.state.MaterialState)

Example 63 with Mesh

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

Example 64 with Mesh

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

the class Roof method addPrintMeshes.

@Override
public void addPrintMeshes(final List<Mesh> list) {
    for (final Spatial roofPart : roofPartsRoot.getChildren()) {
        if (roofPart.getSceneHints().getCullHint() != CullHint.Always) {
            final Mesh mesh = (Mesh) ((Node) roofPart).getChild(REAL_MESH_INDEX);
            addPrintMesh(list, mesh);
        }
    }
}
Also used : Spatial(com.ardor3d.scenegraph.Spatial) Mesh(com.ardor3d.scenegraph.Mesh)

Example 65 with Mesh

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

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