1

I recently started working on java3D. Currently I am working on a java3D racing game. I just wanted to know is it possible to add objects (i.e. scenegraph nodes nodes) e.g. spehere, box, etc. to a scene graph which has been compiled.

If i want to add an object onto a graph on a keyPress event, or on a timing event how can it be done?

2am
  • 699
  • 1
  • 7
  • 25

1 Answers1

4

Yes, you can add and remove BranchGroups from the universe scene graph dynamically.

Typically each BranchGroup is compiled into a single mesh internally for faster rendering.

So you can make your sphere, car mesh, etc a child of a BranchGroup, and then add that BranchGroup as a child of the main BranchGroup.

You may also need to set MyBranchGroup.setCapability( Group.ALLOW_CHILDREN_EXTEND ); to allow adding children.

Zenith
  • 41
  • 1