Undo::CommandPtr Transform::ComputeObjectComponents() { Undo::CommandPtr command = ResetTransform(); Math::Scale scale; Math::EulerAngles rotate; Math::Vector3 translate; if (GetInheritTransform()) { // compute the new object space transform from our global transform and our parent's inverse Matrix4 objectTransform = (m_GlobalTransform * m_Parent->GetTransform()->GetInverseGlobalTransform()); // decompose into the new set of components objectTransform.Decompose(scale, rotate, translate); } else { // we are not inheriting our parent's transform, use the global transform for our components m_GlobalTransform.Decompose(scale, rotate, translate); } m_Scale = scale; m_Rotate = rotate; m_Translate = translate; return command; }
//---------------------------------------------------------------- /// Set Local Transform /// /// This will overwrite any local previous transformations /// /// @param Objects transformation matrix //---------------------------------------------------------------- void Transform::SetLocalTransform(const Matrix4& inmatTransform) { inmatTransform.Decompose(mvPosition, mvScale, mqOrientation); mmatTransform = inmatTransform; OnTransformChanged(); mbIsTransformCacheValid = false; }
//---------------------------------------------------------------- /// Set World Transform /// /// This will overwrite any parent or previous transformations /// /// @param Objects transformation matrix //---------------------------------------------------------------- void Transform::SetWorldTransform(const Matrix4& inmatTransform) { inmatTransform.Decompose(mvWorldPosition, mvWorldScale, mqWorldOrientation); mmatWorldTransform = inmatTransform; OnTransformChanged(); mbIsTransformCacheValid = true; mbIsParentTransformCacheValid = true; }
void Transform::SetObjectTransform( const Matrix4& transform ) { Scale scale; EulerAngles rotate; Vector3 translate; transform.Decompose( scale, rotate, translate ); m_Scale = scale; m_Rotate = rotate; m_Translate = translate; m_ObjectTransform = transform; }