QVR 4.1.0
A library to build Virtual Reality applications
Loading...
Searching...
No Matches
QVRDevice Class Reference

Device for interaction purposes. More...

#include <device.hpp>

Public Member Functions

Constructor / Destructor
 QVRDevice ()
 Constructor.
 
 QVRDevice (int index)
 Constructor for the device with the given index in the QVR configuration.
 
 QVRDevice (const QVRDevice &d)
 Copy constructor.
 
 ~QVRDevice ()
 Destructor.
 
const QVRDeviceoperator= (const QVRDevice &d)
 Assignment operator.
 
Configuration
int index () const
 Returns the index of the device in the QVR configuration.
 
const QString & id () const
 Returns the unique id.
 
const QVRDeviceConfigconfig () const
 Returns the configuration.
 
Pose and velocity
const QVector3D & position () const
 Returns the position.
 
const QQuaternion & orientation () const
 Returns the orientation.
 
const QVector3D & velocity () const
 Returns the velocity, in m/s.
 
const QVector3D & angularVelocity () const
 Returns the angular velocity. The direction of the returned vector specifies the axis of rotation, and its length gives the rotation speed in radians/s.
 
QMatrix4x4 matrix () const
 Returns the position and orientation as a matrix.
 
State of buttons and analog elements
int buttonCount () const
 Returns the number of buttons on this device.
 
QVRButton button (int index) const
 Returns the type of the button with index.
 
int buttonIndex (QVRButton btn) const
 Returns the index of the button btn, or -1 if this device does not have that button.
 
bool hasButton (QVRButton btn) const
 Returns whether this device has button btn.
 
bool isButtonPressed (int index) const
 Returns whether the button with the given index is pressed.
 
bool isButtonPressed (QVRButton btn) const
 Returns whether the button btn is pressed. Returns false if this device does not have that button.
 
int analogCount () const
 Returns the number of analog joystick elements on this device. Usually index 0 will be the x axis and index 1 the y axis for two-dimensional joysticks.
 
QVRAnalog analog (int index) const
 Returns the type of the analog element with index.
 
int analogIndex (QVRAnalog anlg) const
 Returns the index of the analog element anlg, or -1 if this device does not have that element.
 
bool hasAnalog (QVRAnalog anlg) const
 Returns whether this device has analog element anlg.
 
float analogValue (int index) const
 Returns the value of the analog joystick element with the given index. This is either in [-1,1] (for axis-type analog elements) or in [0,1] (for trigger-type analog elements).
 
float analogValue (QVRAnalog anlg) const
 Returns the value of the analog element anlg. Returns 0 if this device does not have that element.
 
Rendering a device representation

A renderable representation of a device consists of one or more nodes. Each node has its own transformation (position and orientation) and contains vertex data (positions, normals, texture coordinates) and optionally a texture.

You can query the number of nodes with modelNodeCount() and then render all nodes sequentially to get the full device representation.

Since the representation of the device depends on its state (buttons, analog elements, ...), the number of nodes and their transformations may change between frames. However, vertex data and textures with a given index are constant and can therefore be uploaded to GPU buffers once and then reused.

int modelNodeCount () const
 Returns the number of nodes that are currently in the renderable device model, or 0 if there is no such model. This depends on the current state of the device and can therefore change between frames.
 
QVector3D modelNodePosition (int nodeIndex) const
 Returns the current position of the renderable device model node with the given index. This depends on the current state of the device and can therefore change between frames.
 
QQuaternion modelNodeOrientation (int nodeIndex) const
 Returns the current orientation of the renderable device model node with the given index. This depends on the current state of the device and can therefore change between frames.
 
QMatrix4x4 modelNodeMatrix (int nodeIndex) const
 Returns the position and orientation of the renderable device model node with the given index as a matrix. This depends on the current state of the device and can therefore change between frames.
 
