#pragma once
#define MLR_MLR_I_L_PMESH_HPP

#include <MLR\MLR.hpp>
#include <MLR\MLR_I_C_PMesh.hpp>

namespace MidLevelRenderer {

	class MLR_I_L_TMesh;

	//##########################################################################
	//###### MLRIndexedPolyMesh with color and lighting one texture layer  #####
	//##########################################################################


	class MLR_I_L_PMesh:
		public MLR_I_C_PMesh
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialization
	//
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

		static HGOSHEAP
			PrimitiveHeap;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors/Destructors
	//
	protected:
		MLR_I_L_PMesh(
			ClassData *class_data,
			Stuff::MemoryStream *stream,
			int version
		);
		~MLR_I_L_PMesh();

	public:
		MLR_I_L_PMesh(ClassData *class_data=MLR_I_L_PMesh::DefaultData);

		static MLR_I_L_PMesh*
			Make(
				Stuff::MemoryStream *stream,
				int version
			);

		void
			Save(Stuff::MemoryStream *stream);

	public:
		virtual void
			SetNormalData(
				const Stuff::Vector3D *array,
				int point_count
			);
		virtual void
			GetNormalData(
				const Stuff::Vector3D **array,
				int *point_count
			);

		virtual void
			SetColorData(
				const ColorType *array,
				int point_count
			);

		bool
			Copy(MLR_I_L_TMesh*);

		virtual void	Lighting(MLRLight* const*, int nrLights, BYTE=3);

		virtual int	
			TransformAndClip(Stuff::Matrix4D *, MLRClippingState, GOSVertexPool*, FogData*, DWORD=0xffffffff, bool=false);

		virtual void
			TransformNoClip(Stuff::Matrix4D*, GOSVertexPool*, FogData*, DWORD=0xffffffff, bool=false);

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

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

	protected:
		Stuff::ReadOnlyArrayOf<Stuff::Vector3D> normals;		// Base address of normal list 

		static Stuff::DynamicArrayOf<ColorType> *litColors;
		Stuff::ReadOnlyArrayOf<ColorType> *actualColors;

	};

//	MLR_I_L_PMesh*
//		CreateIndexedCube(Stuff::Scalar, Stuff::RGBAColor*, Stuff::Vector3D*, MLRState*);
	MLRShape*
		CreateIndexedIcosahedron_Color_Lit(
			IcoInfo&,
			MLRState*
		);

}
