Example usage for javax.media.j3d PolygonAttributes PolygonAttributes

List of usage examples for javax.media.j3d PolygonAttributes PolygonAttributes

Introduction

In this page you can find the example usage for javax.media.j3d PolygonAttributes PolygonAttributes.

Prototype

public PolygonAttributes(int polygonMode, int cullFace, float polygonOffset, boolean backFaceNormalFlip) 

Source Link

Document

Constructs PolygonAttributes object with specified values.

Usage

From source file:KeyNavigateTest.java

public Group createCeiling(Group g) {
    System.out.println("Creating ceiling");

    Group ceilingGroup = new Group();
    Land ceilingTile = null;//from  w w  w . j av a 2s .c om

    // because we are technically viewing the ceiling from below
    // we want to switch the normals using a PolygonAttributes.
    Appearance app = new Appearance();
    app.setPolygonAttributes(
            new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0, false));

    g.addChild(ceilingGroup);

    final double kNumTiles = 6;

    for (double x = -FLOOR_WIDTH + FLOOR_WIDTH / (2 * kNumTiles); x < FLOOR_WIDTH; x = x
            + FLOOR_WIDTH / kNumTiles) {
        for (double z = -FLOOR_LENGTH + FLOOR_LENGTH / (2 * kNumTiles); z < FLOOR_LENGTH; z = z
                + FLOOR_LENGTH / kNumTiles) {
            ceilingTile = new Land(this, g, ComplexObject.GEOMETRY | ComplexObject.TEXTURE);
            ceilingTile.createObject(app, new Vector3d(x, m_kCeilingLevel, z),
                    new Vector3d(FLOOR_WIDTH / (2 * kNumTiles), 1, FLOOR_LENGTH / (2 * kNumTiles)),
                    "ceiling.gif", null, null);
        }
    }

    return ceilingGroup;
}

From source file:KeyNavigateTest.java

void createWater(Group mapGroup, int nPixelX, int nPixelY) {
    Point3d point = convertToWorldCoordinatesPixelCenter(nPixelX, nPixelY);

    if (m_WaterAppearance == null) {
        m_WaterAppearance = new Appearance();
        m_WaterAppearance.setPolygonAttributes(
                new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0, false));
        m_WaterAppearance/*from   w w w  .ja v a2s  .  c o m*/
                .setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.BLENDED, 1.0f));
        m_WaterAppearance.setTextureAttributes(new TextureAttributes(TextureAttributes.REPLACE,
                new Transform3D(), new Color4f(0, 0, 0, 1), TextureAttributes.FASTEST));

    }

    Land water = new Land(this, mapGroup, ComplexObject.GEOMETRY | ComplexObject.TEXTURE);
    water.createObject(m_WaterAppearance, new Vector3d(point.x, m_kFloorLevel + 0.1, point.z),
            new Vector3d(40, 1, 40), "water.gif", null, null);
}

From source file:KeyNavigateTest.java

protected Group createGeometryGroup(Appearance app, Vector3d position, Vector3d scale, String szTextureFile,
        String szSoundFile) {/*from w w  w.j a v a2  s  . c  o m*/
    Group g = new Group();

    app.setPolygonAttributes(
            new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0, false));
    app.setTransparencyAttributes(new TransparencyAttributes(TransparencyAttributes.BLENDED, 1.0f));

    m_TextureAttributes = new TextureAttributes(TextureAttributes.REPLACE, new Transform3D(),
            new Color4f(0, 0, 0, 1), TextureAttributes.FASTEST);
    app.setTextureAttributes(m_TextureAttributes);

    if ((m_nFlags & ComplexObject.TEXTURE) == ComplexObject.TEXTURE)
        setTexture(app, szTextureFile);

    Cone cone = new Cone(1, 1, Primitive.GENERATE_TEXTURE_COORDS, app);

    g.addChild(cone);

    attachBehavior(new TextureAnimationBehavior(m_TextureAttributes));

    return g;
}