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


#ifndef	__MOTION_AUTOMATION_SOURCE__
#define	__MOTION_AUTOMATION_SOURCE__


		#include "automation/automation_source.h"


namespace GS {
	namespace Core { class Motion; }
	namespace Automation {
		struct SourceGroup;

		using Core::Motion;

/*!
	@short	Motion based automation source.
	@author	Emmanuel Julien (ejulien@gsworks.fr)
*/
class	MotionSource : public Source
{
		friend class Player;

protected:

		SourceGroup		*group;

		bool			active;
		Motion			*motion;

		Curve::LoopMode	loop_mode;
		Time			loop_start, loop_end;

public:

		/// Set loop mode.
virtual	void			SetLoopMode(Curve::LoopMode loop = Curve::Reset) { loop_mode = loop; }
		/// Set loop point.
virtual	void			SetLoop(const Time &start = Time::Inf, const Time &end = Time::Inf)
		{
			loop_start = start;
			loop_end = end;
		}

		void			Evaluate(Player &);
		bool			EvaluateRotation(Quaternion &);

		/// Is motion done.
		bool			IsDone() const;

		MotionSource(Motion *, SourceGroup * = 0);
};

	} // Automation
} // GS


#endif	// __MOTION_AUTOMATION_SOURCE__
