Example usage for javax.media.j3d InputDevice DEMAND_DRIVEN

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

Introduction

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

Prototype

int DEMAND_DRIVEN

To view the source code for javax.media.j3d InputDevice DEMAND_DRIVEN.

Click Source Link

Document

Signifies that the Java 3D implementation should not schedule regular reads on the sensors of this device; the Java 3D implementation will only call pollAndProcessInput when one of the device's sensors' getRead methods is called.

Usage

From source file:HelloUniverse.java

public VirtualInputDevice(String[] args) {

    // default user-definable values
    printvalues = false;/* w w  w  . ja v  a  2  s.c  o  m*/
    xscreeninitloc = 400;
    yscreeninitloc = 0;
    xscreensize = 400;
    yscreensize = 200;
    xobjinitloc = 0.0f;
    yobjinitloc = 0.0f;
    zobjinitloc = 2.2f;
    xaxisrotinit = 0.0f;
    yaxisrotinit = 0.0f;
    zaxisrotinit = 0.0f;

    for (int i = 0; i < args.length; i += 2) {
        if (args[i] == null)
            break;
        else if (args[i] == "printvalues")
            printvalues = (Boolean.valueOf(args[i + 1])).booleanValue();
        else if (args[i] == "xscreeninitloc")
            xscreeninitloc = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "yscreeninitloc")
            yscreeninitloc = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "xscreensize")
            xscreensize = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "yscreensize")
            yscreensize = (Integer.valueOf(args[i + 1])).intValue();
        else if (args[i] == "xobjinitloc")
            xobjinitloc = (Float.valueOf(args[i + 1])).floatValue();
        else if (args[i] == "yobjinitloc")
            yobjinitloc = (Float.valueOf(args[i + 1])).floatValue();
        else if (args[i] == "zobjinitloc")
            zobjinitloc = (Integer.valueOf(args[i + 1])).floatValue();
    }

    if (printvalues == true) {
        System.out.println("Initial values for VirtualInputDevice:");
        System.out.println("xscreeninitloc = " + xscreeninitloc);
        System.out.println("yscreeninitloc = " + yscreeninitloc);
        System.out.println("xscreeninitsize = " + xscreensize);
        System.out.println("yscreeninitsize = " + yscreensize);
        System.out.println("xobjinitloc = " + xobjinitloc);
        System.out.println("yobjinitloc = " + yobjinitloc);
        System.out.println("zobjinitloc = " + zobjinitloc);
        System.out.println("xaxisrotinit = " + xaxisrotinit);
        System.out.println("yaxisrotinit = " + yaxisrotinit);
        System.out.println("zaxisrotinit = " + zaxisrotinit);
    }

    // initialize the InputDevice GUI
    Frame deviceFrame = new Frame();
    deviceFrame.setSize(xscreensize, yscreensize);
    deviceFrame.setLocation(xscreeninitloc, yscreeninitloc);
    deviceFrame.setTitle("Virtual Input Device");
    ButtonPositionControls positionControls;
    // initialize position with initial x, y, and z position
    positionControls = new ButtonPositionControls(xobjinitloc, yobjinitloc, zobjinitloc);
    WheelControls rotControls;
    // initialize rotations with initial angles in radians)
    rotControls = new WheelControls(xaxisrotinit, yaxisrotinit, zaxisrotinit);
    positionControls.setDevice(this);
    Panel devicePanel = new Panel();
    devicePanel.setLayout(new BorderLayout());
    devicePanel.add("East", positionControls);
    devicePanel.add("West", rotControls);
    deviceFrame.add(devicePanel);
    deviceFrame.pack();
    deviceFrame.setVisible(true);

    initPos.set(xobjinitloc, yobjinitloc, zobjinitloc);

    this.positionControls = positionControls;
    this.rotControls = rotControls;

    // default processing mode
    processingMode = InputDevice.DEMAND_DRIVEN;

    sensors[0] = new Sensor(this);
}

From source file:HelloUniverse.java

public void setProcessingMode(int mode) {

    // A typical driver might implement only one of these modes, and
    // throw an exception when there is an attempt to switch modes.
    // However, this example allows one to use any processing mode.

    switch (mode) {
    case InputDevice.DEMAND_DRIVEN:
    case InputDevice.NON_BLOCKING:
    case InputDevice.BLOCKING:
        processingMode = mode;//from   ww w  . ja v a  2  s. c  o  m
        break;
    default:
        throw new IllegalArgumentException(
                "Processing mode must " + "be one of DEMAND_DRIVEN, NON_BLOCKING, or BLOCKING");
    }
}