more preparation for physics recording to ipo keyframes
This commit is contained in:
@@ -39,6 +39,10 @@
|
||||
#include "KX_IpoConvert.h"
|
||||
#include "RAS_MeshObject.h"
|
||||
#include "KX_PhysicsEngineEnums.h"
|
||||
#include "PHY_IPhysicsEnvironment.h"
|
||||
#include "KX_KetsjiEngine.h"
|
||||
#include "Object.h"
|
||||
#include "KX_IPhysicsController.h"
|
||||
|
||||
#include "DummyPhysicsEnvironment.h"
|
||||
|
||||
@@ -73,6 +77,10 @@
|
||||
#include "DNA_world_types.h"
|
||||
#include "BKE_main.h"
|
||||
|
||||
#include "DNA_object_types.h"
|
||||
#include "DNA_ipo_types.h"
|
||||
#include "DNA_curve_types.h"
|
||||
|
||||
|
||||
KX_BlenderSceneConverter::KX_BlenderSceneConverter(
|
||||
struct Main* maggie,
|
||||
@@ -321,7 +329,9 @@ void KX_BlenderSceneConverter::ConvertScene(const STR_String& scenename,
|
||||
|
||||
m_map_blender_to_gameobject.clear();
|
||||
m_map_mesh_to_gamemesh.clear();
|
||||
m_map_gameobject_to_blender.clear();
|
||||
|
||||
//don't clear it yet, it is needed for the baking physics into ipo animation
|
||||
//m_map_gameobject_to_blender.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -466,6 +476,50 @@ void KX_BlenderSceneConverter::RegisterWorldInfo(
|
||||
void KX_BlenderSceneConverter::ResetPhysicsObjectsAnimationIpo()
|
||||
{
|
||||
//todo,before 2.38/2.40 release, Erwin
|
||||
|
||||
KX_SceneList* scenes = m_ketsjiEngine->CurrentScenes();
|
||||
int numScenes = scenes->size();
|
||||
int i;
|
||||
for (i=0;i<numScenes;i++)
|
||||
{
|
||||
KX_Scene* scene = scenes->at(i);
|
||||
//PHY_IPhysicsEnvironment* physEnv = scene->GetPhysicsEnvironment();
|
||||
CListValue* parentList = scene->GetRootParentList();
|
||||
int numObjects = parentList->GetCount();
|
||||
int g;
|
||||
for (g=0;g<numObjects;g++)
|
||||
{
|
||||
KX_GameObject* gameObj = (KX_GameObject*)parentList->GetValue(g);
|
||||
if (gameObj->IsDynamic())
|
||||
{
|
||||
//KX_IPhysicsController* physCtrl = gameObj->GetPhysicsController();
|
||||
|
||||
Object* blenderObject = FindBlenderObject(gameObj);
|
||||
if (blenderObject)
|
||||
{
|
||||
//erase existing ipo's
|
||||
Ipo* ipo = blenderObject->ipo;
|
||||
if (ipo)
|
||||
{
|
||||
|
||||
IpoCurve *icu;
|
||||
int numCurves = 0;
|
||||
for( icu = (IpoCurve*)ipo->curve.first; icu; icu = icu->next ) {
|
||||
numCurves++;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
///this generates ipo curves for position, rotation, allowing to use game physics in animation
|
||||
@@ -596,6 +650,19 @@ void KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
|
||||
return IpoCurve_CreatePyObject( icu );
|
||||
}
|
||||
|
||||
static PyObject *Ipo_getNcurves( BPy_Ipo * self )
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
IpoCurve *icu;
|
||||
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
|
||||
i++;
|
||||
}
|
||||
|
||||
return ( PyInt_FromLong( i ) );
|
||||
}
|
||||
|
||||
|
||||
static PyObject *Ipo_getNBezPoints( BPy_Ipo * self, PyObject * args )
|
||||
{
|
||||
int num = 0, i = 0;
|
||||
|
@@ -305,7 +305,7 @@ static void BL_RegisterSumoObject(
|
||||
|
||||
// need easy access, not via 'node' etc.
|
||||
KX_SumoPhysicsController* physicscontroller = new KX_SumoPhysicsController(sumoScene,sumoObj,motionstate,isDynamic);
|
||||
gameobj->SetPhysicsController(physicscontroller);
|
||||
gameobj->SetPhysicsController(physicscontroller,isDynamic);
|
||||
|
||||
|
||||
if (!gameobj->getClientInfo())
|
||||
@@ -1012,7 +1012,7 @@ void KX_ConvertBulletObject( class KX_GameObject* gameobj,
|
||||
env->addCcdPhysicsController( physicscontroller);
|
||||
|
||||
|
||||
gameobj->SetPhysicsController(physicscontroller);
|
||||
gameobj->SetPhysicsController(physicscontroller,dyna);
|
||||
physicscontroller->setNewClientInfo(gameobj->getClientInfo());
|
||||
bool isActor = objprop->m_isactor;
|
||||
gameobj->getClientInfo()->m_type = (isActor ? KX_ClientObjectInfo::ACTOR : KX_ClientObjectInfo::STATIC);
|
||||
|
@@ -265,38 +265,26 @@ public:
|
||||
* @return a pointer to the physics controller owned by this class.
|
||||
*/
|
||||
|
||||
KX_IPhysicsController*
|
||||
GetPhysicsController(
|
||||
) ;
|
||||
KX_IPhysicsController* GetPhysicsController() ;
|
||||
|
||||
void SetPhysicsController
|
||||
(KX_IPhysicsController* physicscontroller)
|
||||
{ m_pPhysicsController1 = physicscontroller;};
|
||||
void SetPhysicsController(KX_IPhysicsController* physicscontroller,bool isDynamic)
|
||||
{
|
||||
m_bDyna = isDynamic;
|
||||
m_pPhysicsController1 = physicscontroller;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @section Coordinate system manipulation functions
|
||||
*/
|
||||
|
||||
void
|
||||
NodeSetLocalPosition(
|
||||
const MT_Point3& trans
|
||||
);
|
||||
void NodeSetLocalPosition(const MT_Point3& trans );
|
||||
|
||||
void
|
||||
NodeSetLocalOrientation(
|
||||
const MT_Matrix3x3& rot
|
||||
);
|
||||
void NodeSetLocalOrientation(const MT_Matrix3x3& rot );
|
||||
|
||||
void
|
||||
NodeSetLocalScale(
|
||||
const MT_Vector3& scale
|
||||
);
|
||||
void NodeSetLocalScale( const MT_Vector3& scale );
|
||||
|
||||
void
|
||||
NodeSetRelativeScale(
|
||||
const MT_Vector3& scale
|
||||
);
|
||||
void NodeSetRelativeScale( const MT_Vector3& scale );
|
||||
|
||||
void
|
||||
NodeUpdateGS(
|
||||
@@ -324,16 +312,13 @@ public:
|
||||
* @section scene graph node accessor functions.
|
||||
*/
|
||||
|
||||
SG_Node*
|
||||
GetSGNode(
|
||||
) {
|
||||
SG_Node* GetSGNode( )
|
||||
{
|
||||
return m_pSGNode;
|
||||
}
|
||||
|
||||
const
|
||||
SG_Node*
|
||||
GetSGNode(
|
||||
) const {
|
||||
const SG_Node* GetSGNode( ) const
|
||||
{
|
||||
return m_pSGNode;
|
||||
}
|
||||
|
||||
@@ -345,19 +330,14 @@ public:
|
||||
* old node. This class takes ownership of the new
|
||||
* node.
|
||||
*/
|
||||
void
|
||||
SetSGNode(
|
||||
SG_Node* node
|
||||
){
|
||||
m_pSGNode = node;
|
||||
}
|
||||
void SetSGNode(SG_Node* node )
|
||||
{
|
||||
m_pSGNode = node;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated & broken
|
||||
*/
|
||||
bool
|
||||
IsDynamic(
|
||||
) const {
|
||||
//Is it a dynamic/physics object ?
|
||||
bool IsDynamic() const
|
||||
{
|
||||
return m_bDyna;
|
||||
}
|
||||
|
||||
|
@@ -258,6 +258,10 @@ void KX_KetsjiEngine::StartEngine()
|
||||
m_firstframe = true;
|
||||
m_bInitialized = true;
|
||||
m_ticrate = DEFAULT_LOGIC_TIC_RATE;
|
||||
m_currentFrame = 0;
|
||||
|
||||
m_sceneconverter->ResetPhysicsObjectsAnimationIpo();
|
||||
|
||||
}
|
||||
|
||||
bool KX_KetsjiEngine::BeginFrame()
|
||||
@@ -305,6 +309,8 @@ void KX_KetsjiEngine::EndFrame()
|
||||
m_rendertools->EndFrame(m_rasterizer);
|
||||
|
||||
m_canvas->EndDraw();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -390,6 +396,9 @@ void KX_KetsjiEngine::NextFrame()
|
||||
m_logger->StartLog(tc_physics, m_kxsystem->GetTimeInSeconds(), true);
|
||||
scene->GetPhysicsEnvironment()->proceedDeltaTime(localtime,realDeltaTime);
|
||||
m_previoustime = curtime;
|
||||
|
||||
m_sceneconverter->WritePhysicsObjectToAnimationIpo(m_currentFrame++);
|
||||
|
||||
} // suspended
|
||||
|
||||
DoSound(scene);
|
||||
|
@@ -97,7 +97,8 @@ private:
|
||||
bool m_bFixedTime;
|
||||
|
||||
bool m_firstframe;
|
||||
|
||||
int m_currentFrame;
|
||||
|
||||
double m_previoustime;
|
||||
double m_deltatime;
|
||||
static double m_ticrate;
|
||||
|
@@ -157,9 +157,11 @@ void KX_SumoPhysicsController::SetObject (SG_IObject* object)
|
||||
SG_Controller::SetObject(object);
|
||||
|
||||
// cheating here...
|
||||
KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
|
||||
gameobj->SetPhysicsController(this);
|
||||
GetSumoObject()->setClientObject(gameobj->getClientInfo());
|
||||
//should not be necessary, is it for duplicates ?
|
||||
|
||||
KX_GameObject* gameobj = (KX_GameObject*) object->GetSGClientObject();
|
||||
gameobj->SetPhysicsController(this,gameobj->IsDynamic());
|
||||
GetSumoObject()->setClientObject(gameobj->getClientInfo());
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user