//===========================================================================//
// File:	AnimInstance.hpp                                                 
// Project: MechWarrior 4
// Contents: 
//			This defines the iterator classes for animation.  The iterators
//	can walk keyframes forward and backward by an absolute or relitive
//  frame, percent, or time.  Got it?  
//---------------------------------------------------------------------------//
//   Date    Who  Modification                                               //
// --------  ---  ---------------------------------------------------------- //
// 07/01/98  JSE  Initial coding, 
//---------------------------------------------------------------------------//
// Copyright (C) 1998, Fasa Interactive, Inc.
// All Rights reserved worldwide
// This unpublished sourcecode is PROPRIETARY and CONFIDENTIAL
//===========================================================================//

#pragma once

namespace MW4Animation {

	class AnimInstanceManager;
	class AnimInstance;
}

#include <MW4\MW4AnimationSystem.hpp>
	

namespace MW4Animation {


//#############################################################################
//#######################       AnimInstanceManager          ##################
//#############################################################################
	
	class AnimInstanceManager:
		public Stuff::Plug
	{
	public:

		static 
			AnimInstanceManager *Anim_Instance_Manager;

		static void
			InitializeClass();
		
		static void
			TerminateClass();


		AnimInstanceManager();
		~AnimInstanceManager();

		void DeleteAnimations(void);

		Stuff::ChainOf<Stuff::PlugOf<AnimData*>*> animDataChains;
		
		AnimData *LoadAnim(const char *animation_name);
		

		// the idea here is that the animation engine knows nothing
		// about the application of the joints.  It just holds a pointer
		// to where you want the resulting information to go.
		// so for a MWVehicle you pass in the vehicle pointer as the user
		// data.  Then Vehicle::FindNamedChild(joint_name, user_data) gets
		// called.  We cast userdata back to the vehicle and then search 
		// for the pointer to the mover child with the appropriate name.
		// when we find it we return it or null for nothing.  It marks that
		// down and gives you an instance.  

		// it only loads an animdata once to save memory. 
		// It does not, however stop the creation of multiple instances
		// that is the responsibility of the owning vehicle

		typedef int
			(*UserDefinedSearchFunction)(
				const char *joint_name,
				void *user_data
			);

		AnimInstance *MakeAnimInstance(
			const char *animation_name, 
			UserDefinedSearchFunction search_func,
			void *user_data
		);


				
	};

//#############################################################################
//#######################       AnimInstance          #########################
//#############################################################################


	class AnimInstance:
		public Stuff::Plug
	{
	public:
		AnimInstance(
			AnimData *anim
		);
		~AnimInstance();

		AnimData *animData;
		int *jointToIndex;

	};
		

	
}
