Alex Guest
|
Posted: Sat Aug 23, 2003 3:29 pm Post subject: Position of Primitive after applying PickRotateBehavior() |
|
|
I'm desperated. Since quite a while I'm trying to get the Position of
a Cylinder relative to its Rotation Point. My final aim is to get the
Rotation Angle from the User Input as Rotation about the X-,Y- and
Z-Axis. I tried to select some of my code to help you getting an idea
of my problem.
CylinderDarstellen(...)and KugelDarstellen(...) are two Methods I
wrote myself which return a TransformGroup with more or less the
information of the primitives Cylinder/Sphere. My program should print
out the new position of Transform3D of TransformGroup Oberkörper when
Button "Beenden" is pushed from the user. It does work alright if I
ask for the the position of "Hals" with
Hals.getLocalToVworld(trans),but when I'm trying to do the same with
Oberkörper,I'm getting the following exception:
* javax.media.j3d.RestrictedAccessException: Node: local to vworld
*transform is undefined for a node that is not part of a live scene
*graph at javax.media.j3d.Node.getLocalToVworld(Node.java:259)
My program is a part of a project I have to do for university. so it
is very important to me. It would be more than nice,if someone could
help me to wether in understanding the thrown exception or in giving
me any advice how to solve my problem in any other way.
---------------------
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if( source==this.Beenden){
Vector3f Winkel= new Vector3f();
Vector3f Start= new Vector3f();
Transform3D trans=new Transform3D();
Oberkörper.getLocalToVworld(trans);
trans.get(Winkel);
System.out.println("WinkelX: "+Winkel.x);
System.out.println("WinkelY: "+Winkel.y);
System.out.println("WinkelZ: "+Winkel.z);
}
}
BranchGroup BG = new BranchGroup()
....
TransformGroup Körper_Gelenk = KugelErstellen(new
Vector3f(0.0f,0.15f,0.0f),0.15f);
Körper_Gelenk.setCapability(TransformGroup.ALLOW_LOCAL_TO_VWORLD_READ);
Körper_Gelenk.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
Körper_Gelenk.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
Körper_Gelenk.setCapability(TransformGroup.ENABLE_PICK_REPORTING);
objScale.addChild(Körper_Gelenk);
TransformGroup Oberkörper = CylinderDarstellen(new
Vector3f(0.0f,0.15f,0.0f),Math.PI,0.15f,0.25f);
Oberkörper.setCapability(TransformGroup.ALLOW_LOCAL_TO_VWORLD_READ);
Körper_Gelenk.addChild(Oberkörper);
Hals = CylinderDarstellen(new
Vector3f(0.0f,0.165f,0.0f),Math.PI,0.075f,0.08f);
Hals.setCapability(TransformGroup.ALLOW_LOCAL_TO_VWORLD_READ);
Oberkörper.addChild(Hals);
PickRotateBehavior behavior1 =
new PickRotateBehavior(BG, canvas, bounds);
behavior1.setMode(PickTool.BOUNDS);
BG.addChild(behavior1);
|
|