/****************************************************************************************************

		OrientedBBox.h
		Copyright: (c) 2001 Eovia Corp. All rights reserved.

		Author:	Pierre-Sylvain
		Date:	6/20/2006

****************************************************************************************************/

#ifndef __OrientedBBox__
#define __OrientedBBox__

#if CP_PRAGMA_ONCE
#pragma once
#endif

#include "Vector3Fwd.h"
#include "TransformsFwd.h"



class TOrientedBBox3D : public TMCObject
{
public:
	TOrientedBBox3D();
	TOrientedBBox3D(const TBBox3D& box);
	TOrientedBBox3D(const TTransform3D& transform, const TBBox3D& box);
	TOrientedBBox3D(const TTransform3D& transform, const TOrientedBBox3D& orientedBox);

	void Reset();

	inline void				SetCenter(const TVector3& center) { fCenter = center; }
	inline void				SetAxis(const int32 index,const TVector3& axis) { MCAssert(index >= 0 && index < 3); fAxis[index] = axis; }
	inline void				SetExtent(const int32 index,const real32 extent) { fExtent[index] = extent; }
	inline void				SetExtent(const TVector3& extent) { fExtent = extent; }

	inline const TVector3&	GetAxis(int32 index) const { MCAssert(index >= 0 && index < 3); return fAxis[index]; }
	inline const TVector3&	GetCenter() const { return fCenter; }
	inline const real		GetExtent(int32 i) const { return fExtent[i]; }
	inline const TVector3&	GetExtent() const { return fExtent; }

	// ****************************************************************************
	//								operator[]
	// 
	/// Returns one of the corners of the box (or its center)<BR>
	///	\code
	///     2_____6      Z
	///   3/|___7/|      ^
	///   | |   | |      |-->Y
	///   |/0---|/4     /
	///   1_____5      X
	/// \endcode
	/// 
	/// \param ii  the corner index. For values between 0 and 7 retruns the point shown in the diagram above.
	/// 
	TVector3				operator[](int32 ii) const;

	void					Transform(const TTransform3D& transform);
	TBBox3D					GetBBox() const;

protected:
	TVector3		fCenter;
	TVector3		fAxis[3];		// normalized axis
	TVector3		fExtent;		// size of the box
};



#endif