int modelNodeVertexDataIndex (int nodeIndex) const
 Returns the index of the vertex data block associated with the given renderable device model node. Pass this index to QVRManager::deviceModelVertexCound(), QVRManager::deviceModelVertexPositions(), QVRManager::deviceModelVertexNormals(), and QVRManager::deviceModelVertexTexCoords() to get the actual vertex data. Vertex data with a given index never changes, so you can e.g. upload this data to a GPU buffer once and reuse it.
 
int modelNodeTextureIndex (int nodeIndex) const
 Returns the index of the texture associated with the given renderable device model node. Pass this index to QVRManager::deviceModelTexture() to get the actual texture data. Texture data with a given index never changes, so you can e.g. upload this data to a GPU buffer once and reuse it.
 
Haptic feedback

Some devices, usually hand-held controllers, support haptic pulses.

bool supportsHapticPulse () const
 Returns whether this device supports haptic pulses.
 
void triggerHapticPulse (int microseconds) const
 Triggers a haptic pulse with the given duration in microseconds. Note that there may be a device-dependent limit on the duration; for now, avoid values larger than 3999.
 

Friends

class QVRManager
 
QDataStream & operator<< (QDataStream &ds, const QVRDevice &d)
 Writes the device d to the stream ds.
 
QDataStream & operator>> (QDataStream &ds, QVRDevice &d)
 Reads the device d from the stream ds.
 

Detailed Description

Device for interaction purposes.

A device is anything a Virtual Reality application might use for interaction purposes, e.g. a wand, a flystick, a 3DOF or 6DOF tracker target, or similar; in short, anything that may be tracked, has buttons, and/or has analog joystick functionality.

For example, tracked glasses can be used to track an observer, and a game controller can be used for navigation.

A device is configured via QVRDeviceConfig.

Constructor & Destructor Documentation

◆ QVRDevice() [1/3]

QVRDevice::QVRDevice ( )

Constructor.

◆ QVRDevice() [2/3]

QVRDevice::QVRDevice ( int index)

Constructor for the device with the given index in the QVR configuration.

◆ QVRDevice() [3/3]

QVRDevice::QVRDevice ( const QVRDevice & d)

Copy constructor.

◆ ~QVRDevice()

QVRDevice::~QVRDevice ( )

Destructor.

Member Function Documentation

◆ analog()

QVRAnalog QVRDevice::analog ( int index) const
inline

Returns the type of the analog element with index.

◆ analogCount()

int QVRDevice::analogCount ( ) const
inline

Returns the number of analog joystick elements on this device. Usually index 0 will be the x axis and index 1 the y axis for two-dimensional joysticks.

◆ analogIndex()

int QVRDevice::analogIndex ( QVRAnalog anlg) const
inline

Returns the index of the analog element anlg, or -1 if this device does not have that element.

◆ analogValue() [1/2]

float QVRDevice::analogValue ( int index) const
inline

Returns the value of the analog joystick element with the given index. This is either in [-1,1] (for axis-type analog elements) or in [0,1] (for trigger-type analog elements).

◆ analogValue() [2/2]

float QVRDevice::analogValue ( QVRAnalog anlg) const
inline

Returns the value of the analog element anlg. Returns 0 if this device does not have that element.

◆ angularVelocity()

const QVector3D & QVRDevice::angularVelocity ( ) const
inline

Returns the angular velocity. The direction of the returned vector specifies the axis of rotation, and its length gives the rotation speed in radians/s.

◆ button()

QVRButton QVRDevice::button ( int index) const
inline

Returns the type of the button with index.

◆ buttonCount()

int QVRDevice::buttonCount ( ) const
inline

Returns the number of buttons on this device.

◆ buttonIndex()

int QVRDevice::buttonIndex ( QVRButton btn) const
inline

Returns the index of the button btn, or -1 if this device does not have that button.

◆ config()

const QVRDeviceConfig & QVRDevice::config ( ) const

Returns the configuration.

◆ hasAnalog()

