From 74f19f0cbc9e89234de4836ee88d81318f7647e0 Mon Sep 17 00:00:00 2001 From: Marianne Gagnon Date: Mon, 22 Jun 2015 19:36:30 -0400 Subject: [PATCH] Start working on scripting API to move objects --- src/scriptengine/script_track.cpp | 3 ++- src/scriptengine/scriptvec3.hpp | 6 +++--- src/tracks/track_object.hpp | 10 ++++++++++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/scriptengine/script_track.cpp b/src/scriptengine/script_track.cpp index a2c475167..8c748c86d 100644 --- a/src/scriptengine/script_track.cpp +++ b/src/scriptengine/script_track.cpp @@ -243,7 +243,8 @@ namespace Scripting r = engine->RegisterObjectMethod("TrackObject", "Mesh@ getMesh()", asMETHOD(TrackObject, getMesh), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("TrackObject", "ParticleEmitter@ getParticleEmitter()", asMETHOD(TrackObject, getParticleEmitter), asCALL_THISCALL); assert(r >= 0); r = engine->RegisterObjectMethod("TrackObject", "Animator@ getIPOAnimator()", asMETHOD(TrackObject, getIPOAnimator), asCALL_THISCALL); assert(r >= 0); - // TODO: add move method + r = engine->RegisterObjectMethod("TrackObject", "void moveTo(const Vec3 &in, bool)", asMETHOD(TrackObject, moveTo), asCALL_THISCALL); assert(r >= 0); + // PhysicalObject r = engine->RegisterObjectMethod("PhysicalObject", "bool isFlattenKartObject()", asMETHOD(PhysicalObject, isFlattenKartObject), asCALL_THISCALL); assert(r >= 0); diff --git a/src/scriptengine/scriptvec3.hpp b/src/scriptengine/scriptvec3.hpp index 5de506dd3..25a8cdbf0 100644 --- a/src/scriptengine/scriptvec3.hpp +++ b/src/scriptengine/scriptvec3.hpp @@ -31,9 +31,9 @@ namespace Scripting float y; float z; - float getX() { return x; } - float getY() { return y; } - float getZ() { return z; } + float getX() const { return x; } + float getY() const { return y; } + float getZ() const { return z; } SimpleVec3() : x(0), y(0), z(0) { } SimpleVec3(float p_x, float p_y, float p_z) : x(p_x), y(p_y), z(p_z) { } diff --git a/src/tracks/track_object.hpp b/src/tracks/track_object.hpp index 1d6ba88c1..70e9b8328 100644 --- a/src/tracks/track_object.hpp +++ b/src/tracks/track_object.hpp @@ -23,6 +23,7 @@ #include "items/item.hpp" #include "physics/physical_object.hpp" +#include "scriptengine/scriptvec3.hpp" #include "tracks/track_object_presentation.hpp" #include "utils/cpp2011.hpp" #include "utils/no_copy.hpp" @@ -212,6 +213,15 @@ public: PhysicalObject* getPhysics() { return m_physical_object; } /** Hide or show the object */ void setEnabled(bool mode); + + void moveTo(const Scripting::SimpleVec3* pos, bool isAbsoluteCoord) + { + move(core::vector3df(pos->getX(), pos->getY(), pos->getZ()), + core::vector3df(0.0f, 0.0f, 0.0f), // TODO: preserve rotation + core::vector3df(1.0f, 1.0f, 1.0f), // TODO: preserve scale + true, // updateRigidBody + isAbsoluteCoord); + } /* @} */ /* @} */ /* @} */