Title: Message
Hi,
 
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 Bartlett
 
public 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".

Reply via email to