# Combine two tranform group?

it2512
Offline
Joined: 2010-10-16

i was reading the tutorial, and saw an exmple:

``3. BranchGroup objRoot = new BranchGroup();4.5. // rotate object has composite transformation matrix6. Transform3D rotate = new Transform3D();7. Transform3D tempRotate = new Transform3D();8.9. rotate.rotX(Math.PI/4.0d);10. tempRotate.rotY(Math.PI/5.0d);11. rotate.mul(tempRotate);12.13. TransformGroup objRotate = new TransformGroup(rotate);14.15. // Create the transform group node and initialize it to the16. // identity. Enable the TRANSFORM_WRITE capability so that17. // our behavior code can modify it at runtime. Add it to the18. // root of the subgraph.19. TransformGroup objSpin = new TransformGroup();20. objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);21.22. objRoot.addChild(objRotate);23. objRotate.addChild(objSpin);24.25. // Create a simple shape leaf node, add it to the scene graph.26. // ColorCube is a Convenience Utility class27. objSpin.addChild(new ColorCube(0.4));28.29. // Create a new Behavior object that performs the desired30. // operation on the specified transform object and add it into31. // the scene graph.32. Transform3D yAxis = new Transform3D();33. Alpha rotationAlpha = new Alpha(-1, 4000);34.35. RotationInterpolator rotator =36. new RotationInterpolator(rotationAlpha, objSpin, yAxis,37. 0.0f, (float) Math.PI*2.0f);38.39. // a bounding sphere specifies a region a behavior is active40. // create a sphere centered at the origin with radius of 141. BoundingSphere bounds = new BoundingSphere();42. rotator.setSchedulingBounds(bounds);43. objSpin.addChild(rotator);44.45. return objRoot;46. } // end of createSceneGraph method of HelloJava3Dd``

so , the scene graph tree is like : BG -> TG1 -> TG2 -> cube
TG1 contain rotation
TG2 contain behaviour

i was thinking it is possible combine this 2 TG together? like: BG -> TG1 -> cube
TG1 contain rotation and behaviour.

i tried to run the program, and found that rotation disappear.
ah, anyone can solve my confusion? thanks.

it2512
Offline
Joined: 2010-10-16

some more, if i changed: