|
How to implement key-frame animation by Morph |
|
|
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:
- create an array of GeometryArray objects
- create a Morph object with ALLOW_WEIGHTS_WRITE
- 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);
morphObj.setCapability(Morph.ALLOW_WEIGHTS_WRITE);
// 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
objRoot.addChild(translate);
translate.addChild(morphObj);
objRoot.addChild(morphBehav);
...
return objRoot;
}
|
Related Tips
|
Page 1 of 0 ( 0 comments )
You can share your information about this topic using the form below!
Please do not post your questions with this form! Thanks.