Search in sources :

Example 6 with OffsetState

use of com.ardor3d.renderer.state.OffsetState 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 7 with OffsetState

use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.

the class SceneManager method createLand.

private Mesh createLand() {
    final Quad land = new Quad("Land", SKY_RADIUS * 2, SKY_RADIUS * 2);
    land.setDefaultColor(new ColorRGBA(0, 1.0f, 0.75f, 0.5f));
    final OffsetState offsetState = new OffsetState();
    offsetState.setTypeEnabled(OffsetType.Fill, true);
    offsetState.setFactor(10);
    offsetState.setUnits(10);
    land.setRenderState(offsetState);
    final BlendState blendState = new BlendState();
    blendState.setBlendEnabled(true);
    land.setRenderState(blendState);
    land.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    final MaterialState ms = new MaterialState();
    ms.setColorMaterial(ColorMaterial.Diffuse);
    land.setRenderState(ms);
    land.updateModelBound();
    land.updateWorldBound(true);
    return land;
}
Also used : Quad(com.ardor3d.scenegraph.shape.Quad) ColorRGBA(com.ardor3d.math.ColorRGBA) MaterialState(com.ardor3d.renderer.state.MaterialState) OffsetState(com.ardor3d.renderer.state.OffsetState) BlendState(com.ardor3d.renderer.state.BlendState)

Example 8 with OffsetState

use of com.ardor3d.renderer.state.OffsetState in project energy3d by concord-consortium.

the class SceneManager method initGroundImageLand.

private void initGroundImageLand(final double scale) {
    // 0.2 is the obsolete annotation scale by default, can't call Scene.getAnnotationScale() yet
    final double d = BOSTON_MAP_SCALE_FACTOR / 0.2 * scale;
    groundImageLand.resize(d, d);
    final OffsetState offsetState = new OffsetState();
    offsetState.setTypeEnabled(OffsetType.Fill, true);
    offsetState.setFactor(2);
    offsetState.setUnits(2);
    groundImageLand.setRenderState(offsetState);
    groundImageLand.updateModelBound();
    groundImageLand.updateWorldBound(true);
}
Also used : OffsetState(com.ardor3d.renderer.state.OffsetState)

Aggregations

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