#pragma once
#define MLR_MLRCULTURSHAPE_HPP

#include <MLR\MLRShape.hpp>
#include <MLR\MLR_I_C_TMesh.hpp>

namespace MidLevelRenderer {

	struct MLRCultural {
		Stuff::Point3D loc;
		BYTE yaw;
		BYTE type;
	};

	//##########################################################################
	//#######################    MLRCulturShape    #############################
	//##########################################################################

	class MLRCulturShape :
		public MLRShape
	{

		friend class MLRClipper;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialization
	//
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();

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

	public:
		MLRCulturShape();

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

		void
			Save(Stuff::MemoryStream *stream);

		void
			SetCenterInWorld(Stuff::Scalar ciwx, Stuff::Scalar ciwz, Stuff::Scalar r)
				{ Check_Object(this); centerInWorldX = ciwx; centerInWorldZ = ciwz; radius = r; }

		void
			FadeValue(Stuff::Scalar start, Stuff::Scalar end)
				{ Check_Object(this); fadeOutStart = start; fadeOutEnd = end;}

		void
			AssignCulturalData(MLRCultural *data, int count)
				{ Check_Object(this); culturals.AssignData(data, count); }

		static MLRShape*
			culturalRevolution;

		static void
			IsDayTime(bool b=true)
				{ isDayTime = b; }
				
		static void
			SetColor(Stuff::RGBAColor day, Stuff::RGBAColor night)
				{ dayColor = day; nightColor = night; }

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

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

	protected:
		static Stuff::RGBAColor
			dayColor, nightColor;

		static bool
			isDayTime;

		Stuff::Scalar
			centerInWorldX, centerInWorldZ, radius;

		Stuff::Scalar
			fadeOutStart, fadeOutEnd;

		Stuff::ReadOnlyArrayOf<MLRCultural> 
			culturals;

		static int lastUsedMesh, lastUsedVertex, nrOfNaturalMeshes;

		static Stuff::DynamicArrayOf<MLR_I_C_TMesh*> *theNaturals;
		static Stuff::DynamicArrayOf<Stuff::Point3D> *theNaturalCoords;
		static Stuff::DynamicArrayOf<Vector2DScalar> *theNaturalTexCoords;
		static Stuff::DynamicArrayOf<BYTE> *theNaturalIndicies;
		static Stuff::DynamicArrayOf<ColorType> *theNaturalColors;
	};

}
