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) 

Source Link

Document

Constructs a PolygonAttributes object with specified values.

Usage

From source file:PickCollisionTest.java

protected void addCube(BranchGroup bg, double x, double y, double z, double sx, double sy, double sz,
        String name, boolean wireframe) {
    // create four ColorCube objects
    TransformGroup cubeTg = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setTranslation(new Vector3d(x, y, z));
    t3d.setScale(new Vector3d(sx, sy, sz));
    cubeTg.setTransform(t3d);/*  w w  w.j ava2s .co m*/
    ColorCube cube = new ColorCube(1.0);

    // we have to make the front face wireframe
    // or we can't see inside the box!
    if (wireframe) {
        Appearance app = new Appearance();
        app.setPolygonAttributes(
                new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
        cube.setAppearance(app);
    }

    cubeTg.addChild(cube);
    recursiveSetUserData(cubeTg, name);

    bg.addChild(cubeTg);
}

From source file:PolygonOffset.java

public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // Create the transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime. Add it to the
    // root of the subgraph.
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objRoot.addChild(objTrans);/*from  ww w.j  a  v a2 s .  c o m*/

    // Create a Sphere. We will display this as both wireframe and
    // solid to make a hidden line display
    // wireframe
    Appearance wireApp = new Appearance();

    ColoringAttributes wireCa = new ColoringAttributes();
    wireCa.setColor(black);
    wireApp.setColoringAttributes(wireCa);
    wirePa = new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_BACK, 0.0f);
    wireApp.setPolygonAttributes(wirePa);
    Sphere outWireSphere = new Sphere(sphereRadius, 0, 15, wireApp);
    objTrans.addChild(outWireSphere);

    // solid
    ColoringAttributes outCa = new ColoringAttributes(red, ColoringAttributes.SHADE_FLAT);
    Appearance outSolid = new Appearance();
    outSolid.setColoringAttributes(outCa);
    solidPa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_BACK, 0.0f);
    solidPa.setPolygonOffsetFactor(dynamicOffset);
    solidPa.setPolygonOffset(staticOffset);
    solidPa.setCapability(PolygonAttributes.ALLOW_OFFSET_WRITE);
    outSolid.setPolygonAttributes(solidPa);
    Sphere outSolidSphere = new Sphere(sphereRadius, 0, 15, outSolid);
    objTrans.addChild(outSolidSphere);

    innerTG = new TransformGroup();
    innerTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    scale = new Transform3D();
    updateInnerScale();
    objTrans.addChild(innerTG);

    // Create a smaller sphere to go inside. This sphere has a different
    // tesselation and color
    Sphere inWireSphere = new Sphere(sphereRadius, 0, 10, wireApp);
    innerTG.addChild(inWireSphere);

    // inside solid
    ColoringAttributes inCa = new ColoringAttributes(blue, ColoringAttributes.SHADE_FLAT);
    Appearance inSolid = new Appearance();
    inSolid.setColoringAttributes(inCa);
    inSolid.setPolygonAttributes(solidPa);
    Sphere inSolidSphere = new Sphere(sphereRadius, 0, 10, inSolid);
    innerTG.addChild(inSolidSphere);

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    AxisAngle4f axisAngle = new AxisAngle4f(0.0f, 0.0f, 1.0f, -(float) Math.PI / 2.0f);
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 80000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
    rotator.setSchedulingBounds(bounds);
    objTrans.addChild(rotator);

    // set up a white background
    Background bgWhite = new Background(new Color3f(1.0f, 1.0f, 1.0f));
    bgWhite.setApplicationBounds(bounds);
    objTrans.addChild(bgWhite);

    // Have Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
}

From source file:TextureTest.java

protected Shape3D createTextureGeometry(String szFile, boolean bWireframe) {
    // load all the texture data from the file and create the geometry
    // coordinates
    TextureGeometryInfo texInfo = createTextureCoordinates(szFile);

    if (texInfo == null) {
        System.err.println("Could not load texture info for file:" + szFile);
        return null;
    }/*  w  w w  .  j  a v  a  2s . c  o  m*/

    // print some stats on the loaded file
    System.out.println("Loaded File: " + szFile);
    System.out.println("   Texture image: " + texInfo.m_szImage);
    System.out.println("   Texture coordinates: " + texInfo.m_TexCoordArray.length);

    // create an Appearance and assign a Material
    Appearance app = new Appearance();

    PolygonAttributes polyAttribs = null;

    // create the PolygonAttributes and attach to the Appearance,
    // note that we use CULL_NONE so that the "rear" side of the geometry
    // is visible with the applied texture image
    if (bWireframe == false)
        polyAttribs = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_NONE, 0);
    else
        polyAttribs = new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0);

    app.setPolygonAttributes(polyAttribs);

    // load the texture image and assign to the appearance
    TextureLoader texLoader = new TextureLoader(texInfo.m_szImage, Texture.RGB, this);
    Texture tex = texLoader.getTexture();
    app.setTexture(tex);

    // create a GeometryInfo for the QuadArray that was populated.
    GeometryInfo gi = new GeometryInfo(GeometryInfo.POLYGON_ARRAY);
    gi.setCoordinates(texInfo.m_CoordArray);
    gi.setTextureCoordinates(texInfo.m_TexCoordArray);

    // use the triangulator utility to triangulate the polygon
    int[] stripCountArray = { texInfo.m_CoordArray.length };
    int[] countourCountArray = { stripCountArray.length };

    gi.setContourCounts(countourCountArray);
    gi.setStripCounts(stripCountArray);

    Triangulator triangulator = new Triangulator();
    triangulator.triangulate(gi);

    // generate normal vectors for the triangles, not
    // strictly necessary as we are not lighting the scene
    // but generally useful
    NormalGenerator normalGenerator = new NormalGenerator();
    normalGenerator.generateNormals(gi);

    // wrap the GeometryArray in a Shape3D and assign appearance
    return new Shape3D(gi.getGeometryArray(), app);
}

From source file:BooksDemo.java

private Appearance createTexture(String fileName) {
    Image sourceImage = UIHelper.readImage(fileName);
    if (sourceImage == null)
        System.out.println("Image could not be loaded from " + fileName);

    TextureLoader loader = new TextureLoader(sourceImage, this);
    ImageComponent2D image = loader.getImage();

    if (image == null)
        System.out.println("Texture could not be loaded from " + fileName);

    Texture2D texture = new Texture2D(Texture.BASE_LEVEL, Texture.RGBA, image.getWidth(), image.getHeight());
    texture.setImage(0, image);/*from w  w  w  . j a  va2s  . com*/
    texture.setEnable(true);
    texture.setMagFilter(Texture.BASE_LEVEL_LINEAR);
    texture.setMinFilter(Texture.BASE_LEVEL_LINEAR);

    Appearance appearance = new Appearance();
    PolygonAttributes polyAttributes = new PolygonAttributes(PolygonAttributes.POLYGON_FILL,
            PolygonAttributes.CULL_NONE, 0f);
    appearance.setPolygonAttributes(polyAttributes);
    appearance.setTexture(texture);

    TextureAttributes textureAttributes = new TextureAttributes();
    appearance.setTextureAttributes(textureAttributes);

    return appearance;
}

From source file:ViewProj.java

