Thanks cyril,
I used ur code ,but iam getting an exception saying that
"Exception in thread "main" javax.media.j3d.RestrictedAccessException: Node: loca
l to vworld transform is undefined for a node that is not part of a live scene graph"
iam attaching my code here.can u find the problem?
import java.Applet.*;
-
public class SingleCubeApplet2 extends Applet
{
BoundingSphere bounds = null;
private Canvas3D canvas = null;
public SingleCubeApplet2()
{
setLayout(new BorderLayout());
Canvas3D canvas3D=new Canvas3D(null);
add("Center",canvas3D);
BranchGroup scene = createSceneGraph();
scene.compile();
SimpleUniverse simpleU=new SimpleUniverse(canvas3D);
simpleU.getViewingPlatform().setNominalViewingTransform();
simpleU.addBranchGraph(scene);
}
public BranchGroup createSceneGraph()
{
Appearance app = new Appearance();
BranchGroup objRoot=new BranchGroup();
Transform3D tmp= new Transform3D();
TransformGroup tg=new TransformGroup(tmp);
ColorCube myColorCube=new ColorCube(0.05);
myColorCube.getLocalToVworld(tmp);
Vector3f trans = new Vector3f();
tmp.get(trans);
System.out.println("vector of translation" + trans);
tg.addChild(myColorCube);
objRoot.addChild(tg);
return objRoot;
}
public static void main(String args[])
{
new MainFrame(new SingleCubeApplet2(), 750, 750);
}
}
please help me regarding this,
Thanks in advance,
Ravi
it's because your colorcube has not been add to the scene yet.
you can use this code only after this :
simpleU.addBranchGraph(scene);
don't forget to set the capability of your node in this case myColorCube by adding this just before adding the colorcube
myColorCube.setCapability(Sphere.ALLOW_LOCAL_TO_VWORLD_READ);
hope i m clear