Bound particle emitters to scripts and added move functionality

This commit is contained in:
Sachith Hasaranga Seneviratne 2014-07-05 08:54:49 +05:30
parent 6af28141a4
commit d5d0ffceb4
3 changed files with 27 additions and 2 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -145,6 +145,8 @@ public:
TrackObjectPresentationMesh* getMesh(){ return getPresentation<TrackObjectPresentationMesh>(); }
TrackObjectPresentationParticles* getParticles(){ return getPresentation<TrackObjectPresentationParticles>(); }
ThreeDAnimation* getAnimator() { return m_animator; }
const ThreeDAnimation* getAnimator() const { return m_animator; }
//Due to above overload AngelScript cannot decide which function to bind