You'll
better create the complete thing in createSceneGraph, including the rotator.
Then in your startRotate / stopRotate / whateverYourButtonsWantsToManipulate you
just set the neccessary values of the alpha
object.
i.e.
a.
create the complete scenegraph with alpha paused.
b. in
startRotate you just resume alpha. Eventually you can reset the start time of
the alpha to the current time.
c. you
may play with other settings of the alpha, for example to change the rotation
speed (by a slider ?).
d. in
stopRotate you pause alpha.
Cheers,
Florin
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".-----Original Message-----
From: Discussion list for Java 3D API [mailto:[EMAIL PROTECTED]On Behalf Of Chris Bartlett
Sent: Mittwoch, 5. November 2003 17:38
To: [EMAIL PROTECTED]
Subject: [JAVA3D] problem with applet methodsHi,I have a simple Java3d applet, pretty much like the HelloUniverse in structure. I have the objRoot and objTrans as private members of the class. At the end of my CreateSceneGraph routine, I have a transform which starts the objects rotating (exactly like in HelloUniverse). What I want to do is to place this code into another method called startRotate so I can control the rotation from _javascript_ - i.e. turn it on and off.When I move my code into a separate method, the applet runs and I can call the method from _javascript_ but I get a "javax.media.j3d.RestrictedAccessException: Group: only a BranchGroup node may be added" error at run time. I have made objTrans private to the class so I can get at it from my method, and I have set its capability to ALLOW_TRANSFORM_WRITE. my code for the rotate method is shown below -any clues as to what I am doing wrong?Chris Bartlettpublic class visualiser extends Applet{private SimpleUniverse u = null;private VirtualInputDevice device = null;private TransformGroup objTrans = null;private BranchGroup objRoot = null;public BranchGroup createSceneGraph() {
objRoot = new BranchGroup();objTrans = new TransformGroup();objTrans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);objRoot.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);objRoot.addChild(objTrans);...return objRoot;}public void init() {Canvas3D c = new Canvas3D(config);add("Center", c);BranchGroup scene = createSceneGraph();u = new SimpleUniverse(c,4);...}public void startRotate(){System.out.println("Method rotate invoked");Transform3D yAxis = new Transform3D();Alpha rotationAlpha = new Alpha(-1, Alpha.INCREASING_ENABLE,0, 0,36000, 0, 0,0, 0, 0);RotationInterpolator rotator =new RotationInterpolator(rotationAlpha, this.objTrans, yAxis,0.0f,(float) Math.PI*2.0f);BoundingSphere bounds =new BoundingSphere(new Point3d(0.0,0.0,0.0), 300.0);new BoundingSphere(new Point3d(0.0,0.0,0.0), Float.MAX_VALUE );rotator.setSchedulingBounds(bounds);this.objTrans.addChild(rotator);}}=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".