JointVertexTransform

This commit is contained in:
David Rose 2005-03-25 13:57:54 +00:00
parent 24353df3ef
commit 4bb06ac900
3 changed files with 27 additions and 36 deletions

View File

@ -18,23 +18,12 @@
////////////////////////////////////////////////////////////////////
// Function: JointVertexTransform::get_from
// Function: JointVertexTransform::get_joint
// Access: Published
// Description: Returns the joint whose coordinate space this object
// moves vertices from.
// Description: Returns the joint for which this object returns the
// transform.
////////////////////////////////////////////////////////////////////
INLINE const CharacterJoint *JointVertexTransform::
get_from() const {
return _from;
}
////////////////////////////////////////////////////////////////////
// Function: JointVertexTransform::get_to
// Access: Published
// Description: Returns the joint whose coordinate space this object
// moves vertices into.
////////////////////////////////////////////////////////////////////
INLINE const CharacterJoint *JointVertexTransform::
get_to() const {
return _to;
get_joint() const {
return _joint;
}

View File

@ -44,13 +44,12 @@ JointVertexTransform() :
// other indicated joint's space.
////////////////////////////////////////////////////////////////////
JointVertexTransform::
JointVertexTransform(CharacterJoint *from, CharacterJoint *to) :
_from(from),
_to(to),
JointVertexTransform(CharacterJoint *joint) :
_joint(joint),
_matrix_stale(true)
{
// Tell the "to" joint that we need to be informed when it moves.
_to->_vertex_transforms.insert(this);
// Tell the joint that we need to be informed when it moves.
_joint->_vertex_transforms.insert(this);
}
////////////////////////////////////////////////////////////////////
@ -60,8 +59,8 @@ JointVertexTransform(CharacterJoint *from, CharacterJoint *to) :
////////////////////////////////////////////////////////////////////
JointVertexTransform::
~JointVertexTransform() {
// Tell the "to" joint to stop informing us about its motion.
_to->_vertex_transforms.erase(this);
// Tell the joint to stop informing us about its motion.
_joint->_vertex_transforms.erase(this);
}
////////////////////////////////////////////////////////////////////
@ -73,8 +72,8 @@ void JointVertexTransform::
get_matrix(LMatrix4f &matrix) const {
if (_matrix_stale) {
((JointVertexTransform *)this)->_matrix =
_from->_initial_net_transform_inverse *
_to->_net_transform;
_joint->_initial_net_transform_inverse *
_joint->_net_transform;
((JointVertexTransform *)this)->_matrix_stale = false;
}
@ -88,7 +87,7 @@ get_matrix(LMatrix4f &matrix) const {
////////////////////////////////////////////////////////////////////
void JointVertexTransform::
output(ostream &out) const {
out << _to->get_name();
out << _joint->get_name();
}

View File

@ -27,11 +27,16 @@
////////////////////////////////////////////////////////////////////
// Class : JointVertexTransform
// Description : This is a specialization on VertexTransform that
// returns the relative transform from one joint's
// initial position to another joint's (or possibly the
// same joint's) current position. It is used to
// implement soft-skinned vertices for an animated
// character.
// returns the transform necessary to move vertices as
// if they were assigned to the indicated joint. The
// geometry itself should be parented to the scene graph
// at the level of the character's root joint; that is,
// it should not be parented under a node directly
// animated by any joints.
//
// Multiple combinations of these with different weights
// are used to implement soft-skinned vertices for an
// animated character.
//
// This is part of the experimental Geom rewrite.
////////////////////////////////////////////////////////////////////
@ -40,19 +45,17 @@ private:
JointVertexTransform();
PUBLISHED:
JointVertexTransform(CharacterJoint *from, CharacterJoint *to);
JointVertexTransform(CharacterJoint *joint);
virtual ~JointVertexTransform();
INLINE const CharacterJoint *get_from() const;
INLINE const CharacterJoint *get_to() const;
INLINE const CharacterJoint *get_joint() const;
virtual void get_matrix(LMatrix4f &matrix) const;
virtual void output(ostream &out) const;
private:
PT(CharacterJoint) _from;
PT(CharacterJoint) _to;
PT(CharacterJoint) _joint;
LMatrix4f _matrix;
bool _matrix_stale;