public BranchGroup createSceneGraph() {
    // Create the root of the branch graph
    BranchGroup objRoot = new BranchGroup();

    // Create the transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime. Add it to the
    // root of the subgraph.
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objRoot.addChild(objTrans);//from w  w w  . j av  a 2  s .  c om

    // Create a Sphere. We will display this as both wireframe and
    // solid to make a hidden line display
    // wireframe
    Appearance wireApp = new Appearance();
    ColoringAttributes ca = new ColoringAttributes(black, ColoringAttributes.SHADE_FLAT);
    wireApp.setColoringAttributes(ca);
    wirePa = new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_BACK, 0.0f);
    wireApp.setPolygonAttributes(wirePa);
    Sphere outWireSphere = new Sphere(sphereRadius, 0, 10, wireApp);
    objTrans.addChild(outWireSphere);

    // solid
    ColoringAttributes outCa = new ColoringAttributes(red, ColoringAttributes.SHADE_FLAT);
    Appearance outSolid = new Appearance();
    outSolid.setColoringAttributes(outCa);
    solidPa = new PolygonAttributes(PolygonAttributes.POLYGON_FILL, PolygonAttributes.CULL_BACK, 0.0f);
    solidPa.setPolygonOffsetFactor(dynamicOffset);
    solidPa.setPolygonOffset(staticOffset);
    solidPa.setCapability(PolygonAttributes.ALLOW_OFFSET_WRITE);
    outSolid.setPolygonAttributes(solidPa);
    Sphere outSolidSphere = new Sphere(sphereRadius, 0, 10, outSolid);
    objTrans.addChild(outSolidSphere);

    innerTG = new TransformGroup();
    innerTG.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    scale = new Transform3D();
    updateInnerScale();
    objTrans.addChild(innerTG);

    // Create a smaller sphere to go inside. This sphere has a different
    // tesselation and color
    Sphere inWireSphere = new Sphere(sphereRadius, 0, 15, wireApp);
    innerTG.addChild(inWireSphere);

    // inside solid
    ColoringAttributes inCa = new ColoringAttributes(blue, ColoringAttributes.SHADE_FLAT);
    Appearance inSolid = new Appearance();
    inSolid.setColoringAttributes(inCa);
    inSolid.setPolygonAttributes(solidPa);
    Sphere inSolidSphere = new Sphere(sphereRadius, 0, 15, inSolid);
    innerTG.addChild(inSolidSphere);

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    AxisAngle4f axisAngle = new AxisAngle4f(0.0f, 0.0f, 1.0f, -(float) Math.PI / 2.0f);
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 80000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
    rotator.setSchedulingBounds(bounds);
    //objTrans.addChild(rotator);

    Background bgWhite = new Background(white);
    bgWhite.setApplicationBounds(bounds);
    objTrans.addChild(bgWhite);

    // Have Java 3D perform optimizations on this scene graph.
    objRoot.compile();

    return objRoot;
}

From source file:MouseNavigateTest.java

protected BranchGroup createSceneBranchGroup() {
    BranchGroup objRoot = super.createSceneBranchGroup();

    // note that we are creating a TG *above* the TG
    // the is being controlled by the mouse behaviors.
    // The SUN mouse translate behavior would fail in this
    // instance as all movement would be in the X-Y plane
    // irrespective of any TG above the object.
    // The TornadoMouseTranslate behavior always moves an object
    // parrallel to the image plane
    TransformGroup objTrans1 = new TransformGroup();
    Transform3D t3d = new Transform3D();
    objTrans1.getTransform(t3d);/*from   w  w  w  .ja va2  s  .  co  m*/
    t3d.setEuler(new Vector3d(0.9, 0.8, 0.3));
    objTrans1.setTransform(t3d);

    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // create the mouse scale behavior and set limits
    TornadoMouseScale mouseScale = new TornadoMouseScale(5, 0.1f);
    mouseScale.setMinScale(new Point3d(0.5, 0.5, 0.5));
    mouseScale.setMaxScale(new Point3d(2, 2, 2));
    mouseScale.setObject(objTrans);
    mouseScale.setChangeListener(this);
    mouseScale.setSchedulingBounds(getApplicationBounds());
    objTrans.addChild(mouseScale);

    // create the mouse rotate behavior
    TornadoMouseRotate mouseRotate = new TornadoMouseRotate(0.001, 0.001);
    mouseRotate.setInvert(true);
    mouseRotate.setObject(objTrans);
    mouseRotate.setChangeListener(this);
    mouseRotate.setSchedulingBounds(getApplicationBounds());
    objTrans.addChild(mouseRotate);

    // create the mouse translate behavior and set limits
    TornadoMouseTranslate mouseTrans = new TornadoMouseTranslate(0.005f);
    mouseTrans.setObject(objTrans);
    mouseTrans.setChangeListener(this);
    mouseTrans.setMinTranslate(new Point3d(-4, -4, -4));
    mouseTrans.setMaxTranslate(new Point3d(4, 4, 4));
    mouseTrans.setSchedulingBounds(getApplicationBounds());
    objTrans.addChild(mouseTrans);

    objTrans.addChild(new ColorCube(0.5));

    // create some axis for the world to show it has been rotated
    ColorCube axis = new ColorCube(5.0);
    Appearance app = new Appearance();
    app.setPolygonAttributes(
            new PolygonAttributes(PolygonAttributes.POLYGON_LINE, PolygonAttributes.CULL_NONE, 0));
    axis.setAppearance(app);
    objTrans1.addChild(axis);

    objTrans1.addChild(objTrans);
    objRoot.addChild(objTrans1);

    return objRoot;
}

From source file:AppearanceExplorer.java

void setupAppearance() {
    appearance = new Appearance();

    // ColoringAttributes
    coloringColor = new Color3f(red);
    coloringAttr = new ColoringAttributes(coloringColor, coloringShadeModel);
    coloringAttr.setCapability(ColoringAttributes.ALLOW_COLOR_WRITE);
    coloringAttr.setCapability(ColoringAttributes.ALLOW_SHADE_MODEL_WRITE);
    appearance.setColoringAttributes(coloringAttr);

    // set up the editor
    coloringAttrEditor = new ColoringAttributesEditor(coloringAttr);

    // PointAttributes
    pointAttr = new PointAttributes(pointSize, pointAAEnable);
    pointAttr.setCapability(PointAttributes.ALLOW_SIZE_WRITE);
    pointAttr.setCapability(PointAttributes.ALLOW_ANTIALIASING_WRITE);
    appearance.setPointAttributes(pointAttr);

    // set up the editor
    pointAttrEditor = new PointAttributesEditor(pointAttr);

    // LineAttributes
    lineAttr = new LineAttributes(lineWidth, linePattern, lineAAEnable);
    lineAttr.setCapability(LineAttributes.ALLOW_WIDTH_WRITE);
    lineAttr.setCapability(LineAttributes.ALLOW_PATTERN_WRITE);
    lineAttr.setCapability(LineAttributes.ALLOW_ANTIALIASING_WRITE);
    appearance.setLineAttributes(lineAttr);

    // set up the editor
    lineAttrEditor = new LineAttributesEditor(lineAttr);

    // PolygonAttributes
    polygonAttr = new PolygonAttributes(polygonMode, polygonCull, 0.0f);
    polygonAttr.setPolygonOffset(polygonOffsetBias);
    polygonAttr.setPolygonOffsetFactor(polygonOffsetFactor);
    polygonAttr.setCapability(PolygonAttributes.ALLOW_MODE_WRITE);
    polygonAttr.setCapability(PolygonAttributes.ALLOW_CULL_FACE_WRITE);
    polygonAttr.setCapability(PolygonAttributes.ALLOW_OFFSET_WRITE);
    appearance.setPolygonAttributes(polygonAttr);

    // set up the editor
    polygonAttrEditor = new PolygonAttributesEditor(polygonAttr);

    // Rendering attributes
    renderAttr = new RenderingAttributes(renderDepthBuffer, renderDepthBufferWrite, 0.0f,
            RenderingAttributes.ALWAYS, renderVisible, renderIgnoreVertexColor, renderRasterOpEnable,
            renderRasterOp);/*from  www  .j  a  v a2  s. c  o m*/
    renderAttr.setCapability(RenderingAttributes.ALLOW_IGNORE_VERTEX_COLORS_WRITE);
    renderAttr.setCapability(RenderingAttributes.ALLOW_VISIBLE_WRITE);
    renderAttr.setCapability(RenderingAttributes.ALLOW_RASTER_OP_WRITE);
    renderAttr.setCapability(RenderingAttributes.ALLOW_ALPHA_TEST_FUNCTION_WRITE);
    renderAttr.setCapability(RenderingAttributes.ALLOW_ALPHA_TEST_VALUE_WRITE);
    appearance.setRenderingAttributes(renderAttr);
    appearance.setCapability(Appearance.ALLOW_RENDERING_ATTRIBUTES_WRITE);

    // set up the editor
    renderAttrEditor = new RenderingAttributesEditor(renderAttr);

    // TransparencyAttributes
    transpAttr = new TransparencyAttributes(transpMode, transpValue);
    transpAttr.setCapability(TransparencyAttributes.ALLOW_MODE_WRITE);
    transpAttr.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
    transpAttr.setCapability(TransparencyAttributes.ALLOW_BLEND_FUNCTION_WRITE);
    appearance.setTransparencyAttributes(transpAttr);

    // set up the editor
    transpAttrEditor = new TransparencyAttributesEditor(transpAttr);

    // Material
    material = new Material(red, black, red, white, 20.f);
    material.setLightingEnable(false);
    material.setCapability(Material.ALLOW_COMPONENT_WRITE);
    appearance.setMaterial(material);

    // material presets
    String[] materialNames = { "Red", "White", "Red Ambient", "Red Diffuse", "Grey Emissive", "White Specular",
            "Aluminium", "Blue Plastic", "Copper", "Gold", "Red Alloy", "Black Onyx" };
    Material[] materialPresets = new Material[materialNames.length];
    materialPresets[0] = new Material(red, black, red, white, 20.0f);
    materialPresets[1] = new Material(white, black, white, white, 20.0f);
    materialPresets[2] = new Material(red, black, black, black, 20.0f);
    materialPresets[3] = new Material(black, black, red, black, 20.0f);
    materialPresets[4] = new Material(black, grey, black, black, 20.0f);
    materialPresets[5] = new Material(black, black, black, white, 20.0f);
    Color3f alum = new Color3f(0.37f, 0.37f, 0.37f);
    Color3f alumSpec = new Color3f(0.89f, 0.89f, 0.89f);
    materialPresets[6] = new Material(alum, black, alum, alumSpec, 17);
    Color3f bluePlastic = new Color3f(0.20f, 0.20f, 0.70f);
    Color3f bluePlasticSpec = new Color3f(0.85f, 0.85f, 0.85f);
    materialPresets[7] = new Material(bluePlastic, black, bluePlastic, bluePlasticSpec, 22);
    Color3f copper = new Color3f(0.30f, 0.10f, 0.00f);
    ;
    Color3f copperSpec = new Color3f(0.75f, 0.30f, 0.00f);
    materialPresets[8] = new Material(copper, black, copper, copperSpec, 10);
    Color3f gold = new Color3f(0.49f, 0.34f, 0.00f);
    Color3f goldSpec = new Color3f(0.89f, 0.79f, 0.00f);
    materialPresets[9] = new Material(gold, black, gold, goldSpec, 15);
    Color3f redAlloy = new Color3f(0.34f, 0.00f, 0.34f);
    Color3f redAlloySpec = new Color3f(0.84f, 0.00f, 0.00f);
    materialPresets[10] = new Material(redAlloy, black, redAlloy, redAlloySpec, 15);
    Color3f blackOnyxSpec = new Color3f(0.72f, 0.72f, 0.72f);
    materialPresets[11] = new Material(black, black, black, blackOnyxSpec, 23);

    // set up the editor
    materialEditor = new MaterialPresetEditor(material, materialNames, materialPresets);

    // Texture2D

    // set the values to the defaults
    texEnable = false;
    texMipMapMode = Texture.BASE_LEVEL;
    texBoundaryModeS = Texture.WRAP;
    texBoundaryModeT = Texture.WRAP;
    texMinFilter = Texture.BASE_LEVEL_POINT;
    texMagFilter = Texture.BASE_LEVEL_POINT;
    texBoundaryColor = new Color4f(0.0f, 0.0f, 0.0f, 0.0f);

    // set up the image choices
    String[] texImageNames = { "Earth", "Fish", };
    String[] texImageFileNames = { "earth.jpg", "fish1.gif", };
    int texImageFileIndex = 0;

    // set up the appearance to allow the texture to be changed
    appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);

    // set up the editor (this will create the initial Texture2D and
    // assign it to the appearance)
    texture2DEditor = new Texture2DEditor(appearance, codeBaseString, texImageNames, texImageFileNames,
            texImageFileIndex, texEnable, texBoundaryModeS, texBoundaryModeT, texMinFilter, texMagFilter,
            texMipMapMode, texBoundaryColor);

    // TextureAttributes
    texMode = TextureAttributes.REPLACE;
    texBlendColor = new Color4f(1.0f, 1.0f, 1.0f, 1.0f);
    texTransform = new Transform3D();
    texPerspCorrect = TextureAttributes.NICEST;
    textureAttr = new TextureAttributes(texMode, texTransform, texBlendColor, texPerspCorrect);

    // set the capabilities to allow run time changes
    textureAttr.setCapability(TextureAttributes.ALLOW_MODE_WRITE);
    textureAttr.setCapability(TextureAttributes.ALLOW_BLEND_COLOR_WRITE);
    textureAttr.setCapability(TextureAttributes.ALLOW_TRANSFORM_WRITE);

    // connect it to the appearance
    appearance.setTextureAttributes(textureAttr);

    // setup the editor
    textureAttrEditor = new TextureAttributesEditor(textureAttr);

    // set up the tex coordinate generation
    texGenEnable = false;
    texGenMode = TexCoordGeneration.OBJECT_LINEAR;
    texGenPlaneS = new Vector4f(1.0f, 0.0f, 0.0f, 0.0f);
    texGenPlaneT = new Vector4f(0.0f, 1.0f, 0.0f, 0.0f);

    // set the appearance so that we can replace the tex gen when live
    appearance.setCapability(Appearance.ALLOW_TEXGEN_WRITE);

    // setup the editor
    texGenEditor = new TexCoordGenerationEditor(appearance, texGenEnable, texGenMode, texGenPlaneS,
            texGenPlaneT);

}

