#pragma once
#define MLR_MLRINDEXEDTRIANGLECLOUD_HPP

#if !defined(MLR_MLR_HPP)
	#include <MLR\MLR.hpp>
#endif

#if !defined(MLR_MLRTRIANGLECLOUD_HPP)
	#include <MLR\MLRTriangleCloud.hpp>
#endif

namespace MidLevelRenderer {

	//##########################################################################
	//##################    MLRIndexedTriangleCloud    #########################
	//##########################################################################


	class MLRIndexedTriangleCloud:
		public MLRTriangleCloud
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialization
	//
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors/Destructors
	//
	public:
		MLRIndexedTriangleCloud(int);
		~MLRIndexedTriangleCloud();

		void
			SetData(
				const int *tri_count,
				const int *point_count,
				const WORD *index_data,
				const Stuff::Point3D *point_data,
				const Stuff::RGBAColor *color_data,
				const Vector2DScalar *uv_data
			);

		void Draw (DrawEffectInformation*, GOSVertexPool*, MLRSorter*);
		int Draw (ToBeDrawnPrimitive*, MLRSorter*);

		int	Clip(MLRClippingState, GOSVertexPool*, bool);		

		virtual WORD*
			GetGOSIndices(int=0)
				{ Check_Object(this); return gos_indices; }

		int
			GetNumGOSIndices()
				{ Check_Object(this); return numGOSIndices; }

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Class Data Support
	//
	public:
		static ClassData
			*DefaultData;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Testing
	//
	public:
		void
			TestInstance() const;

	protected:
		const int *usedNrOfPoints;

		const WORD *index;
		const Vector2DScalar *texCoords;

		static Stuff::DynamicArrayOf<Vector2DScalar> *clipExtraTexCoords; // , Max_Number_Vertices_Per_Effect

		static Stuff::DynamicArrayOf<WORD> *clipExtraIndex; // , Max_Number_Vertices_Per_Effect

		static Stuff::DynamicArrayOf<BYTE>	*visibleIndexedVertices;

		WORD *gos_indices;
		WORD	numGOSIndices;
	};
}
