SPIN Framework
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

spin::GroupNode Class Reference

A basic node to manage translation/orientation/scale of a subgraph. Allows for grouping of nodes. More...

#include <GroupNode.h>

Inheritance diagram for spin::GroupNode:
spin::ReferencedNode spin::AnimationNode spin::AttractorNode spin::ConstraintsNode spin::DSPNode spin::GeometryNode spin::KinectCloud spin::LightSource spin::Menu3D spin::ModelNode spin::ParticleSystem spin::RayNode spin::ReporterNode spin::ShapeNode spin::SwitchNode spin::TextNode

List of all members.

Public Types

enum  InteractionMode {
  STATIC, PASSTHRU, SELECT, DRAG,
  THROW, DRAW
}
enum  globalsReportMode { NONE, GLOBAL_6DOF, GLOBAL_ALL }
enum  velocityMode { TRANSLATE, MOVE }
enum  ComputationMode { SERVER_SIDE, CLIENT_SIDE }
enum  OrientationMode { NORMAL, POINT_TO_TARGET, POINT_TO_TARGET_CENTROID, POINT_TO_ORIGIN }

Public Member Functions

 GroupNode (SceneManager *sceneManager, const char *initID)
virtual void callbackUpdate (osg::NodeVisitor *nv)
virtual void updateNodePath (bool updateChildren=true)
void mouseEvent (int event, int keyMask, int buttonMask, float x, float y)
void event (int event, const char *userString, float eData1, float eData2, float x, float y, float z)
void setLock (const char *userString, int lock)
virtual void debug ()
void setStateSetFromFile (const char *filename)
void setStateSet (const char *s)
t_symbolgetStateSetSymbol () const
virtual void updateStateSet ()
void setReportMode (globalsReportMode mode)
void setInteractionMode (InteractionMode mode)
void setComputationMode (ComputationMode mode)
int getComputationMode () const
void setClipping (float x, float y, float z)
virtual void setTranslation (float x, float y, float z)
void setOrientationMode (OrientationMode m)
int getOrientationMode () const
void setOrientationTarget (const char *target)
char * getOrientationTarget () const
virtual void setOrientation (float pitch, float roll, float yaw)
virtual void setOrientationQuat (float x, float y, float z, float w)
virtual void setScale (float x, float y, float z)
virtual void setVelocity (float dx, float dy, float dz)
virtual void setVelocityMode (velocityMode mode)
virtual void setSpin (float dp, float dr, float dy)
virtual void setDamping (float d)
virtual void translate (float x, float y, float z)
virtual void move (float x, float y, float z)
virtual void rotate (float dPitch, float dRoll, float dYaw)
virtual void addRotation (float dPitch, float dRoll, float dYaw)
virtual void translateTo (float x, float y, float z, float time, const char *motion="Linear")
virtual void setManipulator (const char *manipulatorType)
const char * getManipulator () const
virtual void setManipulatorMatrix (float a00, float a01, float a02, float a03, float a10, float a11, float a12, float a13, float a20, float a21, float a22, float a23, float a30, float a31, float a32, float a33)
void setBroadcastLock (bool lock)
int getReportMode () const
int getInteractionMode () const
osg::Vec3 getClipping () const
osg::Vec3 getOrientation () const
osg::Vec3 getTranslation () const
osg::Quat getOrientationQuat () const
osg::Vec3 getScale () const
osg::Vec3 getVelocity () const
int getVelocityMode () const
float getDamping () const
osg::Matrix getGlobalMatrix ()
osg::Vec3 getCenter () const
bool dumpGlobals (bool forced)
virtual std::vector< lo_message > getState () const
virtual void stateDump ()
osg::MatrixTransform * getTransform ()
void updateDraggerMatrix ()

Protected Member Functions

void updateQuat ()
void updateMatrix ()
void drawManipulator ()
void applyOrientationMode ()

Protected Attributes

osg::ref_ptr< UserNodeowner_
t_symbolstateset_
osg::ref_ptr
< osg::MatrixTransform > 
mainTransform_
osg::ref_ptr
< osgManipulator::Dragger > 
dragger_
osg::ref_ptr
< osgAnimation::Motion > 
motion_
osg::Vec3 motionStart_
osg::Vec3 motionEnd_
InteractionMode interactionMode_
std::vector< osg::Vec4 > trajectory_
int drawMod_
osg::ref_ptr< osg::ClipNode > clipNode_
osg::Vec3 clipping_
globalsReportMode reportMode_
osg::Matrix globalMatrix_
osg::Vec3 _globalScale
float globalRadius_
ComputationMode computationMode_
enum OrientationMode orientationMode_
t_symbolorientationTarget_
osg::Vec3 orientation_
osg::Vec3 translation_
osg::Vec3 scale_
osg::Quat quat_
osg::Vec3 velocity_
velocityMode velocityMode_
osg::Vec3 spin_
float damping_
std::string manipulatorType_
bool manipulatorUpdateFlag_
bool manipulatorShadowCopy_
bool broadcastLock_

Detailed Description

A basic node to manage translation/orientation/scale of a subgraph. Allows for grouping of nodes.

Most nodes in the scene do not have a method to offset their position in the scene. This node provides a mechanism to group and offset nodes.


Member Enumeration Documentation

Enumerator:
STATIC 

Mouse clicks and PointerNode have no effect on this node.

PASSTHRU 

This passes the interaction event to the parent node, which is useful when we need a node with geometry to be selected, but want to move the parent group instead. NOTE: ONLY IMPLEMENTED FOR PointerNode; NOT DONE YET FOR MOUSE!

SELECT 

This node responds to selection events (eg, can display manipulator handles when selected).

DRAG 

This node responds to grag events, either invoked by mouse drags in ViewerManipulator or PointerNode.

THROW 

The same as DRAG mode, but a direction vector is accumulated over the last few drags and a velocity is assigned to the node when released.

DRAW 

Provides access to the x,y,z intersection points as the user draws over the surface of a node


Constructor & Destructor Documentation

spin::GroupNode::GroupNode ( SceneManager sceneManager,
const char *  initID 
)

The constructor takes a string id that will be converted to a t_symbol, which contains a pointer to this object. Thus functions will be able to acquire the pointer using gensym(), which uses a hash table lookup.

Parameters:
initIDwill be converted into a t_symbol

Member Function Documentation

void spin::GroupNode::addRotation ( float  dPitch,
float  dRoll,
float  dYaw 
) [virtual]

The addRotation command adds a (relative) rotation to the node's current orientation.

void spin::GroupNode::callbackUpdate ( osg::NodeVisitor *  nv) [virtual]

For nodes that require regular programmatic control, there is a callback that is evaluated with every refresh. This function can thus be used for animations, or any other periodic updates.

Note that changes to the scene graph structure (eg, moving/deleting nodes should NOT be done within this callback because traversals stacks will become corrupted. The technique is rather to enable a flag and then do the actual change in the SceneManager::updateGraph() method.

Reimplemented from spin::ReferencedNode.

Reimplemented in spin::AnimationNode, spin::AttractorNode, spin::CollisionShape, spin::ConstraintsNode, spin::DSPNode, spin::GeometryNode, spin::KinectCloud, spin::Listener, spin::ParticleSystem, spin::PointerNode, spin::ReporterNode, spin::SoundNode, spin::TextNode, and spin::UserNode.

void spin::GroupNode::debug ( ) [virtual]

Print debug information about the node to standard out (when running in console mode). It may be possible to redirect this to a text box for GUI logs.

Reimplemented from spin::ReferencedNode.

Reimplemented in spin::CollisionShape, and spin::ReporterNode.

bool spin::GroupNode::dumpGlobals ( bool  forced)

The dumpGlobals method results in a broadcast of this node's translation and orientation. It is called by callbackUpdate() every frame, however the 'forced' flag will be set to false, so it will only send a message if the node's matrix has changed. If the 'forced' flag is set to true, it will definitely result in a message broadcast. This should only be used when necessary (eg, when a stateDump is requested).

Note: the return value is only to fool wx so that it doesn't consider this as an editable property.

std::vector< lo_message > spin::GroupNode::getState ( ) const [virtual]
void spin::GroupNode::move ( float  x,
float  y,
float  z 
) [virtual]

The move command adds a relative translation with respect to the node's current orientation. That is, the node will translate along it's direction vector by the supplied number of units.

Reimplemented in spin::ConstraintsNode.

void spin::GroupNode::rotate ( float  dPitch,
float  dRoll,
float  dYaw 
) [virtual]

The rotate command adds to the (absolute) orientation of the node

void spin::GroupNode::setClipping ( float  x,
float  y,
float  z 
)

Set a clipping rectangle for the model so that geometry outside of the region (+-x, +-y, +-z) will not be shown (or used in interactive events)

void spin::GroupNode::setDamping ( float  d) [virtual]

A Damping value (negative acceleration) that gets applied to velocity and spin over time. Units are in -m/sec2 or -deg/sec2, meaning that:

  • zero damping will not change velocity/spin values
  • any positive value will decrease the speeds
void spin::GroupNode::setOrientation ( float  pitch,
float  roll,
float  yaw 
) [virtual]

The local orientation offset for this node with respect to it's parent

Reimplemented in spin::AnimationNode, spin::CollisionShape, and spin::SoundNode.

void spin::GroupNode::setOrientationMode ( OrientationMode  m)

Set the OrientationMode of the node, which will be applied after every transformation.

void spin::GroupNode::setOrientationQuat ( float  x,
float  y,
float  z,
float  w 
) [virtual]

Set the orientation offset as a quaternion

Reimplemented in spin::CollisionShape, and spin::SoundNode.

void spin::GroupNode::setScale ( float  x,
float  y,
float  z 
) [virtual]

A grouped scale operation

Reimplemented in spin::AnimationNode, and spin::CollisionShape.

void spin::GroupNode::setSpin ( float  dp,
float  dr,
float  dy 
) [virtual]

A rotational velocity (deg/sec), computed in callbackUpdate().

void spin::GroupNode::setStateSet ( const char *  s)

Assign an existing stateset to this node

Reimplemented from spin::ReferencedNode.

void spin::GroupNode::setStateSetFromFile ( const char *  filename)

setStateSetFromFile guesses the type of stateset from the filename extension, creates a new stateset of that type and assigns it to this node

Reimplemented from spin::ReferencedNode.

void spin::GroupNode::setTranslation ( float  x,
float  y,
float  z 
) [virtual]

The local translation offset for this node with respect to it's parent

Reimplemented in spin::AnimationNode, spin::CollisionShape, spin::ConstraintsNode, and spin::SoundNode.

void spin::GroupNode::setVelocity ( float  dx,
float  dy,
float  dz 
) [virtual]

A translational velocity (m/s). This is computed in the callbackUpdate() function.

void spin::GroupNode::setVelocityMode ( velocityMode  mode) [virtual]

Applying velocity to an object can either result in translational motion, where velocityMode is TRANSLATE (0). This is the default and applies and motion is relative to the local coordinate system of the node. When velocityMode is MOVE (1), then motion is relative to the current orientation of the node, analogous to the move() command.

void spin::GroupNode::stateDump ( ) [virtual]

We override stateDump so that we can additionally force a dumpGlobals() call whenever a dump is requested

Reimplemented from spin::ReferencedNode.

void spin::GroupNode::translate ( float  x,
float  y,
float  z 
) [virtual]

The translate command increments the node's current translation values (ie, it's position in the scene with respect to it's parent)

Reimplemented in spin::ConstraintsNode.

void spin::GroupNode::translateTo ( float  x,
float  y,
float  z,
float  time,
const char *  motion = "Linear" 
) [virtual]

Instead of instantaneous setTranslation, this method uses an ease motion to animate the node to the target position.

void spin::GroupNode::updateNodePath ( bool  updateChildren = true) [virtual]

IMPORTANT: subclasses of ReferencedNode are allowed to contain complicated subgraphs and can also change their attachmentNode so that children are attached anywhere in that subgraph. If that is the case, the updateNodePath() function MUST be overridden, and extra nodes must be manually pushed onto currentNodePath_.

Reimplemented from spin::ReferencedNode.

Reimplemented in spin::ModelNode, and spin::UserNode.

void spin::GroupNode::updateStateSet ( ) [virtual]

This method actually applies the stateset to the subgraph, replacing any existing stateset with this one. The setStateSet and setStateSetFromFile methods just set the stateset_ symbol, while updateStateSet does the actual work.

Override this method in subclasses in order to change how stateset should be applied. For example, to which node in the subgraph it should be attached, or whether it should be merged with the existing stateset (rather than merged).

By default it is applied to the mainTransform_.

Reimplemented from spin::ReferencedNode.

Reimplemented in spin::GeometryNode, spin::ModelNode, and spin::ShapeNode.


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