SPIN Framework
|
A node with constrained motion. More...
#include <ConstraintsNode.h>
Public Types | |
enum | ConstraintMode { BASIC, DROP, COLLIDE, BOUNCE, STICK, COLLIDE_THRU } |
enum | CollisionMode { POINT, BOUNDING_SPHERE, MESH } |
Public Member Functions | |
ConstraintsNode (SceneManager *sceneManager, const char *initID) | |
virtual void | callbackUpdate (osg::NodeVisitor *nv) |
void | setTarget (const char *id) |
const char * | getTarget () const |
void | setConstraintMode (ConstraintMode m) |
int | getConstraintMode () const |
void | setCubeSize (float xScale, float yScale, float zScale) |
void | setCubeOffset (float x, float y, float z) |
osg::Vec3 | getCubeSize () const |
osg::Vec3 | getCubeOffset () const |
virtual void | setTranslation (float x, float y, float z) |
virtual void | translate (float x, float y, float z) |
virtual void | move (float x, float y, float z) |
void | applyConstrainedTranslation (osg::Vec3 v) |
virtual std::vector< lo_message > | getState () const |
A node with constrained motion.
This node operates much like GroupNode, allowing children to be attached, but motion is constrained in a certain way.
Foremost, there is one BASIC form of constraint where motion of the node is bound within a cubic volume.
Additionally, there are several ConstraintModes, where properties of a target node are used to limit movement of this node. For example, the node will only move along the surface of the target, or bounce off.
One needs to specify the target node for some of these special modes to work.
Enumerator containing all of the constraint modes available
void spin::ConstraintsNode::applyConstrainedTranslation | ( | osg::Vec3 | v | ) |
A pseudo-recursive function that checks if a translation results in one or more intersections with the target node. If no intersection, this method defaults to just a setTranslation call. Otherwise, it will do a setTranslation for the collision point, and call itself again until there are no collisions left.
void spin::ConstraintsNode::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::GroupNode.
Reimplemented in spin::UserNode.
int spin::ConstraintsNode::getConstraintMode | ( | ) | const [inline] |
osg::Vec3 spin::ConstraintsNode::getCubeOffset | ( | ) | const [inline] |
osg::Vec3 spin::ConstraintsNode::getCubeSize | ( | ) | const [inline] |
std::vector< lo_message > spin::ConstraintsNode::getState | ( | ) | const [virtual] |
For each subclass of ReferencedNode, we override the getState() method to fill the vector with the correct set of methods for this particular node
Reimplemented from spin::GroupNode.
Reimplemented in spin::UserNode.
const char* spin::ConstraintsNode::getTarget | ( | ) | const [inline] |
void spin::ConstraintsNode::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 from spin::GroupNode.
void spin::ConstraintsNode::setConstraintMode | ( | ConstraintMode | m | ) |
Sets the node's constraint mode, based on the types in constrainMode enum (see enum for details)
void spin::ConstraintsNode::setCubeOffset | ( | float | x, |
float | y, | ||
float | z | ||
) |
Sets the center of the BASIC constraint cube with respect to the local coordinate system (either the parent object or the world grid).
void spin::ConstraintsNode::setCubeSize | ( | float | xScale, |
float | yScale, | ||
float | zScale | ||
) |
Sets the size of the imaginary cube beyond which the constrained node cannot pass, when constraint type BASIC is set.
void spin::ConstraintsNode::setTarget | ( | const char * | id | ) |
Sets a target whose properties can be used to limit movement of this node, depending on the type on constraint selected. (this should be a model node or shape node, or a group node ideally not too complex, because large amounts of triangles will lead to excessive calculations)
void spin::ConstraintsNode::setTranslation | ( | float | x, |
float | y, | ||
float | z | ||
) | [virtual] |
The local translation offset for this node with respect to it's parent
Reimplemented from spin::GroupNode.
void spin::ConstraintsNode::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 from spin::GroupNode.