Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
Hx3DWand Class Reference

Base class representing a 3D wand in XScreen. More...

#include <Hx3DWand.h>

Public Member Functions

void setGeometry (SoNode *wand, const SbVec3f &hotSpot)
 Sets the inventor geometry used to display the wand in normal state, as well as the top of the wand. More...
 
void setHighlightGeometry (SoNode *wand)
 Sets the inventor geometry used to display the wand in highlighted state. More...
 
void setWandScale (float scaleFactor)
 Sets the scale factor applied to the wand geometry. More...
 
float getWandScale () const
 Returns the scale factor of the wand. More...
 
virtual void setHighlight (bool enable)
 Highlights the wand. More...
 
bool getButton (int butIdx) const
 Returns the current state of a button of the VR input device. More...
 
int getButtonStatus () const
 Returns the current combined state of all buttons of the VR input device. More...
 
bool wasButtonPressed (int butIdx) const
 Returns true if the specified button was pressed since the. More...
 
bool wasButtonReleased (int butIdx) const
 Returns true if the specified button was released since the scene graph was traversed the last time by the handle event action. More...
 
const SbVec3f & origin (bool scene=true) const
 Returns the origin of the 3D wand. More...
 
const SbVec3f & top (bool scene=true) const
 Returns the top of the 3D wand. More...
 
const SbRotation & orientation (bool scene=true) const
 Returns the current orientation of the wand. More...
 
float length (bool scene=true) const
 Returns the length of the wand. More...
 
const SbMatrix & sceneXform () const
 Returns the matrix which transforms between scene coordinates and VR coordinates, i.e., the coordinates used in the XScreen configuration file. More...
 
const SbMatrix & sceneXformInverse () const
 Returns the inverse of sceneXform(). More...
 
virtual void update (const SbVec3f &pos, const SbRotation &rot, int butStat)
 Updates the 3D wand position. More...
 
const SbVec3f & getHotSpot () const
 Returns the HotSpot. More...
 

Static Public Member Functions

static SoSeparator * getDefaultWandGeometry ()
 Creates a default Wand geometry node. More...
 

Protected Types

Protected Member Functions

 Hx3DWandBase ()
 Constructor. More...
 
virtual ~Hx3DWandBase ()
 Destructor. More...
 

Static Protected Member Functions

static SoSeparator * createDefaultWand (bool highlight)
 Creates a default Wand based on a default geometry node. More...
 

Protected Attributes

SbVec3f m_hotSpot
 The hot spot of the wand. More...
 
float m_wandScale
 The scale factor of the wand. More...
 
McHandle< SoSwitch > m_highlightSwitch
 The node for switching between highlight ON/OFF. More...
 
float m_sceneLength
 The length in scene coordinates. More...
 
SbVec3f m_sceneTop
 The top in scene coordinates. More...
 
SbVec3f m_sceneOrigin
 The origin in scene coordinates. More...
 
SbRotation m_sceneOrientation
 The orientation in scene coordinates. More...
 
float m_vrLength
 The length in VR coordinates. More...
 
SbVec3f m_vrTop
 The top in VR coordinates. More...
 
SbVec3f m_vrOrigin
 The origin in VR coordinates. More...
 
SbRotation m_vrOrientation
 The orientation in VR coordinates. More...
 
const SbMatrix * m_sceneToVRTransform
 The scene to VR transform. More...
 
const SbMatrix * m_vrToSceneTransform
 The inverse of scene to VR transform. More...
 
int m_buttonStatus
 The buttons (all) combined status. More...
 
int m_lastButtonStatus
 The buttons (all) combined status sampled during last scene graph traversal. More...
 

Detailed Description

Base class representing a 3D wand in XScreen.

If you are writing an event callback which reacts on VR events in the application, i.e., on SoTrackerEvent or SoControllerButtonEvent, you can access the wand thanks to the GET_WAND(e) macro:

SoTrackerEvent* e = (SoTrackerEvent*) action->getEvent();
Hx3DWandBase* wand = GET_WAND(e);
or
SoControllerButtonEvent* e = (SoControllerButtonEvent*) action->getEvent();
Hx3DWandBase* wand = GET_WAND(e);

You can then ask the wand for its current position or orientation. You can also highlight it in order to give some visual feedback.

In addition, the class provides the two methods sceneXform() and sceneXformInverse(). You can use these methods to convert between the physical coordinates used in an XScreen configuration file and the scene coordinates, e.g., the coordinates a data set is defined in.

Member Enumeration Documentation

enum Hx3DWand::WandGeom
protected

Code for the two (highlighted and not) geometries.

Enumerator
DEFAULT_GEOM 

Default geometry.

HIGHTLIGHT_GEOM 

Highlight geometry.

Constructor & Destructor Documentation

virtual Hx3DWand::~Hx3DWandBase ( )
protectedvirtual

Destructor.

Member Function Documentation

static SoSeparator* Hx3DWand::createDefaultWand ( bool  highlight)
staticprotected

Creates a default Wand based on a default geometry node.

Parameters
highlighttrue for getting highlighted geometry
Returns
The node
bool Hx3DWand::getButton ( int  butIdx) const

Returns the current state of a button of the VR input device.

Parameters
butIdxThe button index
Returns
true for pressed, false for released
int Hx3DWand::getButtonStatus ( ) const
inline

Returns the current combined state of all buttons of the VR input device.

Returns
buttons status
static SoSeparator* Hx3DWand::getDefaultWandGeometry ( )
static

Creates a default Wand geometry node.

Returns
The node representing a wand
const SbVec3f& Hx3DWand::getHotSpot ( ) const
inline

Returns the HotSpot.

Returns
The HotSpot
float Hx3DWand::getWandScale ( ) const
inline

Returns the scale factor of the wand.

The scale factor can be defined in the XScreen configuration file. If it is not specified there, a default factor will be used which 0.16 times the length of the first screen in defined in the config file.

Returns
The scale factor of the wand.
Hx3DWand::Hx3DWandBase ( )
protected

Constructor.

float Hx3DWand::length ( bool  scene = true) const
inline

Returns the length of the wand.

If scene is true the length is reported in scene coordinates. Otherwise it is reported in VR coordinates. The length is the distance between the wand origin and the top of the wand.

const SbRotation& Hx3DWand::orientation ( bool  scene = true) const
inline

Returns the current orientation of the wand.

If scene is true the orientation is reported relative to the scene coordinate system. Otherwise it is reported relative to the VR coordinate system, i.e., the coordinate system used in the XScreen configuration file. This method can be used to pick and move an object with the wand. In order to do so you need to remember the current wand top position and the current orientation at the time the interaction starts, i.e., when a wand button is pressed:

refRotInverse = wand->orientation().inverse();
refPos = wand->origin();

Then, when the wand position and orientation changes you can compute a transformation matrix as follows:

SbMatrix T1; T1.setTranslate(-refPos);
SbMatrix R; R.setRotate(refRotInverse*wand->orientation());
SbMatrix T2; T2.setTranslate(wand->origin());
SbMatrix deltaXform = T1*R*T2;

For a concrete example see the module MyVRDemo in the XScreen demo package.

Parameters
scenetrue for scene orientation, false for VR orientation
Returns
The current orientation of the wand.
const SbVec3f& Hx3DWand::origin ( bool  scene = true) const
inline

Returns the origin of the 3D wand.

If scene is true the origin is reported in scene coordinates, i.e., the value depends on the current viewing transformation. Otherwise the origin is reported in VR coordinates, i.e., in the same coordinate system used in the XScreen configuration file.

Parameters
scenetrue for scene coordinates, false for VR coordinates
Returns
The origin
const SbMatrix& Hx3DWand::sceneXform ( ) const
inline

Returns the matrix which transforms between scene coordinates and VR coordinates, i.e., the coordinates used in the XScreen configuration file.

For example, in order to get the top position of the wand in this physical coordinate system use

SbVec3f topInDeviceCoords;
wand->sceneXform().multVecMatrix(wand->top(),topInDeviceCoords);
Returns
The transform matrix.
const SbMatrix& Hx3DWand::sceneXformInverse ( ) const
inline

Returns the inverse of sceneXform().

This matrix transforms from device coordinates as defined in the XScreen configuration file to scene coordinates.

Returns
The inverse of sceneXform().
void Hx3DWand::setGeometry ( SoNode *  wand,
const SbVec3f &  hotSpot 
)

Sets the inventor geometry used to display the wand in normal state, as well as the top of the wand.

The origin is assumed to be at (0,0,0). This can also be specified in a permanent way in the XScreen configuration file.

Parameters
wandThe node representing wand geometry (if NULL a default wand is created)
hotSpotThe hotspot of the wand
virtual void Hx3DWand::setHighlight ( bool  enable)
virtual

Highlights the wand.

Can be used in custom nodes to give some visual feedback. For example, if the top of the wand is inside some box this method could be called so that the user knows that he can move the box.

Parameters
enabletrue for enable, false for disable
void Hx3DWand::setHighlightGeometry ( SoNode *  wand)

Sets the inventor geometry used to display the wand in highlighted state.

This can also be specified in a permanent way in the XScreen configuration file.

Parameters
wandThe node representing wand geometry (if NULL a default wand is created)
void Hx3DWand::setWandScale ( float  scaleFactor)

Sets the scale factor applied to the wand geometry.

The wand geometry will be scaled by this factor. The factor allows you to adjust the size of the wand so that it matches the VR coordinates used in the current XScreen configuration file. For example, if your screen width is 200 (cm) and you are using a wand geometry with the hot spot at (0,0,-1), a wand scale factor of 100 makes the wand half as long as your screen

Parameters
scaleFactorThe scale factor
const SbVec3f& Hx3DWand::top ( bool  scene = true) const
inline

Returns the top of the 3D wand.

If scene is true the top is reported in scene coordinates, i.e., the value depends on the current viewing transformation. Otherwise the top is reported in VR coordinates, i.e., in the same coordinate system used in the XScreen configuration file.

Parameters
scenetrue for scene coordinates, false for VR coordinates
Returns
The top
virtual void Hx3DWand::update ( const SbVec3f &  pos,
const SbRotation &  rot,
int  butStat 
)
virtual

Updates the 3D wand position.

Parameters
posThe new position
rotThe new rotation
butStatThe new combined button status
bool Hx3DWand::wasButtonPressed ( int  butIdx) const

Returns true if the specified button was pressed since the.

scene graph was traversed the last time by the handle event action.

Parameters
butIdxThe button index
Returns
true for pressed
bool Hx3DWand::wasButtonReleased ( int  butIdx) const

Returns true if the specified button was released since the scene graph was traversed the last time by the handle event action.

Parameters
butIdxThe button index
Returns
true for released

Member Data Documentation

int Hx3DWand::m_buttonStatus
protected

The buttons (all) combined status.

McHandle<SoSwitch> Hx3DWand::m_highlightSwitch
protected

The node for switching between highlight ON/OFF.

SbVec3f Hx3DWand::m_hotSpot
protected

The hot spot of the wand.

int Hx3DWand::m_lastButtonStatus
protected

The buttons (all) combined status sampled during last scene graph traversal.

float Hx3DWand::m_sceneLength
protected

The length in scene coordinates.

SbRotation Hx3DWand::m_sceneOrientation
protected

The orientation in scene coordinates.

SbVec3f Hx3DWand::m_sceneOrigin
protected

The origin in scene coordinates.

SbVec3f Hx3DWand::m_sceneTop
protected

The top in scene coordinates.

const SbMatrix* Hx3DWand::m_sceneToVRTransform
protected

The scene to VR transform.

float Hx3DWand::m_vrLength
protected

The length in VR coordinates.

SbRotation Hx3DWand::m_vrOrientation
protected

The orientation in VR coordinates.

SbVec3f Hx3DWand::m_vrOrigin
protected

The origin in VR coordinates.

SbVec3f Hx3DWand::m_vrTop
protected

The top in VR coordinates.

const SbMatrix* Hx3DWand::m_vrToSceneTransform
protected

The inverse of scene to VR transform.

float Hx3DWand::m_wandScale
protected

The scale factor of the wand.


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