//////////////////////////////////////////////////////////////////////
// Asura_Volume_Sphere												//
// SJL 19/11/07														//
// Copyright (C) 2007 Rebellion, All Rights Reserved.			    //
//																	//
// An oriented sphere volume class								    //
//////////////////////////////////////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
#pragma once
#endif   // ifdef ASURA_USE_PRAGMA_ONCE

#ifndef ASURA_VOLUME_SPHERE_H
#define ASURA_VOLUME_SPHERE_H

// Base header.
#include "Volume/Asura_Volume.h"


// Forward class declaration
class Asura_Chunk_Stream;

class Asura_Volume_Sphere : public Asura_Volume
{
	public:

		// Constructor / Destructor
		Asura_Volume_Sphere();
		virtual ~Asura_Volume_Sphere();

		// Public interface
		virtual bool Contains (const Asura_Vector_3& xPosition) const;
		virtual bool Overlaps (const Asura_Bounding_Box& xBB) const;

		// Pointer member access to facilitate generic tools use mainly
		virtual Asura_Quat* GetVolumeOrient() { return &m_xOrient; }
		Asura_Vector_3* GetPositionPtr() { return &m_xPosition; }
		float* GetRadiusPtr()	{ return &m_fRadius; }
		
		// Various copy and move functions.
		virtual void SetPosition(const Asura_Vector_3& xPos) { m_xPosition = xPos; }
		virtual void Displace(const Asura_Vector_3& xOffset) { m_xPosition+=xOffset; }
		virtual void RotateAbout(const Asura_Vector_3& xCentre, const Asura_Matrix_3x3& xOri);
		virtual Asura_Volume* Duplicate() const;
		void Copy(const Asura_Volume_Sphere* pxFrom);

		virtual void GetAABB(Asura_Bounding_Box& xBB) const;

#if !defined(ASURA_NO_DEBUG_OUTPUT)
		virtual void AddToLineSet(const u_int uARGB, Asura_DebugLineRender_LineSet& xLineSet) const;
#endif	//!defined(ASURA_NO_DEBUG_OUTPUT)

		#ifdef ASURA_TOOLS
		//Moves/rotates volumes that are part of an entity template
		virtual void ApplyChangesForTemplateInstance(class Tools_EntityTemplateInstance* pxInstance);
		#endif

		// load/save stream functions.
		virtual	void ReadFromChunkStream(Asura_Chunk_Stream& xStream);
		virtual	void WriteToChunkStream(Asura_Chunk_Stream& xStream) const;

	protected:

		// A Sphere is defined by a position (which represents the center of the sphere)
		// and a radius, this implementation also includes a an orientation, which isn't a lot of use
		// as far as a 'volume' definition is concerned but might be of use for other applications which 
		// could use these volume classes for other purposes.

		// Member variables
		Asura_Quat m_xOrient;
		Asura_Vector_3 m_xPosition;
		float m_fRadius;

	private:

		// load/save version number
		static const u_int s_uCHUNKVERSION;
};

#endif // ASURA_VOLUME_SPHERE_H

