# Class PhysicalEnvironment

java.lang.Object
javax.media.j3d.PhysicalEnvironment

public class PhysicalEnvironment extends Object
This object contains a specification of the physical environment in which the view will be generated. It is used to set up input devices (sensors) for head-tracking and other uses, and the audio output device. Sensors are indexed starting at zero.

See Also:
  - `View`

## Constructor Summary

Constructors
Constructor
Description
`PhysicalEnvironment()`
Constructs a PhysicalEnvironment object with default parameters.
`PhysicalEnvironment(int sensorCount)`
Constructs and initializes a PhysicalEnvironment object with the specified number of sensors.

## Method Summary

Modifier and Type
Method
Description
`void`
`addInputDevice(InputDevice device)`
Add an input device to the list of input devices.
`Enumeration`
`getAllInputDevices()`
Create an enumerator that produces all input devices.
`AudioDevice`
`getAudioDevice()`
Gets the audioDevice for this PhysicalEnvironment.
`int`
`getCoexistenceCenterInPworldPolicy()`
Returns the current coexistence center in physical world policy.
`void`
`getCoexistenceToTrackerBase(Transform3D t)`
Retrieves the coexistence coordinate system to tracker-base coordinate system transform and copies it into the specified Transform3D object.
`int`
`getDominantHandIndex()`
Gets the sensor index of the dominant hand.
`int`
`getHeadIndex()`
Gets the sensor index of the head.
`int`
`getLeftHandIndex()`
Gets the sensor index of the left hand.
`int`
`getNonDominantHandIndex()`
Gets the sensor index of the non-dominant hand.
`int`
`getRightHandIndex()`
Gets the sensor index of the right hand.
`Sensor`
`getSensor(int index)`
Gets the sensor specified by the index; sensors are indexed starting at 0.
`int`
`getSensorCount()`
Get the current sensor count.
`boolean`
`getTrackingAvailable()`
Returns a status flag indicating whether or not tracking is available.
`void`
`removeInputDevice(InputDevice device)`
Remove an input device from the list of input devices.
`void`
`setAudioDevice(AudioDevice device)`
Sets the specified AudioDevice object as the device through which audio rendering for this PhysicalEnvironment will be performed.
`void`
`setCoexistenceCenterInPworldPolicy(int policy)`
Sets the coexistence center in physical world policy.
`void`
`setCoexistenceToTrackerBase(Transform3D t)`
Sets the coexistence coordinate system to tracker-base coordinate system transform.
`void`
`setDominantHandIndex(int index)`
Sets the index of the dominant hand to the specified sensor index.
`void`
`setHeadIndex(int index)`
Sets the index of the head to the specified sensor index.
`void`
`setLeftHandIndex(int index)`
Sets the index of the left hand to the specified sensor index.
`void`
`setNonDominantHandIndex(int index)`
Sets the index of the non-dominant hand to the specified sensor index.
`void`
`setRightHandIndex(int index)`
Sets the index of the right hand to the specified sensor index.
`void`
`setSensor(int index, Sensor sensor)`
Set the sensor specified by the index to sensor provided; sensors are indexed starting at 0.
`void`
`setSensorCount(int count)`
Set the number of sensor objects per PhysicalEnvironmnet.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PhysicalEnvironment

public PhysicalEnvironment()
Constructs a PhysicalEnvironment object with default parameters. The default values are as follows:

sensor count : 3
sensors : null (for all array elements)
head index : 0
right hand index : 1
left hand index : 2
dominant hand index : 1
nondominant hand index : 2
tracking available : false
audio device : null
input device list : empty
coexistence to tracker base transform : identity
coexistence center in pworld policy : View.NOMINAL_SCREEN

### PhysicalEnvironment

public PhysicalEnvironment(int sensorCount)
Constructs and initializes a PhysicalEnvironment object with the specified number of sensors.

Parameters:
  `sensorCount` - the number of sensors to create.

## Method Details

### setAudioDevice

public void setAudioDevice(AudioDevice device)
Sets the specified AudioDevice object as the device through which audio rendering for this PhysicalEnvironment will be performed.

Parameters:
  `device` - audio device object to be associated with this PhysicalEnvironment

### getAudioDevice

public AudioDevice getAudioDevice()
Gets the audioDevice for this PhysicalEnvironment.

Returns:
  audio device object associated with this PhysicalEnvironment

### getAllInputDevices

public Enumeration getAllInputDevices()
Create an enumerator that produces all input devices.

Returns:
  an enumerator of all available devices

### addInputDevice

public void addInputDevice(InputDevice device)
Add an input device to the list of input devices. User is responsible for initializing the device and setting the processing mode (streaming or polling).

