Example usage for javax.media.j3d Alpha Alpha

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

Introduction

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

Prototype

public Alpha(int loopCount, int mode, long triggerTime, long phaseDelayDuration, long increasingAlphaDuration,
        long increasingAlphaRampDuration, long alphaAtOneDuration, long decreasingAlphaDuration,
        long decreasingAlphaRampDuration, long alphaAtZeroDuration) 

Source Link

Document

This constructor takes all of the Alpha user-definable parameters.

Usage

From source file:Morphing.java

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

    // Create a Transformgroup to scale all objects so they
    // appear in the scene.
    TransformGroup objScale = new TransformGroup();
    Transform3D t3d = new Transform3D();
    t3d.setScale(0.4);//  w ww  .ja  v a  2s.  c om
    objScale.setTransform(t3d);
    objRoot.addChild(objScale);

    // Create a bounds for the background and lights
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // Set up the background
    Color3f bgColor = new Color3f(0.05f, 0.05f, 0.2f);
    Background bg = new Background(bgColor);
    bg.setApplicationBounds(bounds);
    objScale.addChild(bg);

    // Set up the global lights
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
    Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);

    AmbientLight aLgt = new AmbientLight(alColor);
    aLgt.setInfluencingBounds(bounds);
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
    lgt1.setInfluencingBounds(bounds);
    objScale.addChild(aLgt);
    objScale.addChild(lgt1);

    //
    // Create the transform group nodes for the 3 original objects
    // and the morphed object. Add them to the root of the
    // branch graph.
    //
    TransformGroup objTrans[] = new TransformGroup[4];

    for (int i = 0; i < 4; i++) {
        objTrans[i] = new TransformGroup();
        objScale.addChild(objTrans[i]);
    }

    Transform3D tr = new Transform3D();
    Transform3D rotX90 = new Transform3D();
    rotX90.rotX(90.0 * Math.PI / 180.0);

    objTrans[0].getTransform(tr);
    tr.setTranslation(new Vector3d(-2.0, 1.5, -2.0));
    tr.mul(rotX90);
    objTrans[0].setTransform(tr);

    objTrans[1].getTransform(tr);
    tr.setTranslation(new Vector3d(0.0, 1.5, -2.0));
    tr.mul(rotX90);
    objTrans[1].setTransform(tr);

    objTrans[2].getTransform(tr);
    tr.setTranslation(new Vector3d(2.0, 1.5, -2.0));
    tr.mul(rotX90);
    objTrans[2].setTransform(tr);

    objTrans[3].getTransform(tr);
    tr.setTranslation(new Vector3d(0.0, -2.0, -2.0));
    tr.mul(rotX90);
    objTrans[3].setTransform(tr);

    // Now load the object files
    Scene s[] = new Scene[3];
    GeometryArray g[] = new GeometryArray[3];
    Shape3D shape[] = new Shape3D[3];
    ObjectFile loader = new ObjectFile(ObjectFile.RESIZE);
    for (int i = 0; i < 3; i++) {
        s[i] = null;
        g[i] = null;
        shape[i] = null;
    }

    for (int i = 0; i < 3; i++) {
        try {
            s[i] = loader.load(objFiles[i]);
        } catch (FileNotFoundException e) {
            System.err.println(e);
            System.exit(1);
        } catch (ParsingErrorException e) {
            System.err.println(e);
            System.exit(1);
        } catch (IncorrectFormatException e) {
            System.err.println(e);
            System.exit(1);
        }

        BranchGroup b = s[i].getSceneGroup();
        shape[i] = (Shape3D) b.getChild(0);
        g[i] = (GeometryArray) shape[i].getGeometry();

        shape[i].setGeometry(g[i]);
        objTrans[i].addChild(b);
    }

    //
    // Create a Morph node, and set the appearance and input geometry
    // arrays. Set the Morph node's capability bits to allow the weights
    // to be modified at runtime.
    //
    Appearance app = new Appearance();
    Color3f objColor = new Color3f(1.0f, 0.7f, 0.8f);
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    app.setMaterial(new Material(objColor, black, objColor, black, 80.0f));
    Morph morph = new Morph(g, app);
    morph.setCapability(Morph.ALLOW_WEIGHTS_READ);
    morph.setCapability(Morph.ALLOW_WEIGHTS_WRITE);

    objTrans[3].addChild(morph);

    // Now create the Alpha object that controls the speed of the
    // morphing operation.
    Alpha morphAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 2000, 1000, 200,
            2000, 1000, 200);

    // Finally, create the morphing behavior
    MorphingBehavior mBeh = new MorphingBehavior(morphAlpha, morph);
    mBeh.setSchedulingBounds(bounds);
    objScale.addChild(mBeh);

    return objRoot;
}

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);/*w w w . j a  v  a  2s  . co 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 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:SwingTest.java

/**
 * Create the scene side of the scenegraph
 *//*from   w  w  w  .ja va  2s .  c  om*/
protected BranchGroup createSceneBranchGroup() {
    // create the root of the scene side scenegraph
    BranchGroup objRoot = new BranchGroup();

    // create a TransformGroup to rotate the objects in the scene
    // set the capability bits on the TransformGroup so that it
    // can be modified at runtime
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // create a spherical bounding volume
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // create a 4x4 transformation matrix
    Transform3D yAxis = new Transform3D();

    // create an Alpha interpolator to automatically generate
    // modifications to the rotation component of the transformation matrix
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    // create a RotationInterpolator behavior to effect the TransformGroup
    rotator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f, (float) Math.PI * 2.0f);

    // set the scheduling bounds on the behavior
    rotator.setSchedulingBounds(bounds);

    // add the behavior to the scenegraph
    objTrans.addChild(rotator);

    // create the BranchGroup which contains the objects
    // we add/remove to and from the scenegraph
    sceneBranchGroup = new BranchGroup();

    // allow the BranchGroup to have children added at runtime
    sceneBranchGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND);
    sceneBranchGroup.setCapability(Group.ALLOW_CHILDREN_READ);
    sceneBranchGroup.setCapability(Group.ALLOW_CHILDREN_WRITE);

    // add both the cube and the sphere to the scenegraph
    sceneBranchGroup.addChild(createCube());
    sceneBranchGroup.addChild(createSphere());

    // create the colors for the lights
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
    Vector3f lDir1 = new Vector3f(-1.0f, -1.0f, -1.0f);
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);

    // create the ambient light
    AmbientLight aLgt = new AmbientLight(alColor);
    aLgt.setInfluencingBounds(bounds);

    // create the directional light
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
    lgt1.setInfluencingBounds(bounds);

    // add the lights to the scenegraph
    objRoot.addChild(aLgt);
    objRoot.addChild(lgt1);

    // wire the scenegraph together
    objTrans.addChild(sceneBranchGroup);
    objRoot.addChild(objTrans);

    // return the root of the scene side of the scenegraph
    return objRoot;
}

From source file:SplineInterpolatorTest.java

public TransformGroup[] getViewTransformGroupArray() {
    TransformGroup[] tgArray = new TransformGroup[2];
    tgArray[0] = new TransformGroup();
    tgArray[1] = new TransformGroup();

    Transform3D t3d = new Transform3D();
    t3d.setScale(getScale());/*from w  w w  . j a v  a2 s .c o  m*/
    t3d.invert();
    tgArray[0].setTransform(t3d);

    // create an Alpha object for the Interpolator
    Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE | Alpha.DECREASING_ENABLE, 0, 0, 25000, 4000, 100,
            20000, 5000, 50);

    // ensure the Interpolator can access the TG
    tgArray[1].setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    try {
        // create the Interpolator and load the keyframes from disk
        RotPosScaleTCBSplinePathInterpolator splineInterpolator = Utils.createSplinePathInterpolator(
                new UiAlpha(alpha), tgArray[1], new Transform3D(),
                new URL(getWorkingDirectory(), "rotate_viewer_spline.xls"));

        // set the scheduling bounds and attach to the scenegraph
        splineInterpolator.setSchedulingBounds(getApplicationBounds());
        tgArray[1].addChild(splineInterpolator);
    } catch (Exception e) {
        System.err.println(e.toString());
    }

    return tgArray;
}

From source file:HiResCoordTest.java

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

    Transform3D t3dTilt = new Transform3D();
    t3dTilt.rotX(0.3);// w w w .  ja  va 2  s .  c  o  m

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

    TransformGroup objTransPlanets = new TransformGroup();
    objTransPlanets.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objTransPlanets, yAxis, 0.0f,
            (float) Math.PI * 2.0f);

    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), m_TranslateSunZ);
    rotator.setSchedulingBounds(bounds);
    objTransPlanets.addChild(rotator);

    // create the sun
    TransformGroup sunTg = createSun();

    // create Earth
    Transform3D t3dEarth = new Transform3D();
    t3dEarth.setScale(m_EarthRadius);
    t3dEarth.setTranslation(new Vector3d(m_EarthOrbit, 0, 0));
    objTransPlanets.addChild(createPlanet("Earth", new Color3f(0, 0.1f, 1.0f), t3dEarth, null));

    // create Mars
    Transform3D t3dMars = new Transform3D();
    t3dMars.setTranslation(
            new Vector3d(Math.sin(Math.PI * 1.5) * m_MarsOrbit, 0, Math.cos(Math.PI * 0.5) * m_MarsOrbit));
    t3dMars.setScale(m_MarsRadius);
    objTransPlanets.addChild(createPlanet("Mars", new Color3f(1, 0, 0), t3dMars, null));

    // create Mercury
    Transform3D t3dMercury = new Transform3D();
    t3dMercury.setTranslation(
            new Vector3d(Math.sin(Math.PI) * m_MercuryOrbit, 0, Math.cos(Math.PI) * m_MercuryOrbit));
    t3dMercury.setScale(m_MercuryRadius);
    objTransPlanets.addChild(createPlanet("Mercury", new Color3f(0.5f, 0.5f, 0.5f), t3dMercury, null));

    sunTg.addChild(objTransPlanets);
    objTrans.addChild(sunTg);
    objRoot.addChild(objTrans);

    return objRoot;
}

