public class Sensor extends Object
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.
SensorRead
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_SENSOR_READ_COUNT
Default SensorRead object count (30); the number of SensorRead
objects constructed if no count is specified.
|
static int |
HAND_PREDICTOR
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
static int |
HEAD_PREDICTOR
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
static int |
NO_PREDICTOR
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
static int |
PREDICT_NEXT_FRAME_TIME
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
static int |
PREDICT_NONE
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
Constructor and Description |
---|
Sensor(InputDevice device)
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,
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,
Point3d hotspot)
Constructs a Sensor object for the specified input device using
the specified number of SensorRead objects and hotspot.
|
Sensor(InputDevice device,
Point3d hotspot)
Constructs a Sensor object for the specified input device using
the specified hotspot.
|
Modifier and Type | Method and Description |
---|---|
SensorRead |
getCurrentSensorRead()
Gets the current sensor read.
|
InputDevice |
getDevice()
Retrieves the sensor's associated input device.
|
void |
getHotspot(Point3d hotspot)
Get the sensor's hotspot in this sensor's coordinate system.
|
int |
getPredictionPolicy()
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
int |
getPredictor()
Deprecated.
As of Java 3D version 1.4, prediction is not a
supported feature.
|
void |
getRead(Transform3D read)
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 |
getSensorButtonCount()
Returns the number of buttons associated with this sensor.
|
int |
getSensorReadCount()
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 |
lastRead(Transform3D read)
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 |
lastTime()
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 |
setDevice(InputDevice device)
Set the sensor's associated input device.
|
void |
setHotspot(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 |
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().
|
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.
|
public static final int PREDICT_NONE
public static final int PREDICT_NEXT_FRAME_TIME
public static final int NO_PREDICTOR
public static final int HEAD_PREDICTOR
public static final int HAND_PREDICTOR
public static final int DEFAULT_SENSOR_READ_COUNT
public Sensor(InputDevice device)
device
- the Sensor's associated device.public Sensor(InputDevice device, int sensorReadCount)
device
- the Sensor's associated devicesensorReadCount
- the number of SensorReads to associate with
this sensorpublic Sensor(InputDevice device, int sensorReadCount, int sensorButtonCount)
device
- the Sensor's associated devicesensorReadCount
- the number of SensorReads to associate with
this sensorsensorButtonCount
- the number of buttons associated with each
sensor readpublic Sensor(InputDevice device, Point3d hotspot)
device
- the Sensor's associated devicehotspot
- the Sensor's hotspot defined in its local coordinate
systempublic Sensor(InputDevice device, int sensorReadCount, Point3d hotspot)
device
- the Sensor's associated devicesensorReadCount
- the number of SensorReads to associate with
this sensorhotspot
- the Sensor's hotspot defined in its local coordinate
systempublic Sensor(InputDevice device, int sensorReadCount, int sensorButtonCount, Point3d hotspot)
device
- the Sensor's associated devicesensorReadCount
- the number of SensorReads to associate with
this sensorsensorButtonCount
- the number of buttons associated with each
sensor readhotspot
- the Sensor's hotspot defined in its local coordinate
systempublic void setPredictor(int predictor)
predictor
- predictor type one of PREDICT_NONE or
PREDICT_NEXT_FRAME_TIMEIllegalArgumentException
- if an invalid predictor type
is specified.public int getPredictor()
public void setPredictionPolicy(int policy)
policy
- prediction policy one of NO_PREDICTOR, HEAD_PREDICTOR,
or HAND_PREDICTORIllegalArgumentException
- if an invalid prediction policy
is specified.public int getPredictionPolicy()
public void setHotspot(Point3d hotspot)
hotspot
- the sensor's new hotspotpublic void getHotspot(Point3d hotspot)
hotspot
- the variable to receive the sensor's hotspotpublic void setDevice(InputDevice device)
device
- the sensor's new devicepublic InputDevice getDevice()
public void getRead(Transform3D read)
read
- the matrix that will receive the sensor readingpublic void getRead(Transform3D read, long deltaT)
getRead(Transform3D)
instead.read
- the matrix that will receive the sensor readingdeltaT
- this parameter is ignoredpublic void lastRead(Transform3D read)
read
- the matrix that will receive the most recent sensor readingpublic void lastRead(Transform3D read, int kth)
read
- the matrix that will receive the most recent sensor readingkth
- the kth previous sensor readingpublic long lastTime()
public long lastTime(int k)
public void lastButtons(int[] values)
values
- the array into which the button values will be
placedpublic void lastButtons(int k, int[] values)
k
- the time associated with the most recent sensor readingvalues
- the array into which the button values will be
placed.public int getSensorReadCount()
public void setSensorReadCount(int count)
count
- the new sensor read countpublic int getSensorButtonCount()
public SensorRead getCurrentSensorRead()
public void setNextSensorRead(long time, Transform3D transform, int[] values)
time
- the next SensorRead's associated timetransform
- the next SensorRead's transformationvalues
- the next SensorRead's buttons' statespublic void setNextSensorRead(SensorRead read)
read
- the next SensorRead's valuesCopyright © 2016–2022 SciJava. All rights reserved.