Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

NurbsBall Class Reference

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

#include <NurbsBall.h>

Inheritance diagram for NurbsBall:

Subject List of all members.

Public Member Functions

 NurbsBall ()
 Default constructor creates nodes with default values.
 NurbsBall (SculptNurbs *sn, int)
virtual ~NurbsBall ()
 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 updatePoint (int index, SbVec3f trans)
void setRadius (const float &)
 Sets the radius of the sphere.
void setIndexVal (int i)
void setTransform (const SbMatrix &)
 Sets the transform for the object.
void setTransparency (const float &)
 Sets the transparency for the ball.

Static Public Member Functions

static void EventCB (gstTransform *, void *, void *)
 GHOST event callback is called when the shape is touched.
static void GraphicCB (gstTransform *, void *, void *)
 GHOST graphic callback copies transform to Inventor graphics nodes.

Public Attributes

int indexval

Protected Attributes

Inventor scene nodes
SculptNurbs * parent
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 NURBS ball implemented with Inventor and GHOST.

Author:
Vaidya Chandrasekhar
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 matsculptes applied to the spheres must be kept the same as well.


Constructor & Destructor Documentation

NurbsBall::NurbsBall  ) 
 

Default constructor creates nodes with default values.

NurbsBall::NurbsBall SculptNurbs *  sn,
int  index
 

The constructor must allocate memory for all internal scene graph nodes used by an NurbsBall 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.

NurbsBall::~NurbsBall  )  [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 NurbsBall::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 NurbsBall object is used so observers are notified

gstSeparator * NurbsBall::getGHOSTNode  ) 
 

Returns the GHOST separator containing the touchable sphere.

SoTransformSeparator * NurbsBall::getOIVNode  ) 
 

Returns the Open Inventor separator containing the sphere.

void NurbsBall::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 NurbsBall::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 NurbsBall::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 NurbsBall::setIndexVal int  i  ) 
 

void NurbsBall::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 NurbsBall::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 NurbsBall::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

void NurbsBall::updatePoint int  index,
SbVec3f  trans
 


Member Data Documentation

gstSeparator* NurbsBall::hapticSeparator [protected]
 

GHOST separator containing the ball.

gstSphere* NurbsBall::hapticSphere [protected]
 

GHOST sphere geometry node.

int NurbsBall::indexval
 

SoMaterial* NurbsBall::material [protected]
 

Material node for the ball's appearance.

SculptNurbs* NurbsBall::parent [protected]
 

SoTransformSeparator* NurbsBall::separator [protected]
 

Separator under which the ball is placed.

SoSphere* NurbsBall::sphere [protected]
 

Sphere node representing the ball itself.

SoMatrixTransform* NurbsBall::transform [protected]
 

Current transform for the ball.


The documentation for this class was generated from the following files:
Generated on Wed May 18 01:24:59 2005 for SculptDemo by  doxygen 1.4.3