Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharlie Carley <snailrose@gmail.com>2007-03-23 05:20:12 +0300
committerCharlie Carley <snailrose@gmail.com>2007-03-23 05:20:12 +0300
commit9deb69dbca1d766759300bea956e3dbe0301acc0 (patch)
treede1ceb88a98c6a5092d89bebb84e3362ded149e7 /source/gameengine/Ketsji
parent5219812f55ce37a2bd0cb6461084963019e013b6 (diff)
Applied patch #6102 submitted by Mal
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.cpp36
-rw-r--r--source/gameengine/Ketsji/KX_TrackToActuator.h9
2 files changed, 42 insertions, 3 deletions
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
index 0b16ff14f72..36f0d3c3b99 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp
@@ -70,6 +70,17 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
m_object = ob;
m_trackflag = trackflag;
m_upflag = upflag;
+ m_parentobj = 0;
+
+ if (m_object){
+ KX_GameObject* curobj = (KX_GameObject*) GetParent();
+
+ m_parentobj = curobj->GetParent(); // check if the object is parented
+ if (m_parentobj) { // if so, store the initial local rotation
+ m_parentlocalmat = m_parentobj->GetSGNode()->GetLocalOrientation();
+ }
+ }
+
} /* End of constructor */
@@ -325,8 +336,29 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
/* erwin should rewrite this! */
mat= matrix3x3_interpol(oldmat, mat, m_time);
- curobj->NodeSetLocalOrientation(mat);
-
+
+ if(m_parentobj){ // check if the model is parented and calculate the child transform
+
+ MT_Point3 localpos;
+ localpos = curobj->GetSGNode()->GetLocalPosition();
+ // Get the inverse of the parent matrix
+ MT_Matrix3x3 parentmatinv;
+ parentmatinv = m_parentobj->NodeGetWorldOrientation ().inverse ();
+ // transform the local coordinate system into the parents system
+ mat = parentmatinv * mat;
+ // append the initial parent local rotation matrix
+ mat = m_parentlocalmat * mat;
+
+ // set the models tranformation properties
+ curobj->NodeSetLocalOrientation(mat);
+ curobj->NodeSetLocalPosition(localpos);
+ curobj->UpdateTransform();
+ }
+ else
+ {
+ curobj->NodeSetLocalOrientation(mat);
+ }
+
result = true;
}
diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.h b/source/gameengine/Ketsji/KX_TrackToActuator.h
index 6b0ddd7103e..1d257da3f53 100644
--- a/source/gameengine/Ketsji/KX_TrackToActuator.h
+++ b/source/gameengine/Ketsji/KX_TrackToActuator.h
@@ -37,6 +37,9 @@
#include "SCA_IActuator.h"
#include "SCA_IObject.h"
+#include "MT_Matrix3x3.h"
+#include "KX_GameObject.h"
+
class KX_TrackToActuator : public SCA_IActuator
{
@@ -50,7 +53,11 @@ class KX_TrackToActuator : public SCA_IActuator
int m_trackTime;
int m_trackflag;
int m_upflag;
- public:
+
+ MT_Matrix3x3 m_parentlocalmat;
+ KX_GameObject* m_parentobj;
+
+ public:
KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time,
bool threedee,int trackflag,int upflag, PyTypeObject* T=&Type);
virtual ~KX_TrackToActuator();