From d5d0ffceb45b256320060a465351d81374d849d6 Mon Sep 17 00:00:00 2001 From: Sachith Hasaranga Seneviratne Date: Sat, 5 Jul 2014 08:54:49 +0530 Subject: [PATCH] Bound particle emitters to scripts and added move functionality --- data/scripts/greenvalley/triggers.as | 5 +++++ src/scriptengine/script_track.cpp | 22 ++++++++++++++++++++-- src/tracks/track_object.hpp | 2 ++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/data/scripts/greenvalley/triggers.as b/data/scripts/greenvalley/triggers.as index 26d5a6110..210bf1280 100644 --- a/data/scripts/greenvalley/triggers.as +++ b/data/scripts/greenvalley/triggers.as @@ -9,6 +9,11 @@ void sheep_dance() Vec3 newloc = Vec3(2,3,4); sheepMesh.move(newloc); //runScript("sheep_approach"); + TrackObject @t_obj2 = getTrackObject("waterfall"); + ParticleEmitter @waterfallemitter = t_obj2.getParticleEmitter(); + Vec3 newlocation = Vec3(0,2,5); + waterfallemitter.move(newlocation); + } diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index d0ff30179..7d3112f44 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -69,7 +69,7 @@ namespace Scripting { ((ThreeDAnimation*)(memory))->setPaused(mode); } - void move(Vec3 *new_pos,void *memory) + void moveMesh(Vec3 *new_pos,void *memory) { core::vector3df xyz = core::vector3df(0, 0, 0); xyz.X = new_pos->getX(); @@ -79,6 +79,16 @@ namespace Scripting core::vector3df scale = core::vector3df(1, 1, 1); ((TrackObjectPresentationMesh*)(memory))->move(xyz, hpr, scale); } + void moveParticles(Vec3 *new_pos, void *memory) + { + core::vector3df xyz = core::vector3df(0, 0, 0); + xyz.X = new_pos->getX(); + xyz.Y = new_pos->getY(); + xyz.Z = new_pos->getZ(); + core::vector3df hpr = core::vector3df(0, 0, 0); + core::vector3df scale = core::vector3df(1, 1, 1); + ((TrackObjectPresentationParticles*)(memory))->move(xyz, hpr, scale); + } void setLoop(int start, int end, void *memory) { ((TrackObjectPresentationMesh*)(memory))->setLoop(start,end); @@ -166,7 +176,15 @@ namespace Scripting r = engine->RegisterObjectMethod("Mesh", "void setLoop(int start, int end)", asFUNCTION(setLoop), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("Mesh", "int getCurrentFrame()", asFUNCTION(getCurrentFrame), asCALL_CDECL_OBJLAST); assert(r >= 0); r = engine->RegisterObjectMethod("Mesh", "void setCurrentFrame(int frame)", asFUNCTION(setCurrentFrame), asCALL_CDECL_OBJLAST); assert(r >= 0); - r = engine->RegisterObjectMethod("Mesh", "void move(Vec3 &in)", asFUNCTION(move), asCALL_CDECL_OBJLAST); assert(r >= 0); + r = engine->RegisterObjectMethod("Mesh", "void move(Vec3 &in)", asFUNCTION(moveMesh), asCALL_CDECL_OBJLAST); assert(r >= 0); + + //Particle Emitter + r = engine->RegisterObjectType("ParticleEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); + r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter @getParticleEmitter()", asMETHOD(TrackObject, getParticles), asCALL_THISCALL); assert(r >= 0); + r = engine->RegisterObjectMethod("ParticleEmitter", "void move(Vec3 &in)", asFUNCTION(moveParticles), asCALL_CDECL_OBJLAST); assert(r >= 0); + + + //Curve based Animation r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0); diff --git a/src/tracks/track_object.hpp b/src/tracks/track_object.hpp index e469e0eff..617b5b8df 100644 --- a/src/tracks/track_object.hpp +++ b/src/tracks/track_object.hpp @@ -145,6 +145,8 @@ public: TrackObjectPresentationMesh* getMesh(){ return getPresentation(); } + TrackObjectPresentationParticles* getParticles(){ return getPresentation(); } + ThreeDAnimation* getAnimator() { return m_animator; } const ThreeDAnimation* getAnimator() const { return m_animator; } //Due to above overload AngelScript cannot decide which function to bind