Dear all,

I am trying to access to a Shape3D object which is already attached to a BranchGroup (I first clone the node and try to access the object in this cloned BG). The code and scenegraphs are attached. During run time, I am getting the exception:

Exception caught: Index: 0, Size: 0

I can see print out 2 but I cannot see print out 3. So there is something wrong in the line:
Node tgt = ((BranchGroup)cN).getChild(0);

Can someone give me a hint?




//MY CODE
BranchGroup BG_Column = new BranchGroup();
BG_Column.setCapability(BranchGroup.ALLOW_DETACH);
TransformGroup T_TGR = new TransformGroup(rotateX_s);
TransformGroup T_TGT = new TransformGroup(translate1);

T_TGT.addChild(T_TGR);
BG_Column.addChild(T_TGT);

System.out.println("ch: " + BG_Column.numChildren()); // returns: 1

System.out.println("1");
Node cN = BG_Column.cloneNode(true);
System.out.println("2");
Node tgt = ((BranchGroup)cN).getChild(0);
System.out.println("3");
Node tgr = ((TransformGroup)tgt).getChild(0);
System.out.println("4");
Node part2 = ((TransformGroup)tgr).getChild(0);
System.out.println("5");


objTransp.setCapability(TransparencyAttributes.ALLOW_VALUE_WRITE);
System.out.println("6");
objTransp.setTransparencyMode(TransparencyAttributes.BLENDED);
System.out.println("7");
objTransp.setTransparency(0.5f);
System.out.println("8");
Appearance app2 = ((BoxDef)part2).getAppearance();
app2.setTransparencyAttributes(objTransp);
System.out.println("9");
((BoxDef)(part2)).setAppearance(app2);
System.out.println("10");

<<inline: branch.JPG>>

Reply via email to