From source file:BehaviorTest.java

public void processStimulus(java.util.Enumeration criteria) {
    while (criteria.hasMoreElements()) {
        WakeupCriterion wakeUp = (WakeupCriterion) criteria.nextElement();

        if (wakeUp instanceof WakeupOnElapsedTime) {
            // we are starting the explosion, apply the
            // appearance changes we require
            PolygonAttributes polyAttribs = new PolygonAttributes(PolygonAttributes.POLYGON_POINT,
                    PolygonAttributes.CULL_NONE, 0);
            m_Shape3D.getAppearance().setPolygonAttributes(polyAttribs);

            PointAttributes pointAttribs = new PointAttributes(3, false);
            m_Shape3D.getAppearance().setPointAttributes(pointAttribs);

            m_Shape3D.getAppearance().setTexture(null);

            m_TransparencyAttributes = new TransparencyAttributes(TransparencyAttributes.NICEST, 0);
            m_TransparencyAttributes.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
            m_Shape3D.getAppearance().setTransparencyAttributes(m_TransparencyAttributes);
        } else {// w w w  .  j a v a 2 s. c om
            // we are mid explosion, modify the GeometryArray
            m_nFrameNumber++;

            m_GeometryArray.getCoordinates(0, m_CoordinateArray);

            m_TransparencyAttributes.setTransparency(((float) m_nFrameNumber) / ((float) m_nNumFrames));
            m_Shape3D.getAppearance().setTransparencyAttributes(m_TransparencyAttributes);

            for (int n = 0; n < m_CoordinateArray.length; n += 3) {
                m_Vector.x = m_CoordinateArray[n];
                m_Vector.y = m_CoordinateArray[n + 1];
                m_Vector.z = m_CoordinateArray[n + 2];

                m_Vector.normalize();

                m_CoordinateArray[n] += m_Vector.x * Math.random() + Math.random();
                m_CoordinateArray[n + 1] += m_Vector.y * Math.random() + Math.random();
                m_CoordinateArray[n + 2] += m_Vector.z * Math.random() + Math.random();
            }

            // assign the new coordinates
            m_GeometryArray.setCoordinates(0, m_CoordinateArray);
        }
    }

    if (m_nFrameNumber < m_nNumFrames) {
        // assign the next WakeUpCondition, so we are notified again
        wakeupOn(m_FrameWakeupCondition);
    } else {
        // we are at the end of the explosion
        // reapply the original appearance and GeometryArray
        // coordinates
        setEnable(false);
        m_Shape3D.setAppearance(m_Appearance);

        m_GeometryArray.setCoordinates(0, m_OriginalCoordinateArray);

        m_OriginalCoordinateArray = null;
        m_GeometryArray = null;
        m_CoordinateArray = null;
        m_TransparencyAttributes = null;

        // if we have a listener notify them that we are done
        if (m_Listener != null)
            wakeupOn(m_Listener.onExplosionFinished(this, m_Shape3D));
    }
}