Search in sources :

Example 1 with MaterialState

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

the class HousePart method addPrintMesh.

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();
        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 2 with MaterialState

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

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

the class Window method init.

@Override
protected void init() {
    label1 = Annotation.makeNewLabel(1);
    super.init();
    if (Util.isZero(uValue)) {
        uValue = 2;
    }
    if (Util.isZero(solarHeatGainCoefficient)) {
        solarHeatGainCoefficient = 0.5;
    } else if (solarHeatGainCoefficient > 1) {
        solarHeatGainCoefficient *= 0.01;
    }
    if (Util.isZero(volumetricHeatCapacity)) {
        volumetricHeatCapacity = 0.5;
    }
    if (Util.isZero(shutterLength)) {
        shutterLength = 0.5;
    }
    if (glassColor == null) {
        setColor(new ColorRGBA(0.3f, 0.3f, 0.5f, 0.5f));
    }
    if (shutterColor == null) {
        shutterColor = ColorRGBA.DARK_GRAY;
    }
    mesh = new Mesh("Window");
    mesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    mesh.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(6));
    mesh.setModelBound(new BoundingBox());
    mesh.getSceneHints().setAllPickingHints(false);
    if (glassColor == null) {
        glassColor = new ColorRGBA(0.3f, 0.3f, 0.5f, 0.5f);
    }
    mesh.setDefaultColor(glassColor);
    final BlendState blend = new BlendState();
    blend.setBlendEnabled(true);
    // blend.setTestEnabled(true);
    mesh.setRenderState(blend);
    mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    final MaterialState ms = new MaterialState();
    ms.setColorMaterial(ColorMaterial.Diffuse);
    mesh.setRenderState(ms);
    root.attachChild(mesh);
    collisionMesh = new Mesh("Window Collision");
    collisionMesh.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(6));
    collisionMesh.setVisible(false);
    collisionMesh.setUserData(new UserData(this));
    collisionMesh.setModelBound(new BoundingBox());
    root.attachChild(collisionMesh);
    label1.setAlign(Align.SouthWest);
    root.attachChild(label1);
    bars = new Line("Window (bars)");
    bars.setLineWidth(3);
    bars.setModelBound(new BoundingBox());
    Util.disablePickShadowLight(bars);
    bars.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(8));
    root.attachChild(bars);
    leftShutter = new Mesh("Left Shutter");
    leftShutter.getMeshData().setIndexMode(IndexMode.Quads);
    leftShutter.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    leftShutter.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(4));
    leftShutter.setRenderState(ms);
    leftShutter.setModelBound(new BoundingBox());
    root.attachChild(leftShutter);
    rightShutter = new Mesh("Right Shutter");
    rightShutter.getMeshData().setIndexMode(IndexMode.Quads);
    rightShutter.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(4));
    rightShutter.getMeshData().setNormalBuffer(BufferUtils.createVector3Buffer(4));
    rightShutter.setRenderState(ms);
    rightShutter.setModelBound(new BoundingBox());
    root.attachChild(rightShutter);
    leftShutterOutline = new Line("Left Shutter (Outline)");
    leftShutterOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
    leftShutterOutline.setDefaultColor(ColorRGBA.BLACK);
    leftShutterOutline.setModelBound(new BoundingBox());
    root.attachChild(leftShutterOutline);
    rightShutterOutline = new Line("Right Shutter (Outline)");
    rightShutterOutline.getMeshData().setVertexBuffer(BufferUtils.createVector3Buffer(12));
    rightShutterOutline.setDefaultColor(ColorRGBA.BLACK);
    rightShutterOutline.setModelBound(new BoundingBox());
    root.attachChild(rightShutterOutline);
}
Also used : Line(com.ardor3d.scenegraph.Line) ReadOnlyColorRGBA(com.ardor3d.math.type.ReadOnlyColorRGBA) ColorRGBA(com.ardor3d.math.ColorRGBA) BoundingBox(com.ardor3d.bounding.BoundingBox) Mesh(com.ardor3d.scenegraph.Mesh) MaterialState(com.ardor3d.renderer.state.MaterialState) BlendState(com.ardor3d.renderer.state.BlendState)

Example 4 with MaterialState

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

the class SolarPanel 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(colorOption) {
            case COLOR_OPTION_BLACK:
                material.setDiffuse(ColorRGBA.BLACK);
                break;
            case COLOR_OPTION_BLUE:
                material.setDiffuse(ColorRGBA.BLUE);
                break;
            case 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 5 with MaterialState

use of com.ardor3d.renderer.state.MaterialState 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)

Aggregations

MaterialState (com.ardor3d.renderer.state.MaterialState)5 Mesh (com.ardor3d.scenegraph.Mesh)4 ColorRGBA (com.ardor3d.math.ColorRGBA)2 BlendState (com.ardor3d.renderer.state.BlendState)2 BoundingBox (com.ardor3d.bounding.BoundingBox)1 ReadOnlyColorRGBA (com.ardor3d.math.type.ReadOnlyColorRGBA)1 OffsetState (com.ardor3d.renderer.state.OffsetState)1 Line (com.ardor3d.scenegraph.Line)1 Quad (com.ardor3d.scenegraph.shape.Quad)1