Skip to main content

add objects to live or compiled scenegraph

3 replies [Last post]
Anonymous

Hi all,
..seems it's impossible add objects/transformGroups to live or compiled scenegraph, exception throws "RestrictedAccessException: Group: only a BranchGroup node may be added".

is it true, i.e. is this action restricted?

I tried workaround like this, it's working (only with live, not with compiled scene):

//objRoot.compile(); //not working with compiled scene
simpleU.addBranchGraph(objRoot); //making live
objRoot.detach();
objRoot.addChild(tg);
simpleU.addBranchGraph(objRoot);

more ideas?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Anonymous

> There's no need to detach the branchgroup in order to
> add new geometry; just create a new BranchGroup as
> the root of anything new that you add:
>
> BranchGroup bg2 = new BranchGroup();
> bg2.addChild(tg);
> objRoot.addChild(bg2);

..seems this solution is not suitable in my case, because I have MouseRotate on my objTrans (objTrans is child of objRoot), so if I will add bg2 to objRoot, MouseRotate will not affect "bg2 objects".

but - I tried this "non standard" action:
-add BG to TG (addChild);
-detach BG from TG (removeChild);

and seems, this "non standard" action working properly on live or compiled scene.

Q: is this "non standard" action - making branchGroup as child of transformGroup is normal/legal, or "better don't use this"?

kcr
Offline
Joined: 2004-03-17

There's no need to detach the branchgroup in order to add new geometry; just create a new BranchGroup as the root of anything new that you add:

[code]BranchGroup bg2 = new BranchGroup();
bg2.addChild(tg);
objRoot.addChild(bg2);[/code]

Just make sure to set the appropriate capability bits.

-- Kevin

nitro
Offline
Joined: 2004-09-12

If you have a lot of objects to add has this some impact to performance and memory? (Because of all the BG added)