Added pausing capabilities to curve based (IPO) animations, bound ThreeDanimation class to scripts as type Animator
This commit is contained in:
parent
0c24507821
commit
f0622f425d
@ -12,5 +12,7 @@ void onTrigger()
|
||||
PhysicalObject @haybail = t_obj.getPhysicalObject();
|
||||
haybail.disable();
|
||||
Mesh @haybailMesh = t_obj.getMesh();
|
||||
Animator @haybailAnimator = t_obj.getAnimator();
|
||||
haybailAnimator.setPaused(true);
|
||||
//if (haybail.isFlattener())squashKart(0,35.0);
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ ThreeDAnimation::ThreeDAnimation(const XMLNode &node, TrackObject* object) : Ani
|
||||
{
|
||||
m_object = object;
|
||||
|
||||
m_is_paused = false;
|
||||
m_crash_reset = false;
|
||||
m_explode_kart = false;
|
||||
m_flatten_kart = false;
|
||||
@ -77,6 +78,9 @@ void ThreeDAnimation::update(float dt)
|
||||
Vec3 xyz = m_object->getPosition();
|
||||
Vec3 scale = m_object->getScale();
|
||||
|
||||
//make the object think no time has passed to pause it's animation
|
||||
if (m_is_paused)dt = 0;
|
||||
|
||||
AnimationBase::update(dt, &xyz, &m_hpr, &scale); //updates all IPOs
|
||||
//m_node->setPosition(xyz.toIrrVector());
|
||||
//m_node->setScale(scale.toIrrVector());
|
||||
|
@ -56,6 +56,8 @@ private:
|
||||
|
||||
bool m_flatten_kart;
|
||||
|
||||
/** True if animation is currently paused by scripts */
|
||||
bool m_is_paused;
|
||||
/** We have to store the rotation value as computed in blender, since
|
||||
* irrlicht uses a different order, so for rotation animations we
|
||||
* can not use the value returned by getRotation from a scene node. */
|
||||
@ -78,6 +80,7 @@ public:
|
||||
bool isCrashReset() const { return m_crash_reset; }
|
||||
bool isExplodeKartObject() const { return m_explode_kart; }
|
||||
bool isFlattenKartObject() const { return m_flatten_kart; }
|
||||
void setPaused(bool mode){ m_is_paused = mode; }
|
||||
}; // ThreeDAnimation
|
||||
#endif
|
||||
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include "tracks/track_object_manager.hpp"
|
||||
#include "tracks/track_object.hpp"
|
||||
#include "tracks/track.hpp"
|
||||
#include <iostream> //debug
|
||||
#include "animations/three_d_animation.hpp"
|
||||
|
||||
namespace Scripting
|
||||
{
|
||||
|
||||
@ -48,6 +49,10 @@ namespace Scripting
|
||||
{
|
||||
((PhysicalObject*)(memory))->removeBody();
|
||||
}
|
||||
void setPaused(bool mode, void *memory)
|
||||
{
|
||||
((ThreeDAnimation*)(memory))->setPaused(mode);
|
||||
}
|
||||
void getTrackObject(asIScriptGeneric *gen)
|
||||
{
|
||||
std::string *str = (std::string*)gen->GetArgAddress(0);
|
||||
@ -92,6 +97,11 @@ namespace Scripting
|
||||
r = engine->RegisterObjectMethod("PhysicalObject", "void disable()", asFUNCTION(disable), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Mesh", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Mesh @getMesh()", asMETHOD(TrackObject, getMesh), asCALL_THISCALL); assert(r >= 0);
|
||||
r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("TrackObject", "Animator @getAnimator()", asMETHOD(TrackObject, getAnimatorForScript), asCALL_THISCALL); assert(r >= 0);
|
||||
//fails due to insufficient visibility to scripts TODO : Decide whether to fix visibility or introduce wrappers
|
||||
//r = engine->RegisterObjectMethod("Animator", "void setPaused(bool mode)", asMETHOD(ThreeDAnimation, setPaused), asCALL_THISCALL); assert(r >= 0);
|
||||
r = engine->RegisterObjectMethod("Animator", "void setPaused(bool mode)", asFUNCTION( setPaused ), asCALL_CDECL_OBJLAST); assert(r >= 0);
|
||||
|
||||
|
||||
}
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "utils/no_copy.hpp"
|
||||
#include "utils/vec3.hpp"
|
||||
#include <string>
|
||||
#include "animations/three_d_animation.hpp"
|
||||
|
||||
class XMLNode;
|
||||
class ThreeDAnimation;
|
||||
@ -146,6 +147,10 @@ public:
|
||||
|
||||
ThreeDAnimation* getAnimator() { return m_animator; }
|
||||
const ThreeDAnimation* getAnimator() const { return m_animator; }
|
||||
//Due to above overload AngelScript cannot decide which function to bind
|
||||
ThreeDAnimation* getAnimatorForScript() { return m_animator; }
|
||||
|
||||
void setPaused(bool mode){ m_animator->setPaused(mode); }
|
||||
|
||||
const core::vector3df& getPosition() const;
|
||||
const core::vector3df getAbsolutePosition() const;
|
||||
|
Loading…
Reference in New Issue
Block a user