RestrictedAccessException: Group: only a BranchGroup node may be added
843799Jun 19 2006 — edited Jun 19 2006I was wondering if anyone else has ever got this error when trying to add a behavior to a BranchGroup during runtime. Here is the code:
TransformGroup transGunit = new TransformGroup();
BoundingSphere bs = new BoundingSphere(new Point3d(), 1000.0);
ObstacleFactory.setColor(new Color3f(0f,10f,0f));
ObstacleFactory.setStartingPos(1f,12f,0f);
models.add(ObstacleFactory.getInstance(odeWorld));
blockadd = models.size()-1;
transGunit.addChild(models.get(blockadd).getBranchGroup());
tg.add(transGunit);
behav.add(new KeyNavigatorBehavior(tg.get(tg.size() - 1)));
behav.get(blockadd).setSchedulingBounds(bs);
//behav.get(blockadd).setEnable(false);
// BranchGroup fooledYou = new BranchGroup();
// fooledYou.addChild(behav.get(behav.size() - 1));
// sceneRoot.addChild(fooledYou);
sceneRoot.addChild(behav.get(behav.size() - 1));
Thanks in adv ance.