Search in sources :

Example 11 with BMText

use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.

the class ParabolicTrough method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(copyLayoutGap)) {
        // FIXME: Why is a transient member evaluated to zero?
        copyLayoutGap = 0.2;
    }
    if (Util.isZero(moduleLength)) {
        moduleLength = 3;
    }
    if (Util.isZero(troughLength)) {
        troughLength = 2 * moduleLength;
    }
    if (Util.isZero(apertureWidth)) {
        apertureWidth = 2;
    }
    if (Util.isZero(semilatusRectum)) {
        semilatusRectum = 2;
    }
    if (Util.isZero(reflectance)) {
        reflectance = 0.9;
    }
    if (Util.isZero(absorptance)) {
        absorptance = 0.95;
    }
    if (Util.isZero(opticalEfficiency)) {
        opticalEfficiency = 0.7;
    }
    if (Util.isZero(thermalEfficiency)) {
        thermalEfficiency = 0.3;
    }
    if (Util.isZero(nSectionParabola)) {
        nSectionParabola = 16;
    }
    if (Util.isZero(nSectionAxis)) {
        nSectionAxis = 32;
    }
    detailed = Scene.getInstance().countParts(this.getClass()) < 50;
    mesh = new ParabolicCylinder("Parabolic Cylinder", nSectionParabola, semilatusRectum, apertureWidth, troughLength);
    mesh.setDefaultColor(SKY_BLUE);
    mesh.setModelBound(new OrientedBoundingBox());
    mesh.setUserData(new UserData(this));
    CullState cullState = new CullState();
    cullState.setCullFace(Face.Back);
    mesh.setRenderState(cullState);
    root.attachChild(mesh);
    reflector = (ParabolicCylinder) mesh;
    reflectorBack = mesh.makeCopy(true);
    reflectorBack.clearRenderState(StateType.Texture);
    reflectorBack.setDefaultColor(ColorRGBA.WHITE);
    cullState = new CullState();
    cullState.setCullFace(Face.None);
    reflectorBack.setRenderState(cullState);
    root.attachChild(reflectorBack);
    final ColorRGBA tubeColor = new ColorRGBA(0.8f, 0.8f, 0.8f, 0.8f);
    absorber = new Cylinder("Absorber Tube", 2, detailed ? 10 : 4, 0.5, 0, true);
    final BlendState blend = new BlendState();
    blend.setBlendEnabled(true);
    absorber.setRenderState(blend);
    absorber.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    absorber.setDefaultColor(tubeColor);
    absorber.setModelBound(new OrientedBoundingBox());
    root.attachChild(absorber);
    absorberEnd1 = new Cylinder("Absorber End Tube 1", 2, detailed ? 10 : 4, 0.5, 0, true);
    absorberEnd1.setRenderState(blend);
    absorberEnd1.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    absorberEnd1.setDefaultColor(tubeColor);
    absorberEnd1.setModelBound(new OrientedBoundingBox());
    root.attachChild(absorberEnd1);
    absorberEnd2 = new Cylinder("Absorber End Tube 2", 2, detailed ? 10 : 4, 0.5, 0, true);
    absorberEnd2.setRenderState(blend);
    absorberEnd2.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    absorberEnd2.setDefaultColor(tubeColor);
    absorberEnd2.setModelBound(new OrientedBoundingBox());
    root.attachChild(absorberEnd2);
    if (detailed) {
        absorberCore = new Cylinder("Absorber Tube Core", 2, 4, 0.4, 0, true);
        absorberCore.setDefaultColor(ColorRGBA.BROWN);
        absorberCore.setModelBound(new OrientedBoundingBox());
        root.attachChild(absorberCore);
        absorberEnd1Core = new Cylinder("Absorber End Tube 1 Core", 2, 4, 0.4, 0, true);
        absorberEnd1Core.setDefaultColor(ColorRGBA.BROWN);
        absorberEnd1Core.setModelBound(new OrientedBoundingBox());
        root.attachChild(absorberEnd1Core);
        absorberEnd2Core = new Cylinder("Absorber End Tube 2 Core", 2, 4, 0.4, 0, true);
        absorberEnd2Core.setDefaultColor(ColorRGBA.BROWN);
        absorberEnd2Core.setModelBound(new OrientedBoundingBox());
        root.attachChild(absorberEnd2Core);
    }
    final int nModules = getNumberOfModules();
    outlines = new Line("Parabolic Trough (Outline)");
    outlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4 + 2 * (reflector.getNumberOfSamples() + 1) * (nModules + 1)));
    outlines.setDefaultColor(ColorRGBA.BLACK);
    outlines.setModelBound(new OrientedBoundingBox());
    outlines.setLineWidth(1f);
    outlines.setStipplePattern((short) 0xffff);
    Util.disablePickShadowLight(outlines);
    root.attachChild(outlines);
    steelFrame = new Line("Parabolic Trough Steel Frame");
    steelFrame.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    steelFrame.setDefaultColor(ColorRGBA.GRAY);
    steelFrame.setModelBound(new OrientedBoundingBox());
    steelFrame.setLineWidth(3);
    steelFrame.setStipplePattern((short) 0xffff);
    root.attachChild(steelFrame);
    lightBeams = new Line("Light Beams");
    lightBeams.setLineWidth(1f);
    lightBeams.setStipplePattern((short) 0xffff);
    lightBeams.setModelBound(null);
    Util.disablePickShadowLight(lightBeams);
    lightBeams.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    lightBeams.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
    root.attachChild(lightBeams);
    label = new BMText("Label", "#" + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
    Util.initHousePartLabel(label);
    label.setFontScale(0.5);
    label.setVisible(false);
    root.attachChild(label);
    modulesRoot = new Node("Modules Root");
    root.attachChild(modulesRoot);
    updateTextureAndColor();
    if (!points.isEmpty()) {
        oldTroughCenter = points.get(0).clone();
    }
    oldTroughLength = troughLength;
    oldApertureWidth = apertureWidth;
}
Also used : Line(com.ardor3d.scenegraph.Line) Cylinder(com.ardor3d.scenegraph.shape.Cylinder) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) Node(com.ardor3d.scenegraph.Node) CullState(com.ardor3d.renderer.state.CullState) BMText(com.ardor3d.ui.text.BMText) BlendState(com.ardor3d.renderer.state.BlendState) CullHint(com.ardor3d.scenegraph.hint.CullHint)

Example 12 with BMText

use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.

the class SolarPanel method init.

@Override
protected void init() {
    super.init();
    if (Util.isZero(panelWidth)) {
        panelWidth = 0.99;
    }
    if (Util.isZero(panelHeight)) {
        panelHeight = 1.65;
    }
    if (Util.isZero(efficiency)) {
        // make it the same as the default one in PvModuleSpecs
        efficiency = 0.1833;
    }
    if (Util.isZero(temperatureCoefficientPmax)) {
        temperatureCoefficientPmax = -0.005;
    }
    if (Util.isZero(nominalOperatingCellTemperature)) {
        nominalOperatingCellTemperature = 48;
    }
    if (Util.isZero(inverterEfficiency)) {
        inverterEfficiency = 0.95;
    }
    if (Util.isZero(baseHeight)) {
        baseHeight = 5;
    }
    if (Util.isZero(numberOfCellsInX)) {
        numberOfCellsInX = 6;
    }
    if (Util.isZero(numberOfCellsInY)) {
        numberOfCellsInY = 10;
    }
    if (pvModuleSpecs == null) {
        // backward compatibility
        pvModuleSpecs = new PvModuleSpecs("Custom");
        pvModuleSpecs.setCellEfficiency(efficiency);
        pvModuleSpecs.setWidth(panelWidth);
        pvModuleSpecs.setLength(panelHeight);
        pvModuleSpecs.setNoct(nominalOperatingCellTemperature);
        pvModuleSpecs.setPmaxTc(temperatureCoefficientPmax);
        pvModuleSpecs.setLayout(numberOfCellsInX, numberOfCellsInY);
        switch(cellType) {
            case POLYCRYSTALLINE:
                pvModuleSpecs.setCellType("Polycrystalline");
                colorOption = COLOR_OPTION_BLUE;
                break;
            case MONOCRYSTALLINE:
                pvModuleSpecs.setCellType("Monocrystalline");
                colorOption = COLOR_OPTION_BLACK;
                break;
            case THIN_FILM:
                pvModuleSpecs.setCellType("Thin Film");
                colorOption = COLOR_OPTION_BLACK;
                break;
        }
    } else {
        convertStringPropertiesToIntegerProperties();
    }
    mesh = new Mesh("SolarPanel");
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    mesh.getMeshData().setTextureBuffer(BufferUtils.createVector2Buffer(6), 0);
    mesh.setModelBound(new OrientedBoundingBox());
    mesh.setUserData(new UserData(this));
    root.attachChild(mesh);
    surround = new Box("SolarPanel (Surround)");
    surround.setModelBound(new OrientedBoundingBox());
    final OffsetState offset = new OffsetState();
    offset.setFactor(1);
    offset.setUnits(1);
    surround.setRenderState(offset);
    root.attachChild(surround);
    outlineMesh = new Line("SolarPanel (Outline)");
    outlineMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
    outlineMesh.setDefaultColor(ColorRGBA.BLACK);
    outlineMesh.setModelBound(new OrientedBoundingBox());
    root.attachChild(outlineMesh);
    supportFrame = new Mesh("Supporting Frame");
    supportFrame.getMeshData().setIndexMode(IndexMode.Quads);
    supportFrame.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
    supportFrame.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(12));
    supportFrame.setRenderState(offsetState);
    supportFrame.setModelBound(new BoundingBox());
    root.attachChild(supportFrame);
    sunBeam = new Line("Sun Beam");
    sunBeam.setLineWidth(1f);
    sunBeam.setStipplePattern((short) 0xffff);
    sunBeam.setModelBound(null);
    Util.disablePickShadowLight(sunBeam);
    sunBeam.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    sunBeam.setDefaultColor(new ColorRGBA(1f, 1f, 1f, 1f));
    root.attachChild(sunBeam);
    normalVector = new Line("Normal Vector");
    normalVector.setLineWidth(1f);
    normalVector.setStipplePattern((short) 0xffff);
    normalVector.setModelBound(null);
    Util.disablePickShadowLight(normalVector);
    normalVector.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    normalVector.setDefaultColor(new ColorRGBA(1f, 1f, 0f, 1f));
    root.attachChild(normalVector);
    angles = new Node("Angles");
    angles.getSceneHints().setAllPickingHints(false);
    Util.disablePickShadowLight(angles);
    root.attachChild(angles);
    // the angle between the sun beam and the normal vector
    sunAngle = new AngleAnnotation();
    sunAngle.setColor(ColorRGBA.WHITE);
    sunAngle.setLineWidth(1);
    sunAngle.setFontSize(1);
    sunAngle.setCustomRadius(normalVectorLength * 0.8);
    angles.attachChild(sunAngle);
    label = new BMText("Label", "# " + id, FontManager.getInstance().getPartNumberFont(), Align.Center, Justify.Center);
    Util.initHousePartLabel(label);
    label.setFontScale(0.5);
    label.setVisible(false);
    root.attachChild(label);
    solarCellOutlines = new Line("Solar Cell Outlines");
    solarCellOutlines.setLineWidth(1f);
    solarCellOutlines.setStipplePattern((short) 0xffff);
    solarCellOutlines.setModelBound(null);
    Util.disablePickShadowLight(solarCellOutlines);
    solarCellOutlines.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(1));
    solarCellOutlines.setDefaultColor(new ColorRGBA(0f, 0f, 0f, 1f));
    root.attachChild(solarCellOutlines);
    updateTextureAndColor();
}
Also used : Line(com.ardor3d.scenegraph.Line) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) ColorRGBA(com.ardor3d.math.ColorRGBA) BoundingBox(com.ardor3d.bounding.BoundingBox) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Node(com.ardor3d.scenegraph.Node) Mesh(com.ardor3d.scenegraph.Mesh) BoundingBox(com.ardor3d.bounding.BoundingBox) Box(com.ardor3d.scenegraph.shape.Box) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) AngleAnnotation(org.concord.energy3d.shapes.AngleAnnotation) BMText(com.ardor3d.ui.text.BMText) PvModuleSpecs(org.concord.energy3d.simulation.PvModuleSpecs) OffsetState(com.ardor3d.renderer.state.OffsetState)

Example 13 with BMText

use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.

the class MeshLib method createMeshes.

public static void createMeshes(final Node root, final ArrayList<GroupData> groups) {
    if (groups.size() != root.getNumberOfChildren()) {
        root.detachAllChildren();
    }
    int meshIndex = 0;
    for (final GroupData group : groups) {
        final Node node;
        final Mesh mesh;
        final Mesh meshWithHoles;
        final BMText label;
        if (meshIndex < root.getNumberOfChildren()) {
            node = (Node) root.getChild(meshIndex);
            mesh = (Mesh) node.getChild(0);
            label = (BMText) node.getChild(3);
            meshWithHoles = (Mesh) node.getChild(6);
            node.getSceneHints().setAllPickingHints(true);
        } else {
            node = new Node("Roof Part #" + meshIndex);
            mesh = new Mesh("Roof Mesh #" + meshIndex);
            meshWithHoles = new Mesh("Roof Mesh with Holes #" + meshIndex);
            mesh.setVisible(false);
            mesh.setModelBound(new BoundingBox());
            meshWithHoles.setModelBound(new BoundingBox());
            meshWithHoles.setRenderState(HousePart.offsetState);
            label = new BMText("Label Text", "", FontManager.getInstance().getPartNumberFont(), Align.South, Justify.Center);
            Util.initHousePartLabel(label);
            final Mesh wireframeMesh = new Line("Roof (wireframe)");
            wireframeMesh.setDefaultColor(ColorRGBA.BLACK);
            wireframeMesh.setModelBound(new BoundingBox());
            wireframeMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(10));
            // offset to avoid z-fighting
            wireframeMesh.setTranslation(group.key.multiply(0.001, null));
            final Line dashLineMesh = new Line("Roof (dash line)");
            dashLineMesh.setStipplePattern((short) 0xFF00);
            dashLineMesh.setVisible(false);
            dashLineMesh.setModelBound(new BoundingBox());
            final Node sizeAnnotation = new Node("Roof Size Annot");
            final Node angleAnnotation = new Node("Roof Angle Annot");
            // disable picking for all except mesh
            Util.disablePickShadowLight(sizeAnnotation);
            Util.disablePickShadowLight(angleAnnotation);
            Util.disablePickShadowLight(wireframeMesh);
            Util.disablePickShadowLight(dashLineMesh);
            // meshWithHoles.getSceneHints().setAllPickingHints(false);
            node.attachChild(mesh);
            node.attachChild(sizeAnnotation);
            node.attachChild(angleAnnotation);
            node.attachChild(label);
            node.attachChild(wireframeMesh);
            node.attachChild(dashLineMesh);
            node.attachChild(meshWithHoles);
            root.attachChild(node);
        }
        node.getSceneHints().setCullHint(CullHint.Never);
        CollisionTreeManager.getInstance().removeCollisionTree(mesh);
        CollisionTreeManager.getInstance().removeCollisionTree(meshWithHoles);
        final Vector3 normal = group.key;
        node.setUserData(normal);
        final FloatBuffer buf = BufferUtils.createVector3Buffer(group.vertices.size());
        mesh.getMeshData().setVertexBuffer(buf);
        final Vector3 center = new Vector3();
        for (final ReadOnlyVector3 v : group.vertices) {
            buf.put(v.getXf()).put(v.getYf()).put(v.getZf());
            center.addLocal(v);
        }
        center.multiplyLocal(1.0 / group.vertices.size());
        label.setTranslation(center.add(normal.multiply(0.1, null), null));
        mesh.updateModelBound();
        meshIndex++;
    }
}
Also used : Line(com.ardor3d.scenegraph.Line) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Node(com.ardor3d.scenegraph.Node) BoundingBox(com.ardor3d.bounding.BoundingBox) Mesh(com.ardor3d.scenegraph.Mesh) ReadOnlyVector3(com.ardor3d.math.type.ReadOnlyVector3) Vector3(com.ardor3d.math.Vector3) FloatBuffer(java.nio.FloatBuffer) BMText(com.ardor3d.ui.text.BMText) CullHint(com.ardor3d.scenegraph.hint.CullHint) PolygonPoint(org.poly2tri.geometry.polygon.PolygonPoint) TPoint(org.poly2tri.triangulation.point.TPoint) Point(org.poly2tri.geometry.primitives.Point)

