/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* E.P. Scene Graph
* Developed by:
*       - Eduardo Ribeiro (eribeiro @ tecgraf . puc-rio . br)
*       - Peter Dam (peter @ tecgraf . puc-rio . br)
* File: Vec4.h
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

#ifndef _EPSG_VEC4_
#define _EPSG_VEC4_

#include "EPSG/Vec3.h"

namespace EPSG
{
	template <typename T>
	class Vec4
	{
	public:
		/* [CONSTRUCTOR] */	Vec4();
		/* [CONSTRUCTOR] */	Vec4( T x, T y, T z, T w );

		void				operator=( const Vec4& rhs );
		void				operator=( const Vec3<T>& rhs );
		T&					operator[]( int index );
		
		T					x;
		T					y;
		T					z;
		T					w;

	private:
		T					invalid;
	};
}

/* TEMPLATE METHODS */
template <typename T>
EPSG::Vec4<T>::Vec4()
{
	x = y = z = w = 0;
}

template <typename T>
EPSG::Vec4<T>::Vec4( T x, T y, T z, T w )
{
	this->x = x;
	this->y = y;
	this->z = z;
	this->w = w;
}

/* OPERATORS */
template <typename T>
void EPSG::Vec4<T>::operator=( const Vec4& rhs )
{
	x = rhs.x;
	y = rhs.y;
	z = rhs.z;
	w = rhs.w;
}

template <typename T>
void EPSG::Vec4<T>::operator=( const Vec3<T>& rhs )
{
	x = rhs.x;
	y = rhs.y;
	z = rhs.z;
}

template <typename T>
T& EPSG::Vec4<T>::operator[]( int index )
{
	switch( index )
	{
	case 0:
		return x;
	case 1:
		return y;
	case 2:
		return z;
	case 3:
		return w;
	default:
		return invalid;
	}
}

#endif //_EPSG_VEC4_