#pragma once
#define MLR_MLRFOOTSTEP_HPP

#include <MLR\MLR.hpp>

extern DWORD gEnableFootSteps;

namespace MidLevelRenderer {

	class MLRClipper;

	struct FootStepInfo {
		FootStepInfo() { Reset(); }
		void Reset()  { shape = NULL; location = Stuff::Point3D::Identity; }
		MLRShape *shape;
		Stuff::Point3D location;
	};

	class MLRFootStep:
		public Stuff::RegisteredClass

	{
	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Initialization
	//
	public:
		static void
			InitializeClass();
		static void
			TerminateClass();
		static ClassData
			*DefaultData;

		static MLRFootStep
			*Instance;

	//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
	// Constructors/Destructors
	//
	protected:
		MLRFootStep(Stuff::MemoryStream *stream);

	public:
		MLRFootStep(int);

		~MLRFootStep();

		static MLRFootStep*
			Make(Stuff::MemoryStream *stream);

		FootStepInfo*
			AddAStep(MLRShape*, Stuff::Point3D& loc);

		bool
			ShowSteps()
				{ Check_Object(this); return gEnableFootSteps==1; }

		void 
			Draw(MLRClipper *theClipper, const Stuff::LinearMatrix4D& eye);

		void
			SetFadeOut(Stuff::Scalar start, Stuff::Scalar end)
				{ Check_Object(this); Verify(end>start); fadeOutStart = start; fadeOutEnd = end; oneOverFadeOut = 1.0f/(end-start); }

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

	protected:
		Stuff::DynamicArrayOf<FootStepInfo>
			theFootSteps;

		int firstStep, lastStep;

		Stuff::Scalar fadeOutStart, fadeOutEnd, oneOverFadeOut;
	};
}
