Added setLoop to skeletal animations, Test : rapidly nodding sheep in green valley, also incorporates trigger creation at start in the test.

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-06-17 21:11:05 +05:30
parent 77ee20a5e2
commit b7e3329d83
5 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,10 @@
void onTrigger()
{
TrackObject @t_obj = getTrackObject("anim_sheep2.b3d");
//t_obj.setEnable(false);
Mesh @sheepMesh = t_obj.getMesh();
displayMessage("moo");
sheepMesh.setLoop(1,3); //rapid-nod sheep
}

View File

@ -2,5 +2,7 @@ void onUpdate()
{
displayMessage("Track Loaded");
//For green valley sheep test. See sheep_approach.as
createTrigger("sheep_approach",-5.48,7.21,0.49,10.0);
}

View File

@ -65,6 +65,10 @@ namespace Scripting
{
((ThreeDAnimation*)(memory))->setPaused(mode);
}
void setLoop(int start, int end, void *memory)
{
((TrackObjectPresentationMesh*)(memory))->setLoop(start,end);
}
void getTrackObject(asIScriptGeneric *gen)
{
std::string *str = (std::string*)gen->GetArgAddress(0);
@ -109,6 +113,7 @@ 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->RegisterObjectMethod("Mesh", "void setLoop(int start, int end)", asFUNCTION(setLoop), asCALL_CDECL_OBJLAST); 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

View File

@ -421,6 +421,22 @@ void TrackObjectPresentationMesh::reset()
}
void TrackObjectPresentationMesh::setLoop(int start, int end)
{
if (m_node->getType() == scene::ESNT_ANIMATED_MESH)
{
scene::IAnimatedMeshSceneNode *a_node =
(scene::IAnimatedMeshSceneNode*)m_node;
// trick to reset the animation AND also the timer inside it
//a_node->OnAnimate(0);
//a_node->OnAnimate(0);
// irrlicht's "setFrameLoop" is a misnomer, it just sets the first and
// last frame, even if looping is disabled
a_node->setFrameLoop(start, end);
}
}
// ----------------------------------------------------------------------------

View File

@ -222,6 +222,8 @@ public:
scene::IAnimatedMesh* mesh, const core::vector3df& xyz,
const core::vector3df& hpr, const core::vector3df& scale);
void setLoop(int start, int end); //set custom loops, as well as pause by scripts
virtual ~TrackObjectPresentationMesh();
virtual void reset() OVERRIDE;