From source file:TextureTest.java

protected Interpolator createInterpolator(TransformGroup objTrans) {
    Transform3D t3d = new Transform3D();

    float[] knots = { 0.0f, 0.1f, 0.2f, 0.3f, 0.4f, 0.6f, 0.8f, 0.9f, 1.0f };
    Quat4f[] quats = new Quat4f[9];
    Point3f[] positions = new Point3f[9];

    AxisAngle4f axis = new AxisAngle4f(1.0f, 0.0f, 0.0f, 0.0f);
    t3d.set(axis);/*from  ww  w  . j  a va2 s. c om*/

    quats[0] = new Quat4f(0.3f, 1.0f, 1.0f, 0.0f);
    quats[1] = new Quat4f(1.0f, 0.0f, 0.0f, 0.3f);
    quats[2] = new Quat4f(0.2f, 1.0f, 0.0f, 0.0f);
    quats[3] = new Quat4f(0.0f, 0.2f, 1.0f, 0.0f);
    quats[4] = new Quat4f(1.0f, 0.0f, 0.4f, 0.0f);
    quats[5] = new Quat4f(0.0f, 1.0f, 1.0f, 0.2f);
    quats[6] = new Quat4f(0.3f, 0.3f, 0.0f, 0.0f);
    quats[7] = new Quat4f(1.0f, 0.0f, 1.0f, 1.0f);
    quats[8] = quats[0];

    positions[0] = new Point3f(0.0f, 0.0f, -1.0f);
    positions[1] = new Point3f(1.0f, -2.0f, -2.0f);
    positions[2] = new Point3f(-2.0f, 2.0f, -3.0f);
    positions[3] = new Point3f(1.0f, 1.0f, -4.0f);
    positions[4] = new Point3f(-4.0f, -2.0f, -5.0f);
    positions[5] = new Point3f(2.0f, 0.3f, -6.0f);
    positions[6] = new Point3f(-4.0f, 0.5f, -7.0f);
    positions[7] = new Point3f(0.0f, -1.5f, -4.0f);
    positions[8] = positions[0];

    Alpha alpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 10000, 0, 0, 0, 0, 0);

    RotPosPathInterpolator rotPosPath = new RotPosPathInterpolator(alpha, objTrans, t3d, knots, quats,
            positions);
    rotPosPath.setSchedulingBounds(createApplicationBounds());

    return rotPosPath;
}

From source file:ExAppearance.java

private Group createObject(Appearance app, double scale, double xpos, double ypos) {

    // Create a transform group node to scale and position the object.
    Transform3D t = new Transform3D();
    t.set(scale, new Vector3d(xpos, ypos, 0.0));
    TransformGroup objTrans = new TransformGroup(t);

    // Create a second transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime.
    TransformGroup spinTg = new TransformGroup();
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // Create a simple shape leaf node and set the appearance
    Shape3D shape = new Tetrahedron();
    shape.setAppearance(app);//from   w ww. ja  va2s  .  c o m

    // add it to the scene graph.
    spinTg.addChild(shape);

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 5000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, spinTg, 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);

    // Add the behavior and the transform group to the object
    objTrans.addChild(rotator);
    objTrans.addChild(spinTg);

    return objTrans;
}

From source file:TickTockPicking.java

private Group createObject(Appearance app, double scale, double xpos, double ypos) {

    // Create a transform group node to scale and position the object.
    Transform3D t = new Transform3D();
    t.set(scale, new Vector3d(xpos, ypos, 0.0));
    TransformGroup objTrans = new TransformGroup(t);

    // Create a second transform group node and initialize it to the
    // identity. Enable the TRANSFORM_WRITE capability so that
    // our behavior code can modify it at runtime.
    TransformGroup spinTg = new TransformGroup();
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    spinTg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // Create a simple shape leaf node and set the appearance
    Shape3D shape = new Tetrahedron();
    shape.setAppearance(app);//from   ww  w .ja v  a2  s.  c  om
    shape.setCapability(shape.ALLOW_APPEARANCE_READ);
    shape.setCapability(shape.ALLOW_APPEARANCE_WRITE);

    // add it to the scene graph.
    spinTg.addChild(shape);

    // Create a new Behavior object that will perform the desired
    // operation on the specified transform object and add it into
    // the scene graph.
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 5000, 0, 0, 0, 0, 0);

    RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, spinTg, 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);

    // Add the behavior and the transform group to the object
    objTrans.addChild(rotator);
    objTrans.addChild(spinTg);

    return objTrans;
}

