Example usage for javax.media.j3d TransformGroup ALLOW_TRANSFORM_WRITE

List of usage examples for javax.media.j3d TransformGroup ALLOW_TRANSFORM_WRITE

Introduction

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

Prototype

int ALLOW_TRANSFORM_WRITE

To view the source code for javax.media.j3d TransformGroup ALLOW_TRANSFORM_WRITE.

Click Source Link

Document

Specifies that the node allows writing its object's transform information.

Usage

From source file:ScenegraphTest.java

private TransformGroup addLimb(Group parentGroup, String szName, double radius, double length, double rotMin,
        double rotMax) {
    // create the rotator
    TransformGroup tgJoint = new TransformGroup();
    tgJoint.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tgJoint.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // add a rotator if necessary
    if (rotMin != rotMax) {
        Transform3D xAxis = new Transform3D();
        xAxis.rotX(Math.PI / 2.0);
        Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

        RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, tgJoint, xAxis, (float) rotMin,
                (float) rotMax);
        rotator.setSchedulingBounds(createApplicationBounds());
        tgJoint.addChild(rotator);//from w  w w .j  a v  a2 s .  com
    }

    // create a cylinder using length and radius
    tgJoint.addChild(createLimb(radius, length));

    // create the joint (the *next* TG should
    // be offset by the length of this limb)
    TransformGroup tgOffset = new TransformGroup();

    Transform3D t3d = new Transform3D();
    t3d.setTranslation(new Vector3d(0, length, 0));
    tgOffset.setTransform(t3d);

    tgJoint.addChild(tgOffset);
    parentGroup.addChild(tgJoint);

    // return the offset TG, so any child TG's will be added
    // in the correct position.
    return tgOffset;
}

From source file:VrmlPickingTest.java

private TransformGroup createMouseBehaviorsGroup() {
    TransformGroup examineGroup = new TransformGroup();
    examineGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    examineGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    Bounds behaviorBounds = getApplicationBounds();

    MouseRotate mr = new MouseRotate(examineGroup);
    mr.setSchedulingBounds(behaviorBounds);
    examineGroup.addChild(mr);//from   ww w  .jav  a2  s.co  m

    MouseTranslate mt = new MouseTranslate(examineGroup);
    mt.setSchedulingBounds(behaviorBounds);
    examineGroup.addChild(mt);

    MouseZoom mz = new MouseZoom(examineGroup);
    mz.setSchedulingBounds(behaviorBounds);
    examineGroup.addChild(mz);

    return examineGroup;
}

From source file:DoorApp.java

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

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

    OpenBehavior openObject = new OpenBehavior(doorTG);
    CloseBehavior closeObject = new CloseBehavior(doorTG);

    //prepare the behavior objects
    openObject.setBehaviorObjectPartner(closeObject);
    closeObject.setBehaviorObjectPartner(openObject);

    // set scheduling bounds for behavior objects
    BoundingSphere bounds = new BoundingSphere();
    openObject.setSchedulingBounds(bounds);
    closeObject.setSchedulingBounds(bounds);

    // assemble scene graph
    objRoot.addChild(openObject);/*w  w  w .  ja  v a2 s.co  m*/
    objRoot.addChild(closeObject);
    objRoot.addChild(doorTG);
    doorTG.addChild(new ColorCube(0.4));

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

    return objRoot;
}

From source file:BehaviorTest.java

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

    // create a TransformGroup to rotate the hand
    TransformGroup objTrans = new TransformGroup();
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // create a RotationInterpolator behavior to rotate the hand
    Transform3D yAxis = new Transform3D();
    Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE, 0, 0, 4000, 0, 0, 0, 0, 0);

    m_RotationInterpolator = new RotationInterpolator(rotationAlpha, objTrans, yAxis, 0.0f,
            (float) Math.PI * 2.0f);
    m_RotationInterpolator.setSchedulingBounds(createApplicationBounds());
    objTrans.addChild(m_RotationInterpolator);

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

    TextureLoader tex = new TextureLoader("earth.jpg", this);
    app.setTexture(tex.getTexture());/*from   ww  w  . j ava2  s.c  om*/

    Sphere sphere = new Sphere(3, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS, 32, app);

    // connect the scenegraph
    objTrans.addChild(sphere);
    objRoot.addChild(objTrans);

    m_FpsBehavior = new FpsBehavior();
    m_FpsBehavior.setSchedulingBounds(getApplicationBounds());
    objRoot.addChild(m_FpsBehavior);

    m_BoundsBehavior = new BoundsBehavior(sphere);
    m_BoundsBehavior.setSchedulingBounds(getApplicationBounds());
    m_BoundsBehavior.addBehaviorToParentGroup(objTrans);

    m_StretchBehavior = new StretchBehavior((GeometryArray) sphere.getShape().getGeometry());
    m_StretchBehavior.setSchedulingBounds(getApplicationBounds());
    objRoot.addChild(m_StretchBehavior);
    m_StretchBehavior.setEnable(false);

    m_SizeBehavior = new ObjectSizeBehavior((GeometryArray) sphere.getShape().getGeometry());
    m_SizeBehavior.setSchedulingBounds(getApplicationBounds());
    objRoot.addChild(m_SizeBehavior);
    m_SizeBehavior.setEnable(false);

    m_ExplodeBehavior = new ExplodeBehavior(sphere.getShape(), 10000, 20, this);
    m_ExplodeBehavior.setSchedulingBounds(getApplicationBounds());
    objRoot.addChild(m_ExplodeBehavior);

    return objRoot;
}

From source file:Human1.java

void createHuman() {
    Human_body = new TransformGroup();

    // center the body
    tmpVector.set(0.0f, -1.5f, 0.0f);//from w  w w . j  a  va  2s .co m
    tmpTrans.set(tmpVector);
    Human_body.setTransform(tmpTrans);

    // Set up an appearance to make the body with red ambient,
    // black emmissive, red diffuse and white specular coloring
    Material material = new Material(red, black, red, white, 64);
    Appearance appearance = new Appearance();
    appearance.setMaterial(material);

    // offset and place the cylinder for the body
    tmpTG = new TransformGroup();
    // offset the shape
    tmpVector.set(0.0f, 1.5f, 0.0f);
    tmpTrans.set(tmpVector);
    tmpTG.setTransform(tmpTrans);
    tmpCyl = new Cylinder(0.75f, 3.0f, appearance);
    tmpTG.addChild(tmpCyl);

    // add the shape to the body
    Human_body.addChild(tmpTG);

    // create the r_shoulder TransformGroup
    Human_r_shoulder = new TransformGroup();
    Human_r_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    Human_r_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    // translate from the waist
    tmpVector.set(-0.95f, 2.9f, -0.2f);
    tmpTrans.set(tmpVector);
    Human_r_shoulder.setTransform(tmpTrans);

    // place the sphere for the r_shoulder
    tmpSphere = new Sphere(0.22f, appearance);
    Human_r_shoulder.addChild(tmpSphere);

    // offset and place the cylinder for the r_shoulder
    tmpTG = new TransformGroup();
    // offset the shape
    tmpVector.set(0.0f, -0.5f, 0.0f);
    tmpTrans.set(tmpVector);
    tmpTG.setTransform(tmpTrans);
    tmpCyl = new Cylinder(0.2f, 1.0f, appearance);
    tmpTG.addChild(tmpCyl);

    // add the shape to the r_shoulder
    Human_r_shoulder.addChild(tmpTG);

    // add the shoulder to the body group
    Human_body.addChild(Human_r_shoulder);

    // create the r_elbow TransformGroup
    Human_r_elbow = new TransformGroup();
    Human_r_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    Human_r_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tmpVector.set(0.0f, -1.054f, 0.0f);
    tmpTrans.set(tmpVector);
    Human_r_elbow.setTransform(tmpTrans);

    // place the sphere for the r_elbow
    tmpSphere = new Sphere(0.22f, appearance);
    Human_r_elbow.addChild(tmpSphere);

    // offset and place the cylinder for the r_shoulder
    tmpTG = new TransformGroup();
    // offset the shape
    tmpVector.set(0.0f, -0.5f, 0.0f);
    tmpTrans.set(tmpVector);
    tmpTG.setTransform(tmpTrans);
    tmpCyl = new Cylinder(0.2f, 1.0f, appearance);
    tmpTG.addChild(tmpCyl);

    // add the shape to the r_shoulder
    Human_r_elbow.addChild(tmpTG);

    // add the elbow to the shoulder group
    Human_r_shoulder.addChild(Human_r_elbow);

    // create the l_shoulder TransformGroup
    Human_l_shoulder = new TransformGroup();
    Human_l_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    Human_l_shoulder.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tmpVector.set(0.95f, 2.9f, -0.2f);
    tmpTrans.set(tmpVector);
    Human_l_shoulder.setTransform(tmpTrans);

    // place the sphere for the l_shoulder
    tmpSphere = new Sphere(0.22f, appearance);
    Human_l_shoulder.addChild(tmpSphere);

    // offset and place the cylinder for the l_shoulder
    tmpTG = new TransformGroup();
    // offset the shape
    tmpVector.set(0.0f, -0.5f, 0.0f);
    tmpTrans.set(tmpVector);
    tmpTG.setTransform(tmpTrans);
    tmpCyl = new Cylinder(0.2f, 1.0f, appearance);
    tmpTG.addChild(tmpCyl);

    // add the shape to the l_shoulder
    Human_l_shoulder.addChild(tmpTG);

    // add the shoulder to the body group
    Human_body.addChild(Human_l_shoulder);

    // create the r_elbow TransformGroup
    Human_l_elbow = new TransformGroup();
    Human_l_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
    Human_l_elbow.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    tmpVector.set(0.0f, -1.054f, 0.0f);
    tmpTrans.set(tmpVector);
    Human_l_elbow.setTransform(tmpTrans);

    // place the sphere for the l_elbow
    tmpSphere = new Sphere(0.22f, appearance);
    Human_l_elbow.addChild(tmpSphere);

    // offset and place the cylinder for the l_elbow
    tmpTG = new TransformGroup();
    // offset the shape
    tmpVector.set(0.0f, -0.5f, 0.0f);
    tmpTrans.set(tmpVector);
    tmpTG.setTransform(tmpTrans);
    tmpCyl = new Cylinder(0.2f, 1.0f, appearance);
    tmpTG.addChild(tmpCyl);

    // add the shape to the l_elbow
    Human_l_elbow.addChild(tmpTG);

    // add the shoulder to the body group
    Human_l_shoulder.addChild(Human_l_elbow);

    // create the skullbase TransformGroup
    Human_skullbase = new TransformGroup();
    tmpVector.set(0.0f, 3.632f, 0.0f);
    tmpTrans.set(tmpVector);
    Human_skullbase.setTransform(tmpTrans);

    // offset and place the sphere for the skull
    tmpSphere = new Sphere(0.5f, appearance);

    // add the shape to the l_shoulder
    Human_skullbase.addChild(tmpSphere);

    // add the shoulder to the body group
    Human_body.addChild(Human_skullbase);

}

From source file:AppearanceTest.java

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

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

    // attach a navigation behavior to the position of the viewer
    KeyNavigatorBehavior key = new KeyNavigatorBehavior(zoomTg);
    key.setSchedulingBounds(createApplicationBounds());
    key.setEnable(true);/*from   www . ja v a 2s .com*/
    objRoot.addChild(key);

    // create a TransformGroup to flip the hand onto its end and enlarge it.
    TransformGroup objTrans1 = new TransformGroup();
    Transform3D tr = new Transform3D();
    objTrans1.getTransform(tr);
    tr.setEuler(new Vector3d(0.5 * Math.PI, 0.6, 0));
    objTrans1.setTransform(tr);

    // 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(getApplicationBounds());
    DirectionalLight lgt1 = new DirectionalLight(lColor1, lDir1);
    lgt1.setInfluencingBounds(getApplicationBounds());

    objRoot.addChild(aLgt);
    objRoot.addChild(lgt1);

    int nScale = 50;

    Box box = new Box(nScale, nScale, nScale, Primitive.GENERATE_NORMALS | Primitive.GENERATE_TEXTURE_COORDS,
            m_Appearance);

    Shape3D frontFace = box.getShape(Box.LEFT);

    // create a new left face so we can
    // assign per-vertex colors

    GeometryArray geometry = new QuadArray(4, GeometryArray.COORDINATES | GeometryArray.NORMALS
            | GeometryArray.COLOR_4 | GeometryArray.TEXTURE_COORDINATE_2);

    nScale = 40;

    final float[] verts = {
            // left face
            -1.0f * nScale, -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, 1.0f * nScale, 1.0f * nScale,
            -1.0f * nScale, 1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale, -1.0f * nScale };

    final float[] colors = {
            // left face
            1, 0, 0, 0, 0, 1, 0, 0.2f, 0, 0, 1, 0.8f, 0, 0, 0, 1, };

    float[] tcoords = {
            // left
            1, 0, 1, 1, 0, 1, 0, 0 };

    Vector3f normalVector = new Vector3f(-1.0f, 0.0f, 0.0f);

    geometry.setColors(0, colors, 0, 4);

    for (int n = 0; n < 4; n++)
        geometry.setNormal(n, normalVector);

    geometry.setTextureCoordinates(0, tcoords, 0, 4);

    geometry.setCoordinates(0, verts);

    frontFace.setGeometry(geometry);

    // connect the scenegraph
    objTrans1.addChild(box);
    zoomTg.addChild(objTrans1);
    objRoot.addChild(zoomTg);

    return objRoot;
}

From source file:PlatformTest.java

ViewingPlatform createViewer(Canvas3D c, String szName, Color3f objColor, double x, double z) {
    // create a Viewer and attach to its canvas
    // a Canvas3D can only be attached to a single Viewer
    Viewer viewer2 = new Viewer(c);

    // create a ViewingPlatform with 1 TransformGroups above the
    // ViewPlatform
    ViewingPlatform vp2 = new ViewingPlatform(1);

    // create and assign the PlatformGeometry to the Viewer
    vp2.setPlatformGeometry(createPlatformGeometry(szName));

    // create and assign the ViewerAvatar to the Viewer
    viewer2.setAvatar(createViewerAvatar(szName, objColor));

    // set the initial position for the Viewer
    Transform3D t3d = new Transform3D();
    t3d.setTranslation(new Vector3d(x, 0, z));
    vp2.getViewPlatformTransform().setTransform(t3d);

    // set capabilities on the TransformGroup so that the
    // KeyNavigatorBehavior
    // can modify the Viewer's position
    vp2.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
    vp2.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_READ);

    // attach a navigation behavior to the position of the viewer
    KeyNavigatorBehavior key = new KeyNavigatorBehavior(vp2.getViewPlatformTransform());
    key.setSchedulingBounds(m_Bounds);
    key.setEnable(false);/*  w  w w.j  a  v  a2 s  .  c  om*/

    // add the KeyNavigatorBehavior to the ViewingPlatform
    vp2.addChild(key);

    // set the ViewingPlatform for the Viewer
    viewer2.setViewingPlatform(vp2);

    // associate the name of the Viewer with its KeyNavigatorBehavior
    m_KeyHashtable.put(szName, key);

    // create a button to switch the Viewer ON.
    Button button = new Button(szName);
    button.addActionListener(this);
    add(button);

    return vp2;
}

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 a  v a 2s  .  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 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:ExDirectionalLight.java

