diff --git a/KREngine/KREngine/Classes/KRNode.cpp b/KREngine/KREngine/Classes/KRNode.cpp index a6bdb59..99486f4 100644 --- a/KREngine/KREngine/Classes/KRNode.cpp +++ b/KREngine/KREngine/Classes/KRNode.cpp @@ -119,6 +119,36 @@ void KRNode::setLocalTranslation(const KRVector3 &v, bool set_original) { } invalidateModelMatrix(); } + +void KRNode::setWorldTranslation(const KRVector3 &v) +{ + if(m_parentNode) { + setLocalTranslation(KRMat4::Dot(m_parentNode->getInverseModelMatrix(), v)); + } else { + setLocalTranslation(v); + } +} + + +void KRNode::setWorldRotation(const KRVector3 &v) +{ + if(m_parentNode) { + setLocalRotation(KRMat4::DotNoTranslate(m_parentNode->getInverseModelMatrix(), v)); + } else { + setLocalRotation(v); + } +} + + +void KRNode::setWorldScale(const KRVector3 &v) +{ + if(m_parentNode) { + setLocalScale(KRMat4::DotNoTranslate(m_parentNode->getInverseModelMatrix(), v)); + } else { + setLocalScale(v); + } +} + void KRNode::setLocalScale(const KRVector3 &v, bool set_original) { m_localScale = v; if(set_original) { diff --git a/KREngine/KREngine/Classes/KRNode.h b/KREngine/KREngine/Classes/KRNode.h index 2c18a78..c2791a9 100644 --- a/KREngine/KREngine/Classes/KRNode.h +++ b/KREngine/KREngine/Classes/KRNode.h @@ -69,6 +69,10 @@ public: const KRVector3 getWorldScale(); const KRVector3 getWorldRotation(); + void setWorldTranslation(const KRVector3 &v); + void setWorldScale(const KRVector3 &v); + void setWorldRotation(const KRVector3 &v); + virtual KRAABB getBounds(); const KRMat4 &getModelMatrix(); const KRMat4 &getInverseModelMatrix();