Class Sensor

java.lang.Object
javax.media.j3d.Sensor

public class Sensor extends Object
The Sensor Class encapsulates an object that provides real-time data. Examples include six-degree-of-freedom tracking, a joystick, or a data file being read back during a program. A sensor must be used in conjuction with an implementation of the InputDevice interface.

The Sensor object provides an abstract concept of a hardware input device. A Sensor consists of a timestamped sequence of input values and the state of buttons or switches at the time that Java 3D sampled the value. A sensor also contains a hotspot offset specified in the sensor's local coordinate system. If not specified, the hotspot is (0.0, 0.0, 0.0).

Since a typical hardware environment may contain multiple sensing elements, Java 3D maintains an array of sensors. Users can access a sensor directly from their Java code or they can assign a sensor to one of Java 3D's predefined 6DOF entities, such as UserHead.

Using a sensor is as easy as accessing an object. Write your Java code to extract the associated sensor value from the array of sensors. You can then directly apply that value to an element in a scene graph or process the sensor values in whatever way necessary.

Java 3D includes three special six-degrees-of-freedom (6DOF) entities. These include UserHead, DominantHand, and NondominantHand. You can assign or change which sensor drives one of these predefined entities. Java 3D uses the specified sensor to drive the 6DOF entity - most visibly the View.

Java 3D does not provide raw tracker or joystick-generated data in a sensor. At a minimum, Java 3D normalizes the raw data using the registration and calibration parameters either provided by or provided for the end user. It additionally may filter and process the data to remove noise and improve latency. The application programmer can suppress this latter effect on a sensor-by-sensor basis.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Default SensorRead object count (30); the number of SensorRead objects constructed if no count is specified.
    static final int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    static final int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    static final int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    static final int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    static final int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a Sensor object for the specified input device using default parameters.
    Sensor(InputDevice device, int sensorReadCount)
    Constructs a Sensor object for the specified input device using the specified number of SensorRead objects.
    Sensor(InputDevice device, int sensorReadCount, int sensorButtonCount)
    Constructs a Sensor object for the specified input device using the specified number of SensorRead objects and number of buttons.
    Sensor(InputDevice device, int sensorReadCount, int sensorButtonCount, javax.vecmath.Point3d hotspot)
    Constructs a Sensor object for the specified input device using the specified number of SensorRead objects, number of buttons, and hotspot.
    Sensor(InputDevice device, int sensorReadCount, javax.vecmath.Point3d hotspot)
    Constructs a Sensor object for the specified input device using the specified number of SensorRead objects and hotspot.
    Sensor(InputDevice device, javax.vecmath.Point3d hotspot)
    Constructs a Sensor object for the specified input device using the specified hotspot.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets the current sensor read.
    Retrieves the sensor's associated input device.
    void
    getHotspot(javax.vecmath.Point3d hotspot)
    Get the sensor's hotspot in this sensor's coordinate system.
    int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    int
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    void
    Retrieves the last sensor reading and copies that value into the specified argument.
    void
    getRead(Transform3D read, long deltaT)
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature; use getRead(Transform3D) instead.
    int
    Returns the number of buttons associated with this sensor.
    int
    Returns the number of SensorRead objects associated with this sensor.
    void
    lastButtons(int[] values)
    Places the most recent sensor reading value for each button into the array parameter; will throw an ArrayIndexOutOfBoundsException if values.length is less than the number of buttons.
    void
    lastButtons(int k, int[] values)
    Places the kth-most recent sensor reading value for each button into the array parameter; where k=0 is the most recent sensor reading, k=1 is the next most recent sensor reading, etc.; will throw an ArrayIndexOutOfBoundsException if values.length is less than the number of buttons.
    void
    Extracts the most recent sensor reading and copies that value into the specified argument.
    void
    lastRead(Transform3D read, int kth)
    Extracts the kth-most recent sensor reading and copies that value into the specified argument; where 0 is the most recent sensor reading, 1 is the next most recent sensor reading, etc.
    long
    Returns the time associated with the most recent sensor reading.
    long
    lastTime(int k)
    Returns the time associated with the kth-most recent sensor reading; where 0 is the most recent sensor reading, 1 is the next most recent sensor reading, etc.
    void
    Set the sensor's associated input device.
    void
    setHotspot(javax.vecmath.Point3d hotspot)
    Set the sensor's hotspot in this sensor's coordinate system.
    void
    setNextSensorRead(long time, Transform3D transform, int[] values)
    Sets the next sensor read to the specified values; once these values are set via this method they become the current values returned by methods such as lastRead(), lastTime(), and lastButtons(); note that if there are no buttons associated with this sensor, values can just be an empty array.
    void
    Sets the next sensor read to the specified values; once these values are set via this method they become the current values returned by methods such as lastRead(), lastTime(), and lastButtons().
    void
    setPredictionPolicy(int policy)
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    void
    setPredictor(int predictor)
    Deprecated.
    As of Java 3D version 1.4, prediction is not a supported feature.
    void
    setSensorReadCount(int count)
    Set the number of sensor read objects per Sensor.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PREDICT_NONE

      public static final int PREDICT_NONE
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      Set predictor type to do no prediction; this is the default.
      See Also:
    • PREDICT_NEXT_FRAME_TIME

      public static final int PREDICT_NEXT_FRAME_TIME
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      See Also:
    • NO_PREDICTOR

      public static final int NO_PREDICTOR
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      Use no prediction policy; this is the default.
      See Also:
    • HEAD_PREDICTOR

      public static final int HEAD_PREDICTOR
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      See Also:
    • HAND_PREDICTOR

      public static final int HAND_PREDICTOR
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      See Also:
    • DEFAULT_SENSOR_READ_COUNT

      public static final int DEFAULT_SENSOR_READ_COUNT
      Default SensorRead object count (30); the number of SensorRead objects constructed if no count is specified.
      See Also:
  • Constructor Details

    • Sensor

      public Sensor(InputDevice device)
      Constructs a Sensor object for the specified input device using default parameters. The default values are as follows:
        sensor read count : 30
        sensor button count : 0
        hot spot : (0,0,0)
        predictor : PREDICT_NONE — this attribute is unused
        prediction policy : NO_PREDICTOR — this attribute is unused
      Parameters:
      device - the Sensor's associated device.
    • Sensor

      public Sensor(InputDevice device, int sensorReadCount)
      Constructs a Sensor object for the specified input device using the specified number of SensorRead objects. Default values are used for all other parameters.
      Parameters:
      device - the Sensor's associated device
      sensorReadCount - the number of SensorReads to associate with this sensor
    • Sensor

      public Sensor(InputDevice device, int sensorReadCount, int sensorButtonCount)
      Constructs a Sensor object for the specified input device using the specified number of SensorRead objects and number of buttons. Default values are used for all other parameters.
      Parameters:
      device - the Sensor's associated device
      sensorReadCount - the number of SensorReads to associate with this sensor
      sensorButtonCount - the number of buttons associated with each sensor read
    • Sensor

      public Sensor(InputDevice device, javax.vecmath.Point3d hotspot)
      Constructs a Sensor object for the specified input device using the specified hotspot. Default values are used for all other parameters.
      Parameters:
      device - the Sensor's associated device
      hotspot - the Sensor's hotspot defined in its local coordinate system
    • Sensor

      public Sensor(InputDevice device, int sensorReadCount, javax.vecmath.Point3d hotspot)
      Constructs a Sensor object for the specified input device using the specified number of SensorRead objects and hotspot. Default values are used for all other parameters.
      Parameters:
      device - the Sensor's associated device
      sensorReadCount - the number of SensorReads to associate with this sensor
      hotspot - the Sensor's hotspot defined in its local coordinate system
    • Sensor

      public Sensor(InputDevice device, int sensorReadCount, int sensorButtonCount, javax.vecmath.Point3d hotspot)
      Constructs a Sensor object for the specified input device using the specified number of SensorRead objects, number of buttons, and hotspot. Default values are used for all other parameters.
      Parameters:
      device - the Sensor's associated device
      sensorReadCount - the number of SensorReads to associate with this sensor
      sensorButtonCount - the number of buttons associated with each sensor read
      hotspot - the Sensor's hotspot defined in its local coordinate system
  • Method Details

    • setPredictor

      public void setPredictor(int predictor)
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      Sets the type of predictor to use with this sensor. Since prediction is not implemented (and never has been), this attribute has no effect.
      Parameters:
      predictor - predictor type one of PREDICT_NONE or PREDICT_NEXT_FRAME_TIME
      Throws:
      IllegalArgumentException - if an invalid predictor type is specified.
    • getPredictor

      public int getPredictor()
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      Returns the type of predictor used by this sensor.
      Returns:
      the predictor type.
    • setPredictionPolicy

      public void setPredictionPolicy(int policy)
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      Sets the prediction policy use by this sensor. Since prediction is not implemented (and never has been), this attribute has no effect.
      Parameters:
      policy - prediction policy one of NO_PREDICTOR, HEAD_PREDICTOR, or HAND_PREDICTOR
      Throws:
      IllegalArgumentException - if an invalid prediction policy is specified.
    • getPredictionPolicy

      public int getPredictionPolicy()
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature.
      Returns the prediction policy used by this sensor.
      Returns:
      the prediction policy.
    • setHotspot

      public void setHotspot(javax.vecmath.Point3d hotspot)
      Set the sensor's hotspot in this sensor's coordinate system.
      Parameters:
      hotspot - the sensor's new hotspot
    • getHotspot

      public void getHotspot(javax.vecmath.Point3d hotspot)
      Get the sensor's hotspot in this sensor's coordinate system.
      Parameters:
      hotspot - the variable to receive the sensor's hotspot
    • setDevice

      public void setDevice(InputDevice device)
      Set the sensor's associated input device.
      Parameters:
      device - the sensor's new device
    • getDevice

      public InputDevice getDevice()
      Retrieves the sensor's associated input device.
      Returns:
      the sensor's device
    • getRead

      public void getRead(Transform3D read)
      Retrieves the last sensor reading and copies that value into the specified argument.
      Parameters:
      read - the matrix that will receive the sensor reading
    • getRead

      public void getRead(Transform3D read, long deltaT)
      Deprecated.
      As of Java 3D version 1.4, prediction is not a supported feature; use getRead(Transform3D) instead.
      Retrieves the last sensor reading and copies that value into the specified argument.
      Parameters:
      read - the matrix that will receive the sensor reading
      deltaT - this parameter is ignored
    • lastRead

      public void lastRead(Transform3D read)
      Extracts the most recent sensor reading and copies that value into the specified argument.
      Parameters:
      read - the matrix that will receive the most recent sensor reading
    • lastRead

      public void lastRead(Transform3D read, int kth)
      Extracts the kth-most recent sensor reading and copies that value into the specified argument; where 0 is the most recent sensor reading, 1 is the next most recent sensor reading, etc.
      Parameters:
      read - the matrix that will receive the most recent sensor reading
      kth - the kth previous sensor reading
    • lastTime

      public long lastTime()
      Returns the time associated with the most recent sensor reading.
      Returns:
      the time associated with the most recent sensor reading.
    • lastTime

      public long lastTime(int k)
      Returns the time associated with the kth-most recent sensor reading; where 0 is the most recent sensor reading, 1 is the next most recent sensor reading, etc.
      Returns:
      the time associated with the kth-most recent sensor reading.
    • lastButtons

      public void lastButtons(int[] values)
      Places the most recent sensor reading value for each button into the array parameter; will throw an ArrayIndexOutOfBoundsException if values.length is less than the number of buttons.
      Parameters:
      values - the array into which the button values will be placed
    • lastButtons

      public void lastButtons(int k, int[] values)
      Places the kth-most recent sensor reading value for each button into the array parameter; where k=0 is the most recent sensor reading, k=1 is the next most recent sensor reading, etc.; will throw an ArrayIndexOutOfBoundsException if values.length is less than the number of buttons.
      Parameters:
      k - the time associated with the most recent sensor reading
      values - the array into which the button values will be placed.
    • getSensorReadCount

      public int getSensorReadCount()
      Returns the number of SensorRead objects associated with this sensor.
      Returns:
      the number of SensorReadObjects associated with this sensor
    • setSensorReadCount

      public void setSensorReadCount(int count)
      Set the number of sensor read objects per Sensor. This is a calibration parameter that should normally be set in this object's constructor. Calling this method resets all of this sensor's values that are already in the buffer. It is illegal to change this value after the device has been added to the scheduler.
      Parameters:
      count - the new sensor read count
    • getSensorButtonCount

      public int getSensorButtonCount()
      Returns the number of buttons associated with this sensor.
      Returns:
      the number of buttons associated with this sensor.
    • getCurrentSensorRead

      public SensorRead getCurrentSensorRead()
      Gets the current sensor read.
      Returns:
      the current sensor read object
    • setNextSensorRead

      public void setNextSensorRead(long time, Transform3D transform, int[] values)
      Sets the next sensor read to the specified values; once these values are set via this method they become the current values returned by methods such as lastRead(), lastTime(), and lastButtons(); note that if there are no buttons associated with this sensor, values can just be an empty array.
      Parameters:
      time - the next SensorRead's associated time
      transform - the next SensorRead's transformation
      values - the next SensorRead's buttons' states
    • setNextSensorRead

      public void setNextSensorRead(SensorRead read)
      Sets the next sensor read to the specified values; once these values are set via this method they become the current values returned by methods such as lastRead(), lastTime(), and lastButtons().
      Parameters:
      read - the next SensorRead's values