Scripting : start adding features to control light objects

This commit is contained in:
Marianne Gagnon 2015-10-27 18:33:54 -04:00
parent d2e6a10026
commit 953c29089e
4 changed files with 39 additions and 1 deletions

View File

@ -213,6 +213,25 @@ namespace Scripting
/** @} */
}
// ----------- Light Object methods -----------
namespace Light
{
/**
* @addtogroup Scripting_Light Light (script binding)
* Type returned by trackObject.getLight()
* @{
*/
void setEnergy(float energy, /** \cond DOXYGEN_IGNORE */void *memory /** \endcond */)
{
((TrackObjectPresentationLight*)memory)->setEnergy(energy);
}
/** @} */
}
// ----------- Sound Object methods -----------
namespace SoundEmitter
@ -289,6 +308,7 @@ namespace Scripting
r = engine->RegisterObjectType("ParticleEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
r = engine->RegisterObjectType("SoundEmitter", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
r = engine->RegisterObjectType("Animator", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
r = engine->RegisterObjectType("Light", 0, asOBJ_REF | asOBJ_NOCOUNT); assert(r >= 0);
//r = engine->RegisterGlobalFunction("void disableTrackObject(const string &in)", asFUNCTION(disableTrackObject), asCALL_CDECL); assert(r >= 0);
//r = engine->RegisterGlobalFunction("void enableTrackObject(const string &in)", asFUNCTION(enableTrackObject), asCALL_CDECL); assert(r >= 0);
@ -305,6 +325,7 @@ namespace Scripting
// TrackObject
r = engine->RegisterObjectMethod("TrackObject", "void setEnabled(bool status)", asMETHOD(::TrackObject, setEnabled), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("TrackObject", "SoundEmitter@ getSoundEmitter()", asMETHOD(::TrackObject, getSoundEmitter), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("TrackObject", "Light@ getLight()", asMETHOD(::TrackObject, getLight), asCALL_THISCALL); assert(r >= 0);
r = engine->RegisterObjectMethod("TrackObject", "PhysicalObject@ getPhysics()", asMETHOD(::TrackObject, getPhysics), asCALL_THISCALL); assert(r >= 0);
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);
@ -335,6 +356,8 @@ namespace Scripting
r = engine->RegisterObjectMethod("SoundEmitter", "void playOnce()", asFUNCTION(SoundEmitter::playOnce), asCALL_CDECL_OBJLAST); assert(r >= 0);
r = engine->RegisterObjectMethod("SoundEmitter", "void playLoop()", asFUNCTION(SoundEmitter::playLoop), asCALL_CDECL_OBJLAST); assert(r >= 0);
// Light
r = engine->RegisterObjectMethod("Light", "void setEnergy(float)", asFUNCTION(Light::setEnergy), asCALL_CDECL_OBJLAST); assert(r >= 0);
// Curve based Animation
//fails due to insufficient visibility to scripts TODO : Decide whether to fix visibility or introduce wrappers

View File

@ -197,6 +197,10 @@ public:
* On the script side, the returned object is of type : @ref Scripting_SoundEmitter
*/
TrackObjectPresentationSound* getSoundEmitter(){ return getPresentation<TrackObjectPresentationSound>(); }
/** Should only be used on sound emitter track objects.
* On the script side, the returned object is of type : @ref Scripting_Light
*/
TrackObjectPresentationLight* getLight() { return getPresentation<TrackObjectPresentationLight>(); }
// For angelscript. Needs to be named something different than getAnimator since it's overloaded.
/** Should only be used on TrackObjects that use curve-based animation.
* On the script side, the returned object is of type : @ref Scripting_Animator

View File

@ -25,6 +25,7 @@
#include "graphics/camera.hpp"
#include "graphics/central_settings.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/light.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/mesh_tools.hpp"
#include "graphics/particle_emitter.hpp"
@ -972,7 +973,16 @@ TrackObjectPresentationLight::TrackObjectPresentationLight(
TrackObjectPresentationLight::~TrackObjectPresentationLight()
{
} // ~TrackObjectPresentationLight
// ----------------------------------------------------------------------------
void TrackObjectPresentationLight::setEnergy(float energy)
{
m_energy = energy;
LightNode* lnode = dynamic_cast<LightNode*>(m_node);
if (lnode != NULL)
{
lnode->setEnergy(energy);
}
}
// ----------------------------------------------------------------------------
TrackObjectPresentationActionTrigger::TrackObjectPresentationActionTrigger(
const XMLNode& xml_node)

View File

@ -359,6 +359,7 @@ public:
TrackObjectPresentationLight(const XMLNode& xml_node,
scene::ISceneNode* parent);
virtual ~TrackObjectPresentationLight();
void setEnergy(float energy);
}; // TrackObjectPresentationLight
// ============================================================================