forked from bartvdbraak/blender
Applied patch #6102 submitted by Mal
This commit is contained in:
parent
5219812f55
commit
9deb69dbca
@ -70,6 +70,17 @@ KX_TrackToActuator::KX_TrackToActuator(SCA_IObject *gameobj,
|
|||||||
m_object = ob;
|
m_object = ob;
|
||||||
m_trackflag = trackflag;
|
m_trackflag = trackflag;
|
||||||
m_upflag = upflag;
|
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 */
|
} /* End of constructor */
|
||||||
|
|
||||||
|
|
||||||
@ -325,8 +336,29 @@ bool KX_TrackToActuator::Update(double curtime, bool frame)
|
|||||||
/* erwin should rewrite this! */
|
/* erwin should rewrite this! */
|
||||||
mat= matrix3x3_interpol(oldmat, mat, m_time);
|
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;
|
result = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
|
|
||||||
#include "SCA_IActuator.h"
|
#include "SCA_IActuator.h"
|
||||||
#include "SCA_IObject.h"
|
#include "SCA_IObject.h"
|
||||||
|
#include "MT_Matrix3x3.h"
|
||||||
|
#include "KX_GameObject.h"
|
||||||
|
|
||||||
|
|
||||||
class KX_TrackToActuator : public SCA_IActuator
|
class KX_TrackToActuator : public SCA_IActuator
|
||||||
{
|
{
|
||||||
@ -50,7 +53,11 @@ class KX_TrackToActuator : public SCA_IActuator
|
|||||||
int m_trackTime;
|
int m_trackTime;
|
||||||
int m_trackflag;
|
int m_trackflag;
|
||||||
int m_upflag;
|
int m_upflag;
|
||||||
public:
|
|
||||||
|
MT_Matrix3x3 m_parentlocalmat;
|
||||||
|
KX_GameObject* m_parentobj;
|
||||||
|
|
||||||
|
public:
|
||||||
KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time,
|
KX_TrackToActuator(SCA_IObject* gameobj, SCA_IObject *ob, int time,
|
||||||
bool threedee,int trackflag,int upflag, PyTypeObject* T=&Type);
|
bool threedee,int trackflag,int upflag, PyTypeObject* T=&Type);
|
||||||
virtual ~KX_TrackToActuator();
|
virtual ~KX_TrackToActuator();
|
||||||
|
Loading…
Reference in New Issue
Block a user