From 70894249c1ffc458d53540663a95ad628cb5e88d Mon Sep 17 00:00:00 2001 From: kearwood Date: Thu, 3 Jan 2013 23:12:39 +0000 Subject: [PATCH] Implemented KRNode::setWorldTranslation() Implemented KRNode::setWorldRotation() Implemented KRNode::setWorldScale() --HG-- extra : convert_revision : svn%3A7752d6cf-9f14-4ad2-affc-04f1e67b81a5/trunk%40206 --- KREngine/KREngine/Classes/KRNode.cpp | 30 ++++++++++++++++++++++++++++ KREngine/KREngine/Classes/KRNode.h | 4 ++++ 2 files changed, 34 insertions(+) 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();