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

RICBall Class Reference

Touchable ball implemented with Inventor and GHOST. More...

Inheritance diagram for RICBall:

Inheritance graph
[legend]
Collaboration diagram for RICBall:

Collaboration graph
[legend]
List of all members.

Public Methods

 RICBall ()
 Default constructor creates nodes with default values.

virtual ~RICBall ()
 Destructor dereferences all nodes.

SoTransformSeparator * getOIVNode ()
 Returns the Open Inventor separator containing the sphere.

gstSeparator * getGHOSTNode ()
 Returns the GHOST separator containing the touchable sphere.

int isTouched ()
 Returns whether or not the ball is being touched by the PHANToM.

void setDiffuseColor (const SbVec3f &)
 Sets the color of the sphere.

void setRadius (const float &)
 Sets the radius of the sphere.

void setTransform (const SbMatrix &)
 Sets the transform for the object.

void setTransparency (const float &)
 Sets the transparency for the ball.


Static Public Methods

void EventCB (gstTransform *, void *, void *)
 GHOST event callback is called when the shape is touched.

void GraphicCB (gstTransform *, void *, void *)
 GHOST graphic callback copies transform to Inventor graphics nodes.


Protected Attributes

Inventor scene nodes
SoMaterial * material
 Material node for the ball's appearance.

SoTransformSeparator * separator
 Separator under which the ball is placed.

SoSphere * sphere
 Sphere node representing the ball itself.

SoMatrixTransform * transform
 Current transform for the ball.

GHOST API scene nodes
gstSeparator * hapticSeparator
 GHOST separator containing the ball.

gstSphere * hapticSphere
 GHOST sphere geometry node.


Detailed Description

Touchable ball implemented with Inventor and GHOST.

Author:
Chris Scharver
Serving as a bridge between the Inventor scene graph nodes and the nodes specifically represented within the GHOST API, this class represents a ball with an assigned transform matrix. As changes are made in one scene graph, those changes must be duplicated in the other. For a simple object like a sphere, these modifications are small in number. The radius of the spheres must be kept identical, and the transformation matrices applied to the spheres must be kept the same as well.


Constructor & Destructor Documentation

RICBall::RICBall  
 

Default constructor creates nodes with default values.

The constructor must allocate memory for all internal scene graph nodes used by an RICBall instance. It creates the Inventor material, separator, sphere, and transform nodes and calls ref() on each of them. The GHOST hapticSeparator and hapticSphere nodes are created here as well. The separators for each scene graph are assembled with all required children.

RICBall::~RICBall   [virtual]
 

Destructor dereferences all nodes.

The important thing to keep in mind for any destructor is that Inventor uses a references counting scheme to manage when nodes should be cleaned up. GHOST does not have this automatic management scheme, but when delete is called on a gstScene, all nodes in that scene should be properly destroyed (this according to the support people at SensAble).


Member Function Documentation

void RICBall::EventCB gstTransform *    nodePtr,
void *    callbackData,
void *    userData
[static]
 

GHOST event callback is called when the shape is touched.

The event callback is triggered to signal when the ball object has been touched. Touching objects triggers a gstEvent with information specific to the gstShape which was touched. This callback is called when the gstScene::updateEvents() is called.

Parameters:
nodePtr  - GHOST node which triggered the callback
callbackData  - gstEvent passed to the callback contains event information specific to the type of GHOST node which triggered the callback
userData  - pointer to the RICBall object is used so observers are notified

gstSeparator * RICBall::getGHOSTNode  
 

Returns the GHOST separator containing the touchable sphere.

SoTransformSeparator * RICBall::getOIVNode  
 

Returns the Open Inventor separator containing the sphere.

void RICBall::GraphicCB gstTransform *    nodePtr,
void *    callbackData,
void *    userData
[static]
 

GHOST graphic callback copies transform to Inventor graphics nodes.

The graphics callback is triggered to manually copy a GHOST transformation matrix into an Inventor matrix. The Inventor node should be passed as an argument. The callback simply gets the current GHOST matrix and copied it into an Inventor SbMatrix structure. That new matrix is applied to the passed SoTransform node.

Parameters:
nodePtr  - GHOST node containing the transform to copy
callbackData  - gstDynamicGraphicsCBData contains node-specific information related to the particular node which has triggered the callback.
userData  - SoTransform to which the matrix will be copied

int RICBall::isTouched  
 

Returns whether or not the ball is being touched by the PHANToM.

Because the Observer Pattern is used to send notifications when the ball is touched by the PHANToM, this method is used for querying the state of the ball within the context of that notification. The query is to determine whether or not the ball is being touched. The result is determined by using gstShape::isInContact().

Returns:
1 if touched, 0 otherwise

void RICBall::setDiffuseColor const SbVec3f &    rgb
 

Sets the color of the sphere.

The current lighting model uses the standard Inventor Material node. Different colors may be specified for diffuse, ambient, and specular lightning. This method sets only the ball's material's diffuse color.

Parameters:
rgb  - Color (red, green, blue) stored in a vector.

void RICBall::setRadius const float &    radius
 

Sets the radius of the sphere.

It is important to make sure that the objects have identical representations in both scene graphs. This method will set the radius values for both the Inventor and GHOST spheres.

Parameters:
radius  - Radius of the sphere.

void RICBall::setTransform const SbMatrix &    matrix
 

Sets the transform for the object.

Just as the sphere radius must be consistent across the scene graphs, so must the transformation matrix. Because the representation for Inventor's matrix class is easier to work with, it is used as the base type. This method will internally convert it to a gstTransformMatrix for application within the GHOST scene graph.

Parameters:
matrix  - transform matrix to apply

void RICBall::setTransparency const float &    alpha
 

Sets the transparency for the ball.

One component of an Inventor material node is the transparency. This method will set the transparency value for the balls' Material node.

Parameters:
alpha  - tranparency value 0.0-1.0


Member Data Documentation

gstSeparator* RICBall::hapticSeparator [protected]
 

GHOST separator containing the ball.

gstSphere* RICBall::hapticSphere [protected]
 

GHOST sphere geometry node.

SoMaterial* RICBall::material [protected]
 

Material node for the ball's appearance.

SoTransformSeparator* RICBall::separator [protected]
 

Separator under which the ball is placed.

SoSphere* RICBall::sphere [protected]
 

Sphere node representing the ball itself.

SoMatrixTransform* RICBall::transform [protected]
 

Current transform for the ball.


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