#ifndef DEF_MOTIONS
 #define DEF_MOTIONS
//------------------------------------------//
//	TKA4 CEngine and basis Graph classes	//
//				19. 04. 2007				//
//------------------------------------------//


//--- Includes
#include <windows.h>
#include <stdio.h>
#include <math.h>

#include "TX_Engine.h"
//=== Includes 


//--- Pragma 
#pragma warning(disable:4305) 
//=== Pragma 

//--- Defines
#define H_STEP  3.0f
//=== Defines


//---------------------------------------------------------------------


//---  Camera Gradual Motion  ---//
class txObj_CameraGradualMotion : public txObject {
private :	
	
	//--- helper subroutine
	inline void interpolate(GLfloat *cot, GLfloat *ct) {
		for (int i = 0; i<3; i++)
			cot[i] = cot[i] + (ct[i]-cot[i])/H_STEP; 
	};

public :

	//--- txObj :: Execute Forward
	virtual void Execute_Forward()
	{
		GLTFrame *co = &World -> CameraOld, *c = &World -> Camera;

		//if (World->World_Time - local_time > H_STEP+1)

		interpolate(co -> vForward, c -> vForward);
		interpolate(co -> vLocation, c -> vLocation);
		interpolate(co -> vUp, c -> vUp);
		

		gltApplyCameraTransform(&World->CameraOld);	
	}

};


//--- tx Collision Map ---//
class  txObj_CollisionActor : public txObject {
public :
	txcSimple *current;
	
	txObj_CollisionActor() {};

	virtual void Execute_Init() {
	}

	//--- txObj_ :: Execute Forward
	virtual void Execute_Forward()
	{
		//GLTVector3 res;

		/*res[0] = World->Camera.vLocation[0] + World->Camera.vForward[0];
		res[1] = World->Camera.vLocation[1] + World->Camera.vForward[1];
		res[2] = World->Camera.vLocation[2] + World->Camera.vForward[2];*/
		
		for (current = World->Collision.first; current != NULL; current = current -> next)
			if (! current->IsIn( World->Camera.vLocation ) )
			{
				World->Camera = World->CameraOld;
				break;
			}
	}
};

//------------------------- :: Functions :: ---------------------------


#endif



