#pragma once
#define MLR_MLR_WATER_HPP

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

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

namespace MidLevelRenderer {

	//##########################################################################
	//###### MLRIndexedTriMesh with  color no lighting w/ detail texture  ######
	//##########################################################################


	class MLR_Water:
		public MLR_I_C_DeT_TMesh
	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialization
	//
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

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

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

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

		void
			Save(Stuff::MemoryStream *stream);

		virtual void
			FindFacePlanes();

		int
			FindBackFace(const Point3D& u, const Normal3D& n);

		void
			Copy(
				MLR_I_C_TMesh*,
				MLRState detailState,
				Stuff::Scalar xOff,
				Stuff::Scalar yOff,
				Stuff::Scalar xFac,
				Stuff::Scalar yFac
			);

		bool
			Copy(MLR_I_C_DeT_PMesh*);


		static void
			SetSpecularValues(Stuff::Scalar fac, int pow, Scalar cutOff=0.0f);

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

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

		void
			LightMapLighting(MLRLight*);

		static void
			SetSunLight(Stuff::UnitVector3D& sl)
				{ sunLight = sl; }

//		virtual int
//			GetNumPasses();

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

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

		static Stuff::Scalar specMult;
		static int specPow;
		static Stuff::Scalar specCutoff;
	protected:
		static BYTE lookUpSpecular[256];


		Stuff::DynamicArrayOf<Vector2DScalar>
			dynamicUVs;

		static Stuff::UnitVector3D sunLight;


		static Stuff::DynamicArrayOf<Vector2DScalar> *detailTexCoords;	// Base address of texture coordinate list 
	};
}
