Package gaiasky.vr.openvr
Class VRContext.VRDevice
- java.lang.Object
-
- gaiasky.vr.openvr.VRContext.VRDevice
-
- Enclosing class:
- VRContext
public class VRContext.VRDevice extends java.lang.ObjectRepresents a tracked VR device such as the head mounted display, wands etc.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description floatgetAxisX(int axis)floatgetAxisY(int axis)booleangetBooleanProperty(VRContext.VRDeviceProperty property)VRContext.VRControllerRolegetControllerRole()TheVRContext.VRControllerRole, indicating if theVRContext.VRDeviceis assigned to the left or right hand.com.badlogic.gdx.math.Vector3getDirection(VRContext.Space space)floatgetFloatProperty(VRContext.VRDeviceProperty property)intgetInt32Property(VRContext.VRDeviceProperty property)IntModelInstancegetModelInstance()VRContext.VRDevicePosegetPose()com.badlogic.gdx.math.Vector3getPosition(VRContext.Space space)com.badlogic.gdx.math.Vector3getRight(VRContext.Space space)java.lang.StringgetStringProperty(VRContext.VRDeviceProperty property)VRContext.VRDeviceTypegetType()longgetUInt64Property(VRContext.VRDeviceProperty property)com.badlogic.gdx.math.Vector3getUp(VRContext.Space space)voidinitialize()booleanisButtonPressed(int button)booleanisConnected()booleanisInitialized()booleanpollAxis(int axis)Updates the axis values and returns whether the values changed.java.lang.StringtoString()voidtriggerHapticPulse(short duration)Trigger a haptic pulse (vibrate) for the duration in microseconds.voidupdateAxesAndPosition()
-
-
-
Method Detail
-
initialize
public void initialize()
-
getPose
public VRContext.VRDevicePose getPose()
- Returns:
- the most up-to-date
VRContext.VRDevicePosein tracker space
-
updateAxesAndPosition
public void updateAxesAndPosition()
-
getPosition
public com.badlogic.gdx.math.Vector3 getPosition(VRContext.Space space)
- Returns:
- the position in the given
VRContext.Space
-
getRight
public com.badlogic.gdx.math.Vector3 getRight(VRContext.Space space)
- Returns:
- the right vector in the given
VRContext.Space
-
getUp
public com.badlogic.gdx.math.Vector3 getUp(VRContext.Space space)
- Returns:
- the up vector in the given
VRContext.Space
-
getDirection
public com.badlogic.gdx.math.Vector3 getDirection(VRContext.Space space)
- Returns:
- the direction vector in the given
VRContext.Space
-
getType
public VRContext.VRDeviceType getType()
- Returns:
- the
VRContext.VRDeviceType
-
getControllerRole
public VRContext.VRControllerRole getControllerRole()
TheVRContext.VRControllerRole, indicating if theVRContext.VRDeviceis assigned to the left or right hand.Note: the role is not reliable! If one controller is connected on startup, it will have a role of
VRContext.VRControllerRole.Unknownand retain that role even if a second controller is connected (which will also haven an unknown role). The role is only reliable if two controllers are connected already, and none of the controllers disconnects during the application life-time. At least on the HTC Vive, the first connected controller is always the right hand and the second connected controller is the left hand. The order stays the same even if controllers disconnect/reconnect during the application life-time.
-
isConnected
public boolean isConnected()
- Returns:
- whether the device is connected
-
isButtonPressed
public boolean isButtonPressed(int button)
- Returns:
- whether the button from
VRContext.VRControllerButtonsis pressed
-
getAxisX
public float getAxisX(int axis)
- Returns:
- the x-coordinate in the range [-1, 1] of the given axis from
VRContext.VRControllerAxes
-
getAxisY
public float getAxisY(int axis)
- Returns:
- the y-coordinate in the range [-1, 1] of the given axis from
VRContext.VRControllerAxes
-
triggerHapticPulse
public void triggerHapticPulse(short duration)
Trigger a haptic pulse (vibrate) for the duration in microseconds. Subsequent calls to this method within 5ms will be ignored.- Parameters:
duration- pulse duration in microseconds
-
getBooleanProperty
public boolean getBooleanProperty(VRContext.VRDeviceProperty property)
- Returns:
- a boolean property or false if the query failed
-
getFloatProperty
public float getFloatProperty(VRContext.VRDeviceProperty property)
- Returns:
- a float property or 0 if the query failed
-
getInt32Property
public int getInt32Property(VRContext.VRDeviceProperty property)
- Returns:
- an int property or 0 if the query failed
-
getUInt64Property
public long getUInt64Property(VRContext.VRDeviceProperty property)
- Returns:
- a long property or 0 if the query failed
-
getStringProperty
public java.lang.String getStringProperty(VRContext.VRDeviceProperty property)
- Returns:
- a string property or null if the query failed
-
getModelInstance
public IntModelInstance getModelInstance()
- Returns:
- a
IntModelInstancewith the transform updated to the latest tracked position and orientation in world space for rendering or null
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
pollAxis
public boolean pollAxis(int axis)
Updates the axis values and returns whether the values changed.- Parameters:
axis- The axis- Returns:
- Whether the values of this axis changed
-
isInitialized
public boolean isInitialized()
-
-