//--------------------------------------------------------------------- void Bone::setBindingPose(void) { setInitialState(); // Save inverse derived position/scale/orientation, used for calculate offset transform later mBindDerivedInversePosition = - _getDerivedPosition(); mBindDerivedInverseScale = Vector3::UNIT_SCALE / _getDerivedScale(); mBindDerivedInverseOrientation = _getDerivedOrientation().Inverse(); }
// [7/30/2008 zhangxiang] const Matrix4 &sgNode::getFullTransform(void) const{ if(m_bCachedTransformOutOfDate){ // Use derived values m_CachedTransform.makeTransform( _getDerivedPosition(), _getDerivedScale(), _getDerivedOrientation()); m_bCachedTransformOutOfDate = false; } return m_CachedTransform; }
//--------------------------------------------------------------------- void Bone::_getOffsetTransform(Matrix4& m) const { // Combine scale with binding pose inverse scale, // NB just combine as equivalent axes, no shearing Vector3 scale = _getDerivedScale() * mBindDerivedInverseScale; // Combine orientation with binding pose inverse orientation Quaternion rotate = _getDerivedOrientation() * mBindDerivedInverseOrientation; // Combine position with binding pose inverse position, // Note that translation is relative to scale & rotation, // so first reverse transform original derived position to // binding pose bone space, and then transform to current // derived bone space. Vector3 translate = _getDerivedPosition() + rotate * (scale * mBindDerivedInversePosition); m.makeTransform(translate, scale, rotate); }
// [7/30/2008 zhangxiang] const Vector3 &sgNode::absoluteScale(void) const{ return _getDerivedScale(); }