bool QVRDevice::hasAnalog ( QVRAnalog anlg) const
inline

Returns whether this device has analog element anlg.

◆ hasButton()

bool QVRDevice::hasButton ( QVRButton btn) const
inline

Returns whether this device has button btn.

◆ id()

const QString & QVRDevice::id ( ) const

Returns the unique id.

◆ index()

int QVRDevice::index ( ) const

Returns the index of the device in the QVR configuration.

◆ isButtonPressed() [1/2]

bool QVRDevice::isButtonPressed ( int index) const
inline

Returns whether the button with the given index is pressed.

◆ isButtonPressed() [2/2]

bool QVRDevice::isButtonPressed ( QVRButton btn) const
inline

Returns whether the button btn is pressed. Returns false if this device does not have that button.

◆ matrix()

QMatrix4x4 QVRDevice::matrix ( ) const
inline

Returns the position and orientation as a matrix.

◆ modelNodeCount()

int QVRDevice::modelNodeCount ( ) const

Returns the number of nodes that are currently in the renderable device model, or 0 if there is no such model. This depends on the current state of the device and can therefore change between frames.

◆ modelNodeMatrix()

QMatrix4x4 QVRDevice::modelNodeMatrix ( int nodeIndex) const
inline

Returns the position and orientation of the renderable device model node with the given index as a matrix. This depends on the current state of the device and can therefore change between frames.

◆ modelNodeOrientation()

QQuaternion QVRDevice::modelNodeOrientation ( int nodeIndex) const

Returns the current orientation of the renderable device model node with the given index. This depends on the current state of the device and can therefore change between frames.

◆ modelNodePosition()

QVector3D QVRDevice::modelNodePosition ( int nodeIndex) const

Returns the current position of the renderable device model node with the given index. This depends on the current state of the device and can therefore change between frames.

◆ modelNodeTextureIndex()

int QVRDevice::modelNodeTextureIndex ( int nodeIndex) const

Returns the index of the texture associated with the given renderable device model node. Pass this index to QVRManager::deviceModelTexture() to get the actual texture data. Texture data with a given index never changes, so you can e.g. upload this data to a GPU buffer once and reuse it.

◆ modelNodeVertexDataIndex()

int QVRDevice::modelNodeVertexDataIndex ( int nodeIndex) const

Returns the index of the vertex data block associated with the given renderable device model node. Pass this index to QVRManager::deviceModelVertexCound(), QVRManager::deviceModelVertexPositions(), QVRManager::deviceModelVertexNormals(), and QVRManager::deviceModelVertexTexCoords() to get the actual vertex data. Vertex data with a given index never changes, so you can e.g. upload this data to a GPU buffer once and reuse it.

◆ operator=()

const QVRDevice & QVRDevice::operator= ( const QVRDevice & d)

Assignment operator.

◆ orientation()

const QQuaternion & QVRDevice::orientation ( ) const
inline

Returns the orientation.

◆ position()

const QVector3D & QVRDevice::position ( ) const
inline

Returns the position.

◆ supportsHapticPulse()

bool QVRDevice::supportsHapticPulse ( ) const

Returns whether this device supports haptic pulses.

◆ triggerHapticPulse()

void QVRDevice::triggerHapticPulse ( int microseconds) const

Triggers a haptic pulse with the given duration in microseconds. Note that there may be a device-dependent limit on the duration; for now, avoid values larger than 3999.

◆ velocity()

const QVector3D & QVRDevice::velocity ( ) const
inline

Returns the velocity, in m/s.

Friends And Related Symbol Documentation

◆ operator<<

QDataStream & operator<< ( QDataStream & ds,
const QVRDevice & d )
friend

Writes the device d to the stream ds.

◆ operator>>

QDataStream & operator>> ( QDataStream & ds,
QVRDevice & d )
friend

Reads the device d from the stream ds.

◆ QVRManager

friend class QVRManager
friend

The documentation for this class was generated from the following file: