Main Page   Class Hierarchy   Compound List   File List   Compound Members  

Bone Class Reference

The Bone class is a node in the skeleton tree. More...

#include <Bone.h>

List of all members.

Public Methods

 Bone ()
 Default constructor creates a Bone with an empty string name, and with all identity matrices.

 Bone (const std::string &name, const Matrix &refMat, const Matrix &offMat)
 Constructs a new Bone instance, with the given parameters.

 ~Bone ()
 Destructor.

void setName (std::string &name)
 Sets the name for this Bone, should be done before this Bone is used.

void setReferenceMatrix (const Matrix &m)
 Sets the reference Matrix, should be done before this Bone is used.

void setOffsetMatrix (const Matrix &m)
 Sets the offset Matrix, should be done before this Bone is used.

const std::string & getName () const
 Returns the name of this Bone.

void loadBoneNameSet (BoneNameSet &boneSet, bool incParent, bool incChildren) const
 Loads the passed boneSet with the name of this bone, plus the name of its parent and the names of all of its children.

Bone * findBone (const std::string &boneName)
 Finds the specified Bone in this Bone hierarchy.

void setTransform (const Matrix &newMat)
 Sets the current transformed matrix to the passed matrix.

void applyNewTransform (const Matrix &newMat)
 Sets the current transformed matrix to the passed matrix times the reference matrix.

void updateHierarchy (const Matrix &worldMat)
 Updates this Bone's final matrix.

const Matrix & getFinalMatrix () const
 Returns the Bone's final matrix.

const Matrix & getReferenceMatrix () const
 Returns the Bone's reference matrix.

void loadSkinMatrix (Matrix &m) const
 Loads the passed Matrix with the final matrix times the offset matrix, for used in skinning operations.

Bone * getParent ()
 Returns the parent to this Bone.

BoneListIter beginChildren ()
 Gives an iterator to the start of the list of children.

BoneListIter endChildren ()
 Gives an iterator to one past the end of the list of children, similar to the "end" method of an STL container.

void addChild (Bone *newChild)
 Adds the given child to this Bone's list of children.

void debugRender (StaticModel &m)
 Provides a debug rendering by rendering this Bone and its children using each Bone's matrix.

void printHierarchy (std::ostream &o, int level=0)
 Prints an indented bone hierarchy to the ostream.


Detailed Description

The Bone class is a node in the skeleton tree.

An alternate name for the Bone class could be Joint, as these terms are interchangeable as defined in this project. The tree formed by the Bone objects is a n-size tree. Each Bone has 0 or more children, and a parent. These links can be traversed publically. Bones act as containers for the transformation data, but do no other significant work. Each Bone has 4 matrices: a Bone offset matrix, a "reference pose" for the bone, the current transform matrix, and the final combined matrix.


Constructor & Destructor Documentation

Bone::Bone  
 

Default constructor creates a Bone with an empty string name, and with all identity matrices.

If you use the default constructor, you should call the setName, setReferenceMatrix, and setOffsetMatrix methods before doing any animations/calculations on the Bone.

Bone::Bone const std::string &    name,
const Matrix &    refMat,
const Matrix &    offMat
 

Constructs a new Bone instance, with the given parameters.

If this Bone is to have children, they need to be added after construction through the addChild method.

The initial current matrix is built from the reference and offset matricies.

Bone::~Bone  
 

Destructor.

All children of this Bone will be deleted.


Member Function Documentation

void Bone::addChild Bone *    newChild
 

Adds the given child to this Bone's list of children.

This passed in data is not copied, so the child Bone must stick around while this Bone exists. The responsibility for the child's memory rests with its parent, so when the parent is destroyed, it will call delete on its children.

The parent of the passed Bone will become this Bone. Because of how the memory allocation works, the passed Bone cannot have a parent, because then the bone will have 2 parents, leading to double deletes.

Precondition:
newChild cannot have a parent
Postcondition:
newChild's parent becomes this Bone, and newChild is a child of this Bone.

BoneListIter Bone::beginChildren  
 

Gives an iterator to the start of the list of children.

This is an STL-compliant iterator.

If a Bone is added to this Bone's children, any iterators from beginChildren or endChildren become invalid.

void Bone::debugRender StaticModel   m
 

Provides a debug rendering by rendering this Bone and its children using each Bone's matrix.

It is suggested that the model is oriented around the origin so that the model is drawn about the transformed origin of all the Bones.

BoneListIter Bone::endChildren  
 

Gives an iterator to one past the end of the list of children, similar to the "end" method of an STL container.

If a Bone is added to this Bone's children, any iterators from beginChildren or endChildren become invalid.

Bone * Bone::findBone const std::string &    boneName
 

Finds the specified Bone in this Bone hierarchy.

If this Bone's name is the same as the passed name, then a pointer to this object is returned. Else, the method looks through all of its children recursively. If the Bone is not found, NULL is returned.

If more than one Bone of the same name exists in the hierarchy, then one of them will be returned.

Bone * Bone::getParent  
 

Returns the parent to this Bone.

NULL may be returned if this Bone has no parent.

void Bone::loadBoneNameSet BoneNameSet &    boneSet,
bool    incParent,
bool    incChildren
const
 

Loads the passed boneSet with the name of this bone, plus the name of its parent and the names of all of its children.

The latter two are customizable depending if the flags are set.

void Bone::updateHierarchy const Matrix &    worldMat
 

Updates this Bone's final matrix.

The worldMat is this Bone's parent's final matrix, except for the root bone.


The documentation for this class was generated from the following files:
Generated on Wed May 14 01:38:07 2003 for CG Skeletal Animation Project by doxygen1.2.18