Hello.
 
I'm building a virtual world and I'm trying to use the VirtualDevice implementation that comes with the examples of Java3D. I don't know why, but using the code below I have a problem on run-time.
 
       // The InputDevice must be initialized before registering it
        // with the PhysicalEnvironment object.
        device.initialize();
 
        // Register the VirtualInputDevice with Java 3D
        u.getViewer().getPhysicalEnvironment().addInputDevice( device );
 
        TransformGroup viewTrans =
                        u.getViewingPlatform().getViewPlatformTransform();
        SensorBehavior s = new SensorBehavior( viewTrans, device.getSensor(0));
        s.setSchedulingBounds( new BoundingSphere
                       ( new Point3d(0.0,0.0,0.0), Float.MAX_VALUE ));
        scene.addChild( s ); <- This is the line wich the exception
       
u.addBranchGraph(scene);
When I run the program, it tells me this:
 
Exception in thread "main" javax.media.j3d.RestrictedAccessException: Group: onl
y a BranchGroup node may be added
        at javax.media.j3d.Group.addChild(Group.java:246)
        at Prueba2.<init>(Prueba2.java:110)
        at Prueba2.main(Prueba2.java:115)
I don't understand this, because this piece of code is exactly the same as in the 'VirtualInputDevice' and 'HelloUniverse' example. Without this, my program works well but, of course, I have no input device.
 
Any idea about why does it tell me this in my program and not in the example?
 
Thanks,
Juanjo
 
 
 

Reply via email to