Parameters:
  `device` - the device to be added to the list of input devices
Throws:
  `IllegalArgumentException` - if InputDevice.getProcessingMode() does not return one of BLOCKING, NON_BLOCKING, or DEMAND_DRIVEN.

### removeInputDevice

public void removeInputDevice(InputDevice device)
Remove an input device from the list of input devices. User is responsible for closing out the device and releasing the device resources.

Parameters:
  `device` - the device to be removed

### setHeadIndex

public void setHeadIndex(int index)
Sets the index of the head to the specified sensor index.

Parameters:
  `index` - the new sensor index of the head

### getHeadIndex

public int getHeadIndex()
Gets the sensor index of the head.

Returns:
  the sensor index of the head

### setRightHandIndex

public void setRightHandIndex(int index)
Sets the index of the right hand to the specified sensor index.

Parameters:
  `index` - the new sensor index of the right hand

### getRightHandIndex

public int getRightHandIndex()
Gets the sensor index of the right hand.

Returns:
  the sensor index of the right hand

### setLeftHandIndex

public void setLeftHandIndex(int index)
Sets the index of the left hand to the specified sensor index.

Parameters:
  `index` - the new sensor index of the left hand

### getLeftHandIndex

public int getLeftHandIndex()
Gets the sensor index of the left hand.

Returns:
  the sensor index of the left hand

### setDominantHandIndex

public void setDominantHandIndex(int index)
Sets the index of the dominant hand to the specified sensor index.

Parameters:
  `index` - the new sensor index of the dominant hand

### getDominantHandIndex

public int getDominantHandIndex()
Gets the sensor index of the dominant hand.

Returns:
  the sensor index of the dominant hand

### setNonDominantHandIndex

public void setNonDominantHandIndex(int index)
Sets the index of the non-dominant hand to the specified sensor index.

Parameters:
  `index` - the new sensor index of the non dominant hand

### getNonDominantHandIndex

public int getNonDominantHandIndex()
Gets the sensor index of the non-dominant hand.

Returns:
  the sensor index of the non dominant hand

### setSensor

public void setSensor(int index, Sensor sensor)
Set the sensor specified by the index to sensor provided; sensors are indexed starting at 0. All sensors must be registered via this method.

Parameters:
  `index` - the sensor's index
  `sensor` - the new sensor

### getSensor

public Sensor getSensor(int index)
Gets the sensor specified by the index; sensors are indexed starting at 0.

Parameters:
  `index` - the sensor's index

### setCoexistenceToTrackerBase

public void setCoexistenceToTrackerBase(Transform3D t)
Sets the coexistence coordinate system to tracker-base coordinate system transform. If head tracking is enabled, this transform is a calibration constant. If head tracking is not enabled, this transform is not used. This is used in both SCREEN_VIEW and HMD_VIEW modes.

Parameters:
  `t` - the new transform
Throws:
  `BadTransformException` - if the transform is not rigid

### getCoexistenceToTrackerBase

public void getCoexistenceToTrackerBase(Transform3D t)
Retrieves the coexistence coordinate system to tracker-base coordinate system transform and copies it into the specified Transform3D object.

Parameters:
  `t` - the object that will receive the transform

### getTrackingAvailable

public boolean getTrackingAvailable()
Returns a status flag indicating whether or not tracking is available.

Returns:
  a flag telling whether tracking is available

### setCoexistenceCenterInPworldPolicy

public void setCoexistenceCenterInPworldPolicy(int policy)
Sets the coexistence center in physical world policy. This setting determines how Java 3D places the user's eye point as a function of head position during the calibration process, one of View.NOMINAL_SCREEN, View.NOMINAL_HEAD, or View.NOMINAL_FEET. The default policy is View.NOMINAL_SCREEN.

Parameters:
  `policy` - the new policy

### getCoexistenceCenterInPworldPolicy

public int getCoexistenceCenterInPworldPolicy()
Returns the current coexistence center in physical world policy.

Returns:
  one of: View.NOMINAL_SCREEN, View.NOMINAL_HEAD, or View.NOMINAL_FEET

### getSensorCount

public int getSensorCount()
Get the current sensor count.

Returns:
  the number of sensor objects per PhysicalEnvironment object

### setSensorCount

public void setSensorCount(int count)
Set the number of sensor objects per PhysicalEnvironmnet. This is a calibration parameter that should be set before setting any sensors in the PhysicalEnvironment object. This call associates 'count' Sensors with this object, and they are indexed from 0 to count-1.

Parameters:
  `count` - the new sensor count