/***************************************************************************
*                                                                          *
*  Copyright (C) Golaem S.A.  All Rights Reserved.                         *
*                                                                          *
***************************************************************************/

#pragma once

#include <glmQuaternion.h>
#include <glmVector3.h>

namespace glm
{
	namespace crowdio
	{
		inline Quaternion operator+ (const Quaternion& quat0, const Quaternion& quat1) { return Quaternion(quat0.x + quat1.x, quat0.y + quat1.y, quat0.z + quat1.z, quat0.w + quat1.w); }

		// basded on code at http://rodolphe-vaillant.fr/?e=29
		class DualQuaternion
		{
		
		public:
		
			Quaternion _rotateQ;
			Quaternion _translateQ;

			DualQuaternion();
			
			DualQuaternion(const DualQuaternion& other);

			inline Quaternion* getQuatValues() { return &_rotateQ; }

			// use Quaternion::quaternionTranslationToDualQuaternion to initialize this
			DualQuaternion(const Quaternion& rotateQ, const Quaternion& translateQ);

			static DualQuaternion& identity();

			void normalizeSelf();

			// does not work for our usage, don't know why and won't investigate this until we need it. using code derived from skinmeshBatcher instead
			//// transform a point with the dual quaternion
			//Vector3 transform(const Vector3& p) const;
			//			
			//// rotate a normal with the dual quaternion
			//Vector3 rotate(const Vector3& v) const;

			//DualQuaternion operator+(const DualQuaternion& other) const;
			
			void operator+=(const DualQuaternion& other);

			DualQuaternion operator*(float scalar) const;			
		};		
	}
}

