Example usage for javax.media.j3d InputDevice getSensor

List of usage examples for javax.media.j3d InputDevice getSensor

Introduction

In this page you can find the example usage for javax.media.j3d InputDevice getSensor.

Prototype

public Sensor getSensor(int sensorIndex);

Source Link

Document

Gets the specified Sensor associated with the device.

Usage

From source file:HelloUniverse.java

public void init() {
    // These are the string arguments given to the VirtualInputDevice
    // constructor. These are settable parameters. Look in the
    // VirtualInputDevice constructor for a complete list.
    String[] args = new String[10];
    args[0] = "printvalues";
    args[1] = "true";
    args[2] = "yscreeninitloc";
    args[3] = "50";
    args[4] = null;//from w  w  w. j ava  2 s . co  m

    InputDevice device = new VirtualInputDevice(args);

    // now create the HelloUniverse Canvas
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    Canvas3D c = new Canvas3D(config);
    add("Center", c);

    // Create a simple scene and attach it to the virtual universe
    BranchGroup scene = createSceneGraph();
    u = new SimpleUniverse(c);

    // 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);
    u.addBranchGraph(scene);
}