how to get the position of the cube

hi,i have a ColorCube on my applet. i wanted to get the position of the cube(coordinates) on the applet.Is it posible to get the position.can anyone help me?Thanks in advance,Ravi
[215 byte] By [vnvravikumara] at [2007-9-19]
# 1
i've the same problem with my Spherehope someone can help us
czormana at 2007-7-8 > top of java,Security,Cryptography...
# 2
i manage make it work doing like this Transform3D tmp= new Transform3D();myColorCube.getLocalToVworld(tmp); Vector3f trans = new Vector3f();Tmp.get(trans); System.out.println("vector of translation" + trans);cyril
czormana at 2007-7-8 > top of java,Security,Cryptography...
# 3

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

vnvravikumara at 2007-7-8 > top of java,Security,Cryptography...
# 4

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

czormana at 2007-7-8 > top of java,Security,Cryptography...
# 5
Thank u very much,My problem is solved.regardsravi
vnvravikumara at 2007-7-8 > top of java,Security,Cryptography...