private Group buildArrows() {
    // Create a transform group surrounding the arrows.
    // Enable writing of its transform.
    arrowDirectionTransformGroup = new TransformGroup();
    arrowDirectionTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // Create a group of arrows and add the group to the
    // transform group. The arrows point in the +X direction.
    AnnotationArrowGroup ag = new AnnotationArrowGroup(-2.0f, 2.0f, // X
            // start
            // and
            // end
            1.5f, -1.5f, // Y start and end
            5); // Number of arrows
    arrowDirectionTransformGroup.addChild(ag);

    // Create a set of Transform3Ds for the different
    // arrow directions.
    arrowDirectionTransforms = new Transform3D[directions.length];
    Vector3f dir = new Vector3f();
    Vector3f positiveX = new Vector3f(1.0f, 0.0f, 0.0f);
    Vector3f axis = new Vector3f();
    float angle;//from  w w  w.  j a  v a2  s  .  c o  m
    float dot;

    for (int i = 0; i < directions.length; i++) {
        // Normalize the direction vector
        dir.normalize((Vector3f) directions[i].value);

        // Cross the direction vector with the arrow's
        // +X aim direction to get a vector orthogonal
        // to both. This is the rotation axis.
        axis.cross(positiveX, dir);
        if (axis.x == 0.0f && axis.y == 0.0f && axis.z == 0.0f) {
            // New direction is parallel to current
            // arrow direction. Default to a Y axis.
            axis.y = 1.0f;
        }

        // Compute the angle between the direction and +X
        // vectors, where:
        //
        //   cos(angle) = (dir dot positiveX)
        //                -------------------------------
        //                (positiveX.length * dir.length)
        //
        // but since positiveX is normalized (as created
        // above and dir has been normalized, both have a
        // length of 1. So, the angle between the
        // vectors is:
        //
        //   angle = arccos(dir dot positiveX)
        //
        dot = dir.dot(positiveX);
        angle = (float) Math.acos(dot);

        // Create a Transform3D, setting its rotation using
        // an AxisAngle4f, which takes an XYZ rotation vector
        // and an angle to rotate by around that vector.
        arrowDirectionTransforms[i] = new Transform3D();
        arrowDirectionTransforms[i].setRotation(new AxisAngle4f(axis.x, axis.y, axis.z, angle));
    }

    // Set the initial transform to be the current aim direction.
    arrowDirectionTransformGroup.setTransform(arrowDirectionTransforms[currentDirection]);

    return arrowDirectionTransformGroup;
}

From source file:ExPointLight.java

private Group buildArrows() {
    // Create a transform group surrounding the arrows.
    // Enable writing of its transform.
    arrowPositionTransformGroup = new TransformGroup();
    arrowPositionTransformGroup.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

    // Create a group of arrows in a fan and add that group
    // to the transform group.
    AnnotationArrowFan af = new AnnotationArrowFan(0.0f, 0.0f, 0.0f, // center
            // position
            2.5f, // arrow length
            0.0f, // start angle
            (float) (Math.PI * 2.0 * 7.0 / 8.0), // end angle
            8); // number of arrows
    arrowPositionTransformGroup.addChild(af);

    // Create a set of Transform3Ds for the different
    // arrow positions.
    arrowPositionTransforms = new Transform3D[positions.length];
    Point3f pos;/* ww w.  j  av  a  2  s.c  o  m*/
    Vector3f v = new Vector3f();
    for (int i = 0; i < positions.length; i++) {
        // Create a Transform3D, setting its translation.
        arrowPositionTransforms[i] = new Transform3D();
        pos = (Point3f) positions[i].value;
        v.set(pos);
        arrowPositionTransforms[i].setTranslation(v);
    }

    // Set the initial transform to be the current position
    arrowPositionTransformGroup.setTransform(arrowPositionTransforms[currentPosition]);

    return arrowPositionTransformGroup;
}