Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Java 3D / May 2006

Tip: Looking for answers? Try searching our database.

Replace Shape3D in scene graph

Thread view: 
Dave - 17 Apr 2006 14:13 GMT
I have a method that generates a Shape3D. I want to regenerate that shape
and replace the Shape3D originally added to the scene graph with the newly
generated one. How do I do this?

tg = new TransformGroup();
tg.addChild(generateShape());
rootBranchGroup.addChild(tg);

I want to replace the Shape3D added to tg with a new one created by
generateShape().
Nick Wiedenbrück - 17 Apr 2006 15:51 GMT
Dave schrieb:
> I have a method that generates a Shape3D. I want to regenerate that shape
> and replace the Shape3D originally added to the scene graph with the newly
[quoted text clipped - 6 lines]
> I want to replace the Shape3D added to tg with a new one created by
> generateShape().

Hi Dave,

you can do this by

tg = new TransformGroup();
shape = generateShape();
tg.addChild(shape);
rootBranchGroup.addChild(tg);

and then replace the shape object by a shape2 object by

tg.removeChild(shape);
shape2 = generateShape();
tg.addChild(shape2);

But you have to be careful: after compiling the
rootBranchGroup by rootBranchGroup.compile() method
it is usually not be allowed to remove or add children
so you'll get an Exception like <<Capability not set>>
or something. Then you can set this capability by
rootBranchGroup.setCapability(Group.ALLOW_CHILDREN_EXTEND);
or something like that.

Bye,
Nick
Paul Drallos - 18 May 2006 00:52 GMT
Another thing you have to watch out for is that you can only add BranchGroups to a live scene.  So before you add the shape to the scene, you have to put it in a BranchGroup and then add the BranchGroup to the scene (provided all the capabilities are set.)


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.