Search in sources :

Example 6 with Box

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

Aggregations

OrientedBoundingBox (com.ardor3d.bounding.OrientedBoundingBox)6 Box (com.ardor3d.scenegraph.shape.Box)6 BMText (com.ardor3d.ui.text.BMText)6 BoundingBox (com.ardor3d.bounding.BoundingBox)5 OffsetState (com.ardor3d.renderer.state.OffsetState)5 Line (com.ardor3d.scenegraph.Line)5 Mesh (com.ardor3d.scenegraph.Mesh)5 ColorRGBA (com.ardor3d.math.ColorRGBA)4 Node (com.ardor3d.scenegraph.Node)3 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)2 CullHint (com.ardor3d.scenegraph.hint.CullHint)2 AngleAnnotation (org.concord.energy3d.shapes.AngleAnnotation)2 PvModuleSpecs (org.concord.energy3d.simulation.PvModuleSpecs)2 Vector3 (com.ardor3d.math.Vector3)1 ReadOnlyVector3 (com.ardor3d.math.type.ReadOnlyVector3)1 Spatial (com.ardor3d.scenegraph.Spatial)1 Cylinder (com.ardor3d.scenegraph.shape.Cylinder)1