From source file:HiResCoordTest.java

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

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

    Transform3D yAxis = new Transform3D();
    yAxis.rotZ(0.2);/*from w w w .  j  ava  2  s .  co m*/
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 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), m_TranslateSunZ);
    rotator.setSchedulingBounds(bounds);
    objTrans.addChild(rotator);

    Transform3D t3d = new Transform3D();
    t3d.setScale(m_EarthRadius);

    objTrans.addChild(createPlanet("Earth", new Color3f(0, 0.1f, 1), t3d, "earth.jpg"));
    objRoot.addChild(objTrans);

    return objRoot;
}

From source file:TextureByReference.java

public BranchGroup createSceneGraph() {

    // create the root of the branch group
    BranchGroup objRoot = new BranchGroup();

    // create the transform group node and initialize it
    // enable the TRANSFORM_WRITE capability so that it can be modified
    // at runtime. Add it to the root of the subgraph
    Transform3D rotate = new Transform3D();
    TransformGroup objTrans = new TransformGroup(rotate);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objRoot.addChild(objTrans);// w  w  w  .  j  a  va 2 s .  c  o  m

    // bounds
    BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);

    // set up some light
    Color3f lColor1 = new Color3f(0.7f, 0.7f, 0.7f);
    Vector3f lDir1 = new Vector3f(-1.0f, -0.5f, -1.0f);
    Color3f alColor = new Color3f(0.2f, 0.2f, 0.2f);

    AmbientLight aLgt = new AmbientLight(alColor);
    aLgt.setInfluencingBounds(bounds);
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
    lgt1.setInfluencingBounds(bounds);
    objRoot.addChild(aLgt);
    objRoot.addChild(lgt1);

    Appearance appearance = new Appearance();

    // enable the TEXTURE_WRITE so we can modify it at runtime
    appearance.setCapability(Appearance.ALLOW_TEXTURE_WRITE);

    // load the first texture
    TextureLoader loader = new TextureLoader(urls[0], TextureLoader.BY_REFERENCE | TextureLoader.Y_UP, this);
    // get the texture from the loader
    Texture2D tex = (Texture2D) loader.getTexture();

    // get the BufferedImage to convert to TYPE_4BYTE_ABGR and flip
    // get the ImageComponent because we need it anyway
    ImageComponent2D imageComp = (ImageComponent2D) tex.getImage(0);
    BufferedImage bImage = imageComp.getImage();
    // convert the image
    bImage = ImageOps.convertImage(bImage, BufferedImage.TYPE_4BYTE_ABGR);
    // flip the image
    ImageOps.flipImage(bImage);
    imageComp.set(bImage);

    tex.setCapability(Texture.ALLOW_IMAGE_WRITE);
    tex.setBoundaryModeS(Texture.CLAMP);
    tex.setBoundaryModeT(Texture.CLAMP);
    tex.setBoundaryColor(1.0f, 1.0f, 1.0f, 1.0f);

    // set the image of the texture
    tex.setImage(0, imageComp);

    // set the texture on the appearance
    appearance.setTexture(tex);

    // set texture attributes
    TextureAttributes texAttr = new TextureAttributes();
    texAttr.setTextureMode(TextureAttributes.MODULATE);
    appearance.setTextureAttributes(texAttr);

    // set material properties
    Color3f black = new Color3f(0.0f, 0.0f, 0.0f);
    Color3f white = new Color3f(1.0f, 1.0f, 1.0f);
    appearance.setMaterial(new Material(white, black, white, black, 1.0f));

    // create a scale transform
    Transform3D scale = new Transform3D();
    scale.set(.6);
    TransformGroup objScale = new TransformGroup(scale);
    objTrans.addChild(objScale);

    tetra = new Tetrahedron(true);
    tetra.setAppearance(appearance);
    objScale.addChild(tetra);

    // create the behavior
    animate = new AnimateTexturesBehavior(tex, urls, appearance, this);
    animate.setSchedulingBounds(bounds);

    objTrans.addChild(animate);

    // add a rotation behavior so we can see all sides of the tetrahedron
    Transform3D yAxis = new Transform3D();
    Alpha rotorAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);
    RotationInterpolator rotator = new RotationInterpolator(rotorAlpha, objTrans, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    rotator.setSchedulingBounds(bounds);
    objTrans.addChild(rotator);

    // have java3d perform optimizations on this scene graph
    objRoot.compile();

    return objRoot;
}