Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

RICDemoApp Class Reference

Application implementing demonstration of capabilities. More...

Inheritance diagram for RICDemoApp:

Inheritance graph
[legend]
Collaboration diagram for RICDemoApp:

Collaboration graph
[legend]
List of all members.

Public Methods

 RICDemoApp (int, char **)
 Constructor takes parameters from the command line.

virtual ~RICDemoApp ()
 Destuctor cleans up memory.

SbBox3f getWorkspaceSize ()
 Get the PHANToM's physical workspace size.

void setPhantomOffset (const SbVec3f &)
 Set the PHANToM offset from the CAVE origin.

virtual void update (Subject *)
 Observer update method is triggered when notified by Subjects.

CAVE-related template method callbacks
virtual void buildScene ()
 Builds the Inventor and GHOST scene graphs.

virtual void frameUpdate ()
 Once-per-frame update will trigger GHOST notification.

virtual void update ()
 Update method called from main will check the stylus button.


Static Public Methods

void PointerGraphicCB (gstTransform *, void *, void *)
 Callback copies the PHANToM transform to the pointer graphics.


Protected Attributes

bool m_canTranslate
 Whether or not use of the translation manipulator is enabled.

int m_stylusButtonOn
 Current status of the PHANToM stylus button.

Inventor scene graph elements
SoSeparator * m_ghostSep
 Separator under which the haptic scene is contained.

SoTransform * m_phantomOffset
 Transform of the PHANToM device offset from the CAVE origin.

SoTransform * m_phantomTransform
 Transform representing the PHANToM.

GHOST scene graph elements
gstScene * m_hapScene
 GHOST scene graph.

gstSeparator * m_hapRoot
 GHOST scene graph root node.

gstPHANToM * m_phantom
 GHOST PHANToM device instance.

gstPHANToM_SCP * m_phantomSCP
 PHANToM surface contact point.

gstTranslateManipulator * m_translateManip
 GHOST dynamic translation manipulator.

SbBox3f m_workspaceSize
 Box storing the available PHANToM workspace size.


Detailed Description

Application implementing demonstration of capabilities.

Author:
Chris Scharver
Using the capabilities of OIVAppShell with subclasses makes the management of code significantly easier. The interaction between Inventor and the CAVELib have been localized to the parent class, so that's less code to duplicate when working on several different applications. As a subclass, RICDemoApp must construct its scene within RICDemoApp::buildScene() and also add extra capabilities for the GHOST scene graph.


Constructor & Destructor Documentation

RICDemoApp::RICDemoApp int    argc,
char **    argv
 

Constructor takes parameters from the command line.

The application constructor initializes several nodes and other variables. The PHANToM instance is initialized here and checked to make sure that a valid construction took place. The initial elements of the GHOST scene graph are created here. Once the PHANToM has been initialized, it is queried to determine the workspace size, and that size is stored for use when constructing the Inventor scene.

Parameters:
argc  - number of arguments passed from the command line
argv  - strings passed from the command line

RICDemoApp::~RICDemoApp   [virtual]
 

Destuctor cleans up memory.

When the application has finished running, it's important to stop the haptic servo loop. The destructor also dumps the Inventor scene graph to a file for debugging purposes. This makes it easy to check the construction of the scene graph.


Member Function Documentation

void RICDemoApp::buildScene   [virtual]
 

Builds the Inventor and GHOST scene graphs.

The base OIVAppShell implementation does not create any scene graph nodes to place into the scene. The Inventor graphics are constructed first. A PointLight provides illumination. A Separator is used to localize all haptic elements under a single sub-tree of the scene graph. The details of the scene graph are described in the source code.

Reimplemented from OIVAppShell.

void RICDemoApp::frameUpdate   [virtual]
 

Once-per-frame update will trigger GHOST notification.

The frame update is triggered once per trip through the frame loop. The GHOST scene must be updated manually, so this method calls gstScene::updateEvents() and gstScene::updateGraphics(). Those methods will in turn trigger any event and graphic callbacks assigned to nodes in the GHOST scene graph.

Reimplemented from OIVAppShell.

SbBox3f RICDemoApp::getWorkspaceSize  
 

Get the PHANToM's physical workspace size.

void RICDemoApp::PointerGraphicCB gstTransform *    nodePtr,
void *    callbackData,
void *    userData
[static]
 

Callback copies the PHANToM transform to the pointer graphics.

Each time the GHOST graphics update is called, this function will copy the PHANToM transform to a passed node.

Parameters:
nodePtr  - GHOST shape
callbackData  - gstDynamicGraphicsCBData
userData  - pointer to the RICDemoApp instance.

void RICDemoApp::setPhantomOffset const SbVec3f &    offset
 

Set the PHANToM offset from the CAVE origin.

The origin of the PHANToM work area must be measured from the origin of the CAVELib. This offset is the magic element which makes the haptics appear aligned with the rendering. If this offset is significantly displaced, the misalignment will be clearly evident to the user. This example code merely demonstrates how this offset must be placed into the scene graph. A more robust implementation should provide an interactive method for measuring and adjusting this offset.

Parameters:
offset  - distance (mm) from CAVE origin to PHANToM origin

void RICDemoApp::update Subject   subj [virtual]
 

Observer update method is triggered when notified by Subjects.

The Observer Pattern provides a very easy way to update one object as a result of notification sent by another. The Observer is attached to a Subject object. At some point during execution, Subject::notify() will trigger this method. This state of the subject must be pulled by performing a cast and checking for the appropriate information. In this case, the check must determine whether or not the Subject is being touched by the PHANToM. The purpose is to set the m_canTranslate flag as appropriate.

Parameters:
subj  - observed subject which has sent notification

Implements Observer.

void RICDemoApp::update   [virtual]
 

Update method called from main will check the stylus button.

Called once per cycle of the main loop, this update function handles checking the PHANToM stylus to manage the use of the translation manipulator. It controls the logic for starting and stopping the manipulator.


Member Data Documentation

bool RICDemoApp::m_canTranslate [protected]
 

Whether or not use of the translation manipulator is enabled.

SoSeparator* RICDemoApp::m_ghostSep [protected]
 

Separator under which the haptic scene is contained.

gstSeparator* RICDemoApp::m_hapRoot [protected]
 

GHOST scene graph root node.

gstScene* RICDemoApp::m_hapScene [protected]
 

GHOST scene graph.

gstPHANToM* RICDemoApp::m_phantom [protected]
 

GHOST PHANToM device instance.

SoTransform* RICDemoApp::m_phantomOffset [protected]
 

Transform of the PHANToM device offset from the CAVE origin.

gstPHANToM_SCP* RICDemoApp::m_phantomSCP [protected]
 

PHANToM surface contact point.

SoTransform* RICDemoApp::m_phantomTransform [protected]
 

Transform representing the PHANToM.

int RICDemoApp::m_stylusButtonOn [protected]
 

Current status of the PHANToM stylus button.

gstTranslateManipulator* RICDemoApp::m_translateManip [protected]
 

GHOST dynamic translation manipulator.

SbBox3f RICDemoApp::m_workspaceSize [protected]
 

Box storing the available PHANToM workspace size.


The documentation for this class was generated from the following files:
Generated on Thu Jun 12 10:13:14 2003 for RICDemo by doxygen1.2.18