Recipe for Using a Path Interpolator Object

  1. create the target object with the appropriate capability

  2. create the Alpha object

  3. create arrays of knot and other values

  4. create the path interpolator object referencing the Alpha object, target object, and arrays of settings

  5. add scheduling bounds to the Interpolator object

  6. add path interpolator object to the scene graph

The RotPosPathApp.java example program uses an RotPosPathInterpolator object to animate a ColorCube object through a number of position and rotation values. The RotPosPathInterpolator stores sets of rotations (as an array of Quat4f), positions (as an array of Point3f), and knot values (as an array of
float).

The complete source for RotPosPathApp.java is available in the examples/Animation subdirectory.

An Excerpt from the CreateSceneGraph Method of RotPosPathApp.java.

public BranchGroup createSceneGraph() {
	BranchGroup objRoot = new BranchGroup();
 
	//	1.
	TransformGroup target = new TransformGroup();
	//	2.
	Alpha alpha = new Alpha(-1, 10000); 
	Transform3D axisOfRotPos = new Transform3D();
 	//	3.
	float[] knots = {0.0f, 0.3f, 0.6f ,1.0f};
 	Quat4f[] quats = new Quat4f[4];
	Point3f[] positions = new Point3f[4];

	target.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); 

 	AxisAngle4f axis = new AxisAngle4f(1.0f,0.0f,0.0f,0.0f);
	axisOfRotPos.set(axis);
	
	quats[0] = new Quat4f(0.0f, 1.0f, 1.0f, 0.0f);
 	quats[1] = new Quat4f(1.0f, 0.0f, 0.0f, 0.0f);
	quats[2] = new Quat4f(0.0f, 1.0f, 0.0f, 0.0f); 

	positions[0]= new Point3f( 0.0f, 0.0f, -1.0f);
 	positions[1]= new Point3f( 1.0f, -1.0f, -2.0f);
	positions[2]= new Point3f( -1.0f, 1.0f, -3.0f);
	
	//	4.
	RotPosPathInterpolator rotPosPath = new RotPosPathInterpolator(
		alpha, target, axisOfRotPos, knots, quats, positions);

	//	5.
	rotPosPath.setSchedulingBounds(new BoundingSphere());

	objRoot.addChild(target);
   	//	6.
	objRoot.addChild(rotPosPath);
	target.addChild(new ColorCube(0.4));
	
	return objRoot;
} // end of createSceneGraph method of RotPosPathApp