To reuse the same object, use the SharedGroup class. Add your node to the SharedGroup and where you want to display an instance, you add a Link node which has a reference to your SharedGroup. You can also have your Link node inside a TransformGroup to do any transformations you need to your object instance.
For example, the code below adds to instances of the same SharedGroup.
BranchGroup objToShare = new BranchGroup();
SharedGroup sharedGroup = new SharedGroup();
sharedGroup.addChild(objToShare);
rootBG.addChild(new Link(sharedGroup));
rootBG.addChild(new Link(sharedGroup));
Be aware that using a SharedGroup adds a bit more complexity when it comes to Picking and getting the localToVworld transform, you will have to read up on that, but basically because some objects are being referenced more than once in the scene, java3d will only be able to identify which node you are referring to if it knows the complete scenegraphpath to the node, which it can obtain if you have using picking to select the object.
[Message sent by forum member 'chrismcband' (
chrismcband@...)]
http://forums.java.net/jive/thread.jspa?messageID=371320---------------------------------------------------------------------
To unsubscribe, e-mail:
interest-unsubscribe@...
For additional commands, e-mail:
interest-help@...