Java Reference
In-Depth Information
fect will be similar to that of flipping pages of slightly different still pictures to create an
illusion of moving objects or images.
Under the morph class, these pages of still make up an array of GeometryArray objects,
as illustrated in line 15 to line 19 in Figure 19. Each element of the array is associated with
a GeometryArray object for the morph class to combine and smooth for the purpose of
animation.
In addition the morph class, the animation sequence must also be defined. This is done by
declaring a separate class on the behavior of the morph object as illustrated in Figure 20.
To declare a behavior class, the initialize() and processStimulus() classes must be speci-
fied. Also, for MorphBehaviour, it is necessary to define an array of weights. These serve
Figure 19. Morph class
1.
public BranchGroup createSceneGraph()
2.
{
3.
BranchGroup objRoot = new BranchGroup();
4.
TransformGroup objTrans = new TransformGroup();
5.
objTrans.setCapability( TransformGroup.ALLOW_TRANSFORM_WRITE );
6.
objRoot.addChild( objTrans );
7.
8. Alpha alphas = new Alpha( -1, 5000 );
9. RotationInterpolator rotator =
10. new RotationInterpolator( alphas, objTrans );
11. BoundingSphere bounds = new BoundingSphere();
12. rotator.setSchedulingBounds( bounds );
13. objTrans.addChild( rotator );
14.
15. GeometryArray[] geoarry = new GeometryArray[4];
16. geoarry[0] = createGeometry1();
17. geoarry[1] = createGeometry2();
18. geoarry[2] = createGeometry3();
19. geoarry[3] = createGeometry4();
20.
21. Morph objMorph = new Morph( geoarry );
22. objMorph.setCapability( Morph.ALLOW_WEIGHTS_WRITE );
23.
24. MorphBehaviour behave = new MorphBehaviour( objMorph, alphas );
25. behave.setSchedulingBounds( bounds );
26.
27. objTrans.addChild( objMorph );
28. objRoot.addChild( behave );
29. objRoot.compile();
30.
31. return objRoot;
32. }
Search WWH ::




Custom Search