//********************************************************************
// This source file is part of Ninfa3D Engine
// 
// Copyright (C) 2008-2009 Viz_fuerte.
// All rights reserved.
// 
// LIMITED WARRANTY
// This software is provided "as-is", without any express or implied warranty.
// In no event shall the author be held liable for any damages arising from the use of this software.
// This is a contract. By accepting the Ninfa3D Engine (the SOFTWARE), 
// you (either an individual or a single entity, the LICENSEE) accept the terms and conditions of this licensing agreement.
// 
// If the LICENSEE does not accept the terms and conditions, then LICENSEE must not accept the SOFTWARE.
// If at a later time the LICENSEE decides not to continue licensing the SOFTWARE under these terms and 
// conditions, then the LICENSEE must delete permanently all files constituting the SOFTWARE.
//
// File: Vehicle.cpp
//********************************************************************

/*--------------------------------------------------------------------
Includos*/

	#include "..\..\Header Files\Ninfa3D.h"
	#include "..\..\Codes\CVehicleSceneNode.h"
	#include "..\..\Codes\CBodySceneNode.h"

/*--------------------------------------------------------------------
Variables externas*/

	extern IrrlichtDevice* device;
	extern ISceneManager* SceneManager;
	extern NewtonWorld* nWorld;

/*--------------------------------------------------------------------
Declaracion global de funciones*/

extern "C"
{

/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	VEHICLE
*/

	/*====================================================================
	Crea un vehiculo.*/

	DLL_EXPORT void* DLL_APIENTRY CreateVehicle(float DX,float DY,float DZ,CBodySceneNode* CarBody)
	{
		CVehicleSceneNode* Car = new CVehicleSceneNode(0,SceneManager,-1);
		vector3df pos = vector3df(0.0f,0.0f,0.0f);
		Car->addVehicle(pos.X,pos.Y,pos.Z,DX,DY,DZ,CarBody->getBody());
		return (void*)Car;
	}

	/*====================================================================
	Devuelve la velocidad del vehiculo.*/

	DLL_EXPORT float DLL_APIENTRY VehicleSpeed(CVehicleSceneNode* Car)
	{
		return Car->getVehicleSpeed();
	}

/*:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	TIRE
*/

	/*====================================================================
	Crea una rueda.*/

	DLL_EXPORT void DLL_APIENTRY AddTire(CVehicleSceneNode* Car,void* UserData,float X,float Y,float Z,float Mass,float Radius,float Width,float Friction,float SLenght,float SConst,float SDamper)
	{
		Car->addTire(UserData,X,Y,Z,Mass,Radius,Width,Friction,SLenght,SConst,SDamper);
	}

	/*====================================================================
	Aplica el freno a la rueda*/

	DLL_EXPORT void DLL_APIENTRY ApplyBrake(CVehicleSceneNode* Car,int Index,float Value)
	{
		Car->setApplyBrake(Index,Value);
	}

	/*====================================================================
	Aplica la direccion*/

	DLL_EXPORT void DLL_APIENTRY ApplySteering(CVehicleSceneNode* Car,int Index,float Value)
	{
		Car->setApplySteering(Index,Value);
	}

	//DLL_EXPORT void DLL_APIENTRY ApplySteering(CVehicleSceneNode* Car,int Index,float Value1,float Value2)
	//{
	//	Car->setApplySteering(Index,Value1,Value2);
	//}


	/*====================================================================
	Aplica fuerza de giro*/

	DLL_EXPORT void DLL_APIENTRY ApplyTorque(CVehicleSceneNode* Car,int Index,float Value)
	{
		Car->setApplyTorque(Index,Value);
	}

}