/* -----------------------------------------------------------------------------
	GSFramework
	Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */


		#include "binding_helpers.h"
		#include "scene3d/scene.h"
		#include "scene3d/memitter.h"
		#include "core/engine.h"
		#include "core/graphic_resource_factory.h"

		using namespace GS::Core;
		using namespace GS::S3D;
		using namespace GS::Script;


SQInteger			EmitterSetParticleModel(HSQUIRRELVM vm)
{
	__SQ_GETSTART(2)
	__SQ_GETSAFEPTR(e, MEmitter, typetag_Emitter)
	__SQ_GETSAFEPTR(model, ParticleModel, typetag_ParticleModel)
	__SQ_GETEND
	if	(e->render_data.IsNull())
		return sq_throwerror(vm, "Emitter has no render data, you need to call ItemRenderSetup() first.");
	e->render_data->particle_model = model;
	__SQ_RETURN
}

SQInteger			EmitterSetBirthRateScale(HSQUIRRELVM vm)
{
	__SQ_GETSTART(2)
	__SQ_GETSAFEPTR(e, MEmitter, typetag_Emitter)
	__SQ_GETFLOAT(scale)
	__SQ_GETEND
	e->birth_rate_scale = scale;
	__SQ_RETURN
}
SQInteger			EmitterSetBirthSizeScale(HSQUIRRELVM vm)
{
	__SQ_GETSTART(2)
	__SQ_GETSAFEPTR(e, MEmitter, typetag_Emitter)
	__SQ_GETFLOAT(scale)
	__SQ_GETEND
	e->birth_size_scale = scale;
	__SQ_RETURN
}
SQInteger			EmitterSetBirthSpeedScale(HSQUIRRELVM vm)
{
	__SQ_GETSTART(2)
	__SQ_GETSAFEPTR(e, MEmitter, typetag_Emitter)
	__SQ_GETFLOAT(scale)
	__SQ_GETEND
	e->birth_speed_scale = scale;
	__SQ_RETURN
}
SQInteger			EmitterSetBirthOpacityScale(HSQUIRRELVM vm)
{
	__SQ_GETSTART(2)
	__SQ_GETSAFEPTR(e, MEmitter, typetag_Emitter)
	__SQ_GETFLOAT(scale)
	__SQ_GETEND
	e->birth_opacity_scale = scale;
	__SQ_RETURN
}

//--------------------------------------------------------
void				RegisterEmitterBinding(HSQUIRRELVM vm)
//--------------------------------------------------------
{
/*#
	Topic: Emitter
	Type: Emitter
	Type: ParticleModel
#*/

/*#
	Section: EmitterSettings
	Desc: Emitter functions
#*/
	/*#
		Func: EmitterSetParticleModel
		Proto: void:Emitter,ParticleModel
		Desc: Set the emitter particle model.
	#*/
	sq_register(vm, EmitterSetParticleModel, "EmitterSetParticleModel", _SC(".xx"));

	/*#
		Func: EmitterSetBirthRateScale
		Proto: void:Emitter,float scale
		Desc: Set the emitter birth rate scale.
	#*/
	sq_register(vm, EmitterSetBirthRateScale, "EmitterSetBirthRateScale", _SC(".xn"));
	/*#
		Func: EmitterSetBirthSizeScale
		Proto: void:Emitter,float scale
		Desc: Set the emitter birth size scale.
	#*/
	sq_register(vm, EmitterSetBirthSizeScale, "EmitterSetBirthSizeScale", _SC(".xn"));
	/*#
		Func: EmitterSetBirthSpeedScale
		Proto: void:Emitter,float scale
		Desc: Set the emitter birth speed scale.
	#*/
	sq_register(vm, EmitterSetBirthSpeedScale, "EmitterSetBirthSpeedScale", _SC(".xn"));
	/*#
		Func: EmitterSetBirthOpacityScale
		Proto: void:Emitter,float scale
		Desc: Set the emitter birth opacity scale.
	#*/
	sq_register(vm, EmitterSetBirthOpacityScale, "EmitterSetBirthOpacityScale", _SC(".xn"));
}
