diff options
author | Charlie Carley <snailrose@gmail.com> | 2007-03-23 05:20:12 +0300 |
---|---|---|
committer | Charlie Carley <snailrose@gmail.com> | 2007-03-23 05:20:12 +0300 |
commit | 9deb69dbca1d766759300bea956e3dbe0301acc0 (patch) | |
tree | de1ceb88a98c6a5092d89bebb84e3362ded149e7 /source/gameengine/Ketsji/KX_TrackToActuator.cpp | |
parent | 5219812f55ce37a2bd0cb6461084963019e013b6 (diff) |
Applied patch #6102 submitted by Mal
Diffstat (limited to 'source/gameengine/Ketsji/KX_TrackToActuator.cpp')
-rw-r--r-- | source/gameengine/Ketsji/KX_TrackToActuator.cpp | 36 |
1 files changed, 34 insertions, 2 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; } |