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


		#include "scene3d/item_automated_property_provider.h"
		#include "core/item.h"

		using GS::Quaternion;
		using namespace GS::Core;
		using namespace GS::S3D::Automation;


//------------------------------------------------------------------------------
bool				ItemPropertyProvider::GetProperty(MotionChannel::Type type, float &v)
{
	switch (type)
	{
		case MotionChannel::XPos:	v = item->GetPosition().x;	return true;
		case MotionChannel::YPos:	v = item->GetPosition().y;	return true;
		case MotionChannel::ZPos:	v = item->GetPosition().z;	return true;
		case MotionChannel::XRot:	v = item->GetRotation().x;	return true;
		case MotionChannel::YRot:	v = item->GetRotation().y;	return true;
		case MotionChannel::ZRot:	v = item->GetRotation().z;	return true;
		case MotionChannel::XScl:	v = item->GetScale().x;		return true;
		case MotionChannel::YScl:	v = item->GetScale().y;		return true;
		case MotionChannel::ZScl:	v = item->GetScale().z;		return true;
	}
	return false;
}
bool				ItemPropertyProvider::SetProperty(MotionChannel::Type type, float v)
{
	Vector4 t;
	switch (type)
	{
		case MotionChannel::XPos:	t = item->GetPosition(); t.x = v; item->SetPosition(t);	return true;
		case MotionChannel::YPos:	t = item->GetPosition(); t.y = v; item->SetPosition(t);	return true;
		case MotionChannel::ZPos:	t = item->GetPosition(); t.z = v; item->SetPosition(t);	return true;
		case MotionChannel::XRot:	t = item->GetRotation(); t.x = v; item->SetRotation(t);	return true;
		case MotionChannel::YRot:	t = item->GetRotation(); t.y = v; item->SetRotation(t);	return true;
		case MotionChannel::ZRot:	t = item->GetRotation(); t.z = v; item->SetRotation(t);	return true;
		case MotionChannel::XScl:	t = item->GetScale(); t.x = v; item->SetScale(t);		return true;
		case MotionChannel::YScl:	t = item->GetScale(); t.y = v; item->SetScale(t);		return true;
		case MotionChannel::ZScl:	t = item->GetScale(); t.z = v; item->SetScale(t);		return true;
	}
	return false;
}
Quaternion			ItemPropertyProvider::GetRotation() const
{
	const Vector4 &e = item->GetRotation();
	return Quaternion::FromEuler(e.x, e.y, e.z, item->GetRotationOrder());
}
bool				ItemPropertyProvider::SetRotation(const Quaternion &q)
{
	item->SetRotation(q);
	return true;
}
//------------------------------------------------------------------------------
