Java Reference
In-Depth Information
rotposscalepathInterpolator
Similar to RotPosPathInterpolator, which combines translation and rotation, RotPosS-
calePathInterpolator allows an object to be rotated, translated, and scaled. As illustrated
Figure 7. Code segment and result of RotPosScalePathInter.java
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. Alpha rotationAlpha = new Alpha( -1, 4000 );
8. Transform3D axisRot = new Transform3D();
9. float[] knots = { 0.0f, 0.25f, 0.5f, 0.75f, 1.0f };
10. Quat4f[] quats = new Quat4f[5]; //quaternions for rotation
11. quats[0] = new Quat4f( 0.0f, -1.0f, 0.0f, 1.0f );
12. quats[1] = new Quat4f( 0.0f, 1.0f, 0.0f, 1.0f );
13. quats[2] = new Quat4f( 1.0f, 0.0f, 0.0f, 1.0f );
14. quats[3] = new Quat4f( -1.0f, 0.0f, 0.0f, 1.0f );
15. quats[4] = new Quat4f( 0.0f, -1.0f, 0.0f, 1.0f );
16. Point3f[] postns = new Point3f[5]; //coordinates of waypoints for translation
17. postns[0] = new Point3f( 0.0f, 0.0f, 0.0f );
18. postns[1] = new Point3f( 0.5f, 0.0f, 0.0f );
19. postns[2] = new Point3f( 0.0f, 0.5f, 0.0f );
20. postns[3] = new Point3f( -0.5f, 0.0f, 0.0f );
21. postns[4] = new Point3f( 0.0f, 0.0f, 0.0f );
22. float[] scales = { 1.0f, 0.5f, 0.1f, 0.5f, 1.0f }; // scaling factor for each position
23. RotPosScalePathInterpolator rotator =
24. new RotPosScalePathInterpolator( rotationAlpha, objTrans, axisRot, knots, quats, postns, scales );
25. BoundingSphere bounds = new BoundingSphere();
26. rotator.setSchedulingBounds( bounds );
27. objTrans.addChild( rotator );
28. objTrans.addChild( new createRotPosScalePathInter() );
29. objRoot.compile();
30. return objRoot;
31. }
32.
Search WWH ::




Custom Search