Search in sources :

Example 1 with Quad

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

the class Human method init.

@Override
protected void init() {
    super.init();
    final double h;
    final double w;
    switch(humanType) {
        case JANE:
            w = 2.5;
            h = 8;
            break;
        case JENI:
            w = 3;
            h = 9;
            break;
        case JILL:
            w = 3;
            h = 8;
            break;
        case JACK:
            w = 2.8;
            h = 9;
            break;
        case JOHN:
            w = 4;
            h = 10;
            break;
        case JOSE:
            w = 8;
            h = 8;
            break;
        default:
            w = 2.5;
            h = 8;
    }
    mesh = new Quad("Human Quad", w, h);
    mesh.setModelBound(new BoundingBox());
    mesh.updateModelBound();
    mesh.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
    // stand on the ground by default
    translate(w, h, feetHeight);
    mesh.setUserData(new UserData(this, 0, true));
    final BlendState bs = new BlendState();
    bs.setEnabled(true);
    bs.setBlendEnabled(false);
    bs.setTestEnabled(true);
    bs.setTestFunction(TestFunction.GreaterThan);
    bs.setReference(0.7f);
    mesh.setRenderState(bs);
    mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    billboard = new BillboardNode("Billboard");
    billboard.setAlignment(BillboardAlignment.AxialZ);
    billboard.attachChild(mesh);
    root.attachChild(billboard);
    updateTextureAndColor();
}
Also used : Quad(com.ardor3d.scenegraph.shape.Quad) BoundingBox(com.ardor3d.bounding.BoundingBox) BillboardNode(com.ardor3d.scenegraph.extension.BillboardNode) BlendState(com.ardor3d.renderer.state.BlendState) Matrix3(com.ardor3d.math.Matrix3)

Example 2 with Quad

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

the class Tree method init.

@Override
protected void init() {
    super.init();
    switch(treeType) {
        case COTTONWOOD:
            treeWidth = 80;
            treeHeight = 100;
            break;
        case LINDEN:
            treeWidth = 90;
            treeHeight = 120;
            break;
        case OAK:
            treeWidth = 70;
            treeHeight = 80;
            break;
        case ELM:
            treeWidth = 60;
            treeHeight = 75;
            break;
        case MAPLE:
            treeWidth = 30;
            treeHeight = 60;
            break;
        case PINE:
            treeWidth = 30;
            treeHeight = 80;
            break;
        default:
            treeWidth = 30;
            treeHeight = 40;
    }
    mesh = new Quad("Tree Quad", treeWidth, treeHeight);
    mesh.setModelBound(new BoundingBox());
    mesh.updateModelBound();
    mesh.setRotation(new Matrix3().fromAngles(Math.PI / 2, 0, 0));
    mesh.setTranslation(0, 0, treeHeight / 2.0);
    mesh.getSceneHints().setPickingHint(PickingHint.Pickable, false);
    final BlendState bs = new BlendState();
    bs.setEnabled(true);
    bs.setBlendEnabled(false);
    bs.setTestEnabled(true);
    bs.setTestFunction(TestFunction.GreaterThan);
    bs.setReference(0.7f);
    mesh.setRenderState(bs);
    mesh.getSceneHints().setRenderBucketType(RenderBucketType.Transparent);
    billboard = new BillboardNode("Billboard");
    billboard.setAlignment(BillboardAlignment.AxialZ);
    billboard.attachChild(mesh);
    root.attachChild(billboard);
    switch(treeType) {
        case PINE:
            // axis samples, radial samples, radius, height, closed
            crown = new Cone("Tree Crown", 2, 6, 18, 20, false);
            break;
        default:
            // z samples, radial samples, radius
            crown = new Sphere("Tree Crown", 4, 8, 14);
    }
    crown.setModelBound(new BoundingSphere());
    crown.updateModelBound();
    final Cylinder trunk = new Cylinder("Tree Trunk", 10, 10, 1, 20);
    trunk.setModelBound(new BoundingBox());
    trunk.updateModelBound();
    switch(treeType) {
        case COTTONWOOD:
            crown.setScale(3, 3, 3.5);
            crown.setTranslation(0, 0, 55);
            trunk.setScale(8, 8, 2);
            trunk.setTranslation(0, 0, 20);
            break;
        case LINDEN:
            crown.setScale(3.5, 3.5, 4);
            crown.setTranslation(0, 0, 65);
            trunk.setScale(5, 5, 2);
            trunk.setTranslation(0, 0, 20);
            break;
        case OAK:
            crown.setScale(2.5, 2.5, 3);
            crown.setTranslation(0, 0, 45);
            trunk.setScale(5, 5, 2);
            trunk.setTranslation(0, 0, 20);
            break;
        case ELM:
            crown.setScale(2, 2, 2.5);
            crown.setTranslation(0, 0, 40);
            trunk.setScale(2, 2, 2);
            trunk.setTranslation(0, 0, 20);
            break;
        case MAPLE:
            crown.setScale(1, 1, 2.1);
            crown.setTranslation(0, 0, 32);
            trunk.setTranslation(0, 0, 10);
            break;
        case PINE:
            crown.setScale(1, 1, -4.0);
            crown.setTranslation(0, 0, 45);
            trunk.setTranslation(0, 0, 10);
            break;
        default:
            crown.setScale(1, 1, 1.2);
            crown.setTranslation(0, 0, 24);
            trunk.setTranslation(0, 0, 10);
            break;
    }
    collisionRoot = new Node("Tree Collision Root");
    collisionRoot.attachChild(crown);
    collisionRoot.attachChild(trunk);
    if (points.size() > 0) {
        collisionRoot.setTranslation(getAbsPoint(0));
    }
    collisionRoot.updateWorldTransform(true);
    collisionRoot.updateWorldBound(true);
    collisionRoot.getSceneHints().setCullHint(showPolygons ? CullHint.Never : CullHint.Always);
    root.attachChild(collisionRoot);
    crown.setUserData(new UserData(this));
    trunk.setUserData(new UserData(this));
    updateTextureAndColor();
}
Also used : Sphere(com.ardor3d.scenegraph.shape.Sphere) BoundingSphere(com.ardor3d.bounding.BoundingSphere) Quad(com.ardor3d.scenegraph.shape.Quad) Cylinder(com.ardor3d.scenegraph.shape.Cylinder) Cone(com.ardor3d.scenegraph.shape.Cone) BoundingSphere(com.ardor3d.bounding.BoundingSphere) BoundingBox(com.ardor3d.bounding.BoundingBox) Node(com.ardor3d.scenegraph.Node) BillboardNode(com.ardor3d.scenegraph.extension.BillboardNode) BillboardNode(com.ardor3d.scenegraph.extension.BillboardNode) BlendState(com.ardor3d.renderer.state.BlendState) Matrix3(com.ardor3d.math.Matrix3)

Example 3 with Quad

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

Aggregations

BlendState (com.ardor3d.renderer.state.BlendState)3 Quad (com.ardor3d.scenegraph.shape.Quad)3 BoundingBox (com.ardor3d.bounding.BoundingBox)2 Matrix3 (com.ardor3d.math.Matrix3)2 BillboardNode (com.ardor3d.scenegraph.extension.BillboardNode)2 BoundingSphere (com.ardor3d.bounding.BoundingSphere)1 ColorRGBA (com.ardor3d.math.ColorRGBA)1 MaterialState (com.ardor3d.renderer.state.MaterialState)1 OffsetState (com.ardor3d.renderer.state.OffsetState)1 Node (com.ardor3d.scenegraph.Node)1 Cone (com.ardor3d.scenegraph.shape.Cone)1 Cylinder (com.ardor3d.scenegraph.shape.Cylinder)1 Sphere (com.ardor3d.scenegraph.shape.Sphere)1