Example 14 with BMText

use of com.ardor3d.ui.text.BMText in project energy3d by concord-consortium.

the class PrintController method computePageDimension.

private void computePageDimension() {
    spaceBetweenParts = Scene.getInstance().areAnnotationsVisible() ? 3.0 : 0;
    double fromPageToWorldCoord;
    if (!isScaleToFit) {
        fromPageToWorldCoord = exactFromPageToWorldCoord / (Scene.getInstance().getAnnotationScale() / 10.0);
    } else {
        double maxWidth = 0;
        double maxHeight = 0;
        for (final HousePart printPart : printParts) {
            if (printPart.isPrintable()) {
                if (printPart instanceof Roof) {
                    for (final Spatial roofPartNode : ((Roof) printPart).getRoofPartsRoot().getChildren()) {
                        if (roofPartNode.getSceneHints().getCullHint() != CullHint.Always) {
                            final OrientedBoundingBox boundingBox = (OrientedBoundingBox) ((Node) roofPartNode).getChild(0).getWorldBound().asType(Type.OBB);
                            final double width = Math.min(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                            final double height = Math.max(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                            if (width > maxWidth) {
                                maxWidth = width;
                            }
                            if (height > maxHeight) {
                                maxHeight = height;
                            }
                        }
                    }
                } else {
                    final OrientedBoundingBox boundingBox = (OrientedBoundingBox) printPart.getMesh().getWorldBound().asType(Type.OBB);
                    final double width = Math.min(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                    final double height = Math.max(boundingBox.getExtent().getX(), boundingBox.getExtent().getZ());
                    if (width > maxWidth) {
                        maxWidth = width;
                    }
                    if (height > maxHeight) {
                        maxHeight = height;
                    }
                }
            }
        }
        maxWidth *= 2;
        maxHeight *= 2;
        maxWidth += 2 * spaceBetweenParts;
        maxHeight += 2 * spaceBetweenParts;
        final double ratio = pageFormat.getImageableWidth() / pageFormat.getImageableHeight();
        if (maxWidth / maxHeight > ratio) {
            pageWidth = ratio < 1 ? Math.min(maxWidth, maxHeight) : Math.max(maxWidth, maxHeight);
            pageHeight = pageWidth / ratio;
        } else {
            pageHeight = ratio < 1 ? Math.max(maxWidth, maxHeight) : Math.min(maxWidth, maxHeight);
            pageWidth = pageHeight * ratio;
        }
        fromPageToWorldCoord = pageWidth / pageFormat.getImageableWidth();
    }
    pageLeft = pageFormat.getImageableX() * fromPageToWorldCoord + spaceBetweenParts / 2.0;
    pageRight = (pageFormat.getImageableX() + pageFormat.getImageableWidth()) * fromPageToWorldCoord - spaceBetweenParts / 2.0;
    pageTop = pageFormat.getImageableY() * fromPageToWorldCoord + spaceBetweenParts / 2.0;
    if (labelHeight == 0.0) {
        final BMText label = Annotation.makeNewLabel(1);
        label.setFontScale(0.5);
        labelHeight = label.getHeight();
    }
    pageBottom = (pageFormat.getImageableY() + pageFormat.getImageableHeight()) * fromPageToWorldCoord;
    pageWidth = pageFormat.getWidth() * fromPageToWorldCoord;
    pageHeight = pageFormat.getHeight() * fromPageToWorldCoord;
}
Also used : Roof(org.concord.energy3d.model.Roof) OrientedBoundingBox(com.ardor3d.bounding.OrientedBoundingBox) Spatial(com.ardor3d.scenegraph.Spatial) BMText(com.ardor3d.ui.text.BMText) HousePart(org.concord.energy3d.model.HousePart)

Example 15 with BMText

use of com.ardor3d.ui.text.BMText 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)

Aggregations

BMText (com.ardor3d.ui.text.BMText)17 OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)10 Line (com.ardor3d.scenegraph.Line)9 BoundingBox (com.ardor3d.bounding.BoundingBox)8 ColorRGBA (com.ardor3d.math.ColorRGBA)7 Mesh (com.ardor3d.scenegraph.Mesh)7 Node (com.ardor3d.scenegraph.Node)7 Box (com.ardor3d.scenegraph.shape.Box)6 Vector3 (com.ardor3d.math.Vector3)5 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)5 OffsetState (com.ardor3d.renderer.state.OffsetState)5 CullHint (com.ardor3d.scenegraph.hint.CullHint)5 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)4 Spatial (com.ardor3d.scenegraph.Spatial)4 Cylinder (com.ardor3d.scenegraph.shape.Cylinder)4 BlendState (com.ardor3d.renderer.state.BlendState)2 CullState (com.ardor3d.renderer.state.CullState)2 AngleAnnotation (org.concord.energy3d.shapes.AngleAnnotation)2 PvModuleSpecs (org.concord.energy3d.simulation.PvModuleSpecs)2 ColladaImporter (com.ardor3d.extension.model.collada.jdom.ColladaImporter)1