diff options
author | Erwin Coumans <blender@erwincoumans.com> | 2005-08-23 17:16:02 +0400 |
---|---|---|
committer | Erwin Coumans <blender@erwincoumans.com> | 2005-08-23 17:16:02 +0400 |
commit | 056a33ac699f0393b87503536b5492f03fd6b55a (patch) | |
tree | 1f23c3d9ef4d44ed9a48097b914481f5822830de /source/gameengine/Ketsji | |
parent | 0192536102a0d0179f2cb09e62c7035c13ce3723 (diff) |
new game-menu option 'Record Game Physics to Ipo'
including implementation. hope it works, and doesn't break to much.
it bakes physics objects transform into ipo, every frame of the running gameengine.
When you disable and run the game again, it clears the ipo's again. just for physics objects at the moment.
(perhaps some better UI in the future?)
Diffstat (limited to 'source/gameengine/Ketsji')
-rw-r--r-- | source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp | 9 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.cpp | 11 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_KetsjiEngine.h | 5 | ||||
-rw-r--r-- | source/gameengine/Ketsji/KX_TrackToActuator.cpp | 6 |
4 files changed, 23 insertions, 8 deletions
diff --git a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp index b5aea65cfe4..e9a6c2442b0 100644 --- a/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp +++ b/source/gameengine/Ketsji/KX_ConvertPhysicsObjects.cpp @@ -866,7 +866,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, assert(env); - bool dyna = false; + bool isbulletdyna = false; CcdConstructionInfo ci; class PHY_IMotionState* motionstate = new KX_MotionState(gameobj->GetSGNode()); @@ -874,7 +874,8 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, ci.m_gravity = SimdVector3(0,0,0); ci.m_localInertiaTensor =SimdVector3(0,0,0); ci.m_mass = objprop->m_dyna ? shapeprops->m_mass : 0.f; - + isbulletdyna = objprop->m_dyna; + ci.m_localInertiaTensor = SimdVector3(ci.m_mass/3.f,ci.m_mass/3.f,ci.m_mass/3.f); SimdTransform trans; @@ -1008,11 +1009,11 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj, //need a bit of damping, else system doesn't behave well - KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,dyna); + KX_BulletPhysicsController* physicscontroller = new KX_BulletPhysicsController(ci,isbulletdyna); env->addCcdPhysicsController( physicscontroller); - gameobj->SetPhysicsController(physicscontroller,dyna); + gameobj->SetPhysicsController(physicscontroller,isbulletdyna); physicscontroller->setNewClientInfo(gameobj->getClientInfo()); bool isActor = objprop->m_isactor; gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC); diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index 24c34976ce8..3c2f3e04aac 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -120,6 +120,7 @@ KX_KetsjiEngine::KX_KetsjiEngine(KX_ISystem* system) m_bInitialized(false), m_activecam(0), m_bFixedTime(false), + m_game2ipo(false), m_firstframe(true), @@ -397,7 +398,10 @@ void KX_KetsjiEngine::NextFrame() scene->GetPhysicsEnvironment()->proceedDeltaTime(localtime,realDeltaTime); m_previoustime = curtime; - m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame++); + if (m_game2ipo) + { + m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame++); + } } // suspended @@ -1197,6 +1201,11 @@ void KX_KetsjiEngine::SetUseFixedTime(bool bUseFixedTime) } +void KX_KetsjiEngine::SetGame2IpoMode(bool game2ipo,int startFrame) +{ + m_game2ipo = game2ipo; + m_currentFrame = startFrame; +} bool KX_KetsjiEngine::GetUseFixedTime(void) const { diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 5af694f5f1f..7f0b4fd59f9 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -155,6 +155,9 @@ private: bool m_show_debug_properties; + /** record physics into keyframes */ + bool m_game2ipo; + /** Hide cursor every frame? */ bool m_hideCursor; @@ -189,6 +192,8 @@ public: void SetRasterizer(RAS_IRasterizer* rasterizer); void SetPythonDictionary(PyObject* pythondictionary); void SetSceneConverter(KX_ISceneConverter* sceneconverter); + void SetGame2IpoMode(bool game2ipo,int startFrame); + void NextFrame(); void Render(); diff --git a/source/gameengine/Ketsji/KX_TrackToActuator.cpp b/source/gameengine/Ketsji/KX_TrackToActuator.cpp index 2c4d02854ad..0b16ff14f72 100644 --- a/source/gameengine/Ketsji/KX_TrackToActuator.cpp +++ b/source/gameengine/Ketsji/KX_TrackToActuator.cpp @@ -107,7 +107,7 @@ MT_Matrix3x3 EulToMat3(float *eul) /* old function from Blender */ -void Mat3ToEul(MT_Matrix3x3 mat, float *eul) +void Mat3ToEulOld(MT_Matrix3x3 mat, float *eul) { MT_Scalar cy; @@ -154,8 +154,8 @@ MT_Matrix3x3 matrix3x3_interpol(MT_Matrix3x3 oldmat, MT_Matrix3x3 mat, int m_tim { float eul[3], oldeul[3]; - Mat3ToEul(oldmat, oldeul); - Mat3ToEul(mat, eul); + Mat3ToEulOld(oldmat, oldeul); + Mat3ToEulOld(mat, eul); compatible_eulFast(eul, oldeul); eul[0]= (m_time*oldeul[0] + eul[0])/(1.0+m_time); |