Interpolator classes change various visual attributes in the virtual world. However, there is no interpolator to change the geometry of a visual object. This is exactly what the Morph Class does. A Morph object creates the geometry for a visual object through interpolating from a set of GeometryArray objects.

The next list summarizes the steps to use a Morph object:

  1. create an array of GeometryArray objects
  2. create a Morph object with ALLOW_WEIGHTS_WRITE
  3. assemble the scene graph, including adding children to target Switch object(s)
 public BranchGroup createSceneGraph() {

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

    Transform3D t3d = new Transform3D();
    t3d.set(new Vector3f(0f, -0.5f, 0f));
    TransformGroup translate = new TransformGroup(t3d);

    // create GeometryArray[] (array of GeometryArray objects)
    GeometryArray[] geomArray = new GeometryArray[4];
    geomArray[0] = createGeomArray0();
    geomArray[1] = createGeomArray1();
    geomArray[2] = createGeomArray2();
    geomArray[3] = createGeomArray3();

    // create morph object
    Morph morphObj = new Morph(geomArray);

    // create alpha object
    Alpha alpha = new Alpha(-1, 1, 0, 0, 2000, 100, 0, 0, 0, 0);

    // create morph driving behavior
    MorphBehavior morphBehav = new MorphBehavior(morphObj, alpha);
    morphBehav.setSchedulingBounds(new BoundingSphere());

    // assemble scene graph


    return objRoot;