//********************************************************************
// 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: Joint.cpp
//********************************************************************

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

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

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

	extern ISceneManager* SceneManager;
	extern NewtonWorld* nWorld;

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

extern "C"
{

	/*====================================================================
	Crea una union tipo bola*/

	DLL_EXPORT void* DLL_APIENTRY CreateJointBall(float X,float Y,float Z,float PX,float PY,float PZ,CBodySceneNode* B1,CBodySceneNode* B2)
	{
		CJointSceneNode* Joint = new CJointSceneNode(0,SceneManager,-1);
		Joint->addJointBall(X,Y,Z,PX,PY,PZ,B1->getBody(),B2->getBody());
		return (void*)Joint;
	}

	/*====================================================================
	Crea una union tipo bisagra*/

	DLL_EXPORT void* DLL_APIENTRY CreateJointHinge(float X,float Y,float Z,float DX,float DY,float DZ,CBodySceneNode* B1,CBodySceneNode* B2)
	{
		CJointSceneNode* Joint = new CJointSceneNode(0,SceneManager,-1);
		Joint->addJointHinge(X,Y,Z,DX,DY,DZ,B1->getBody(),B2->getBody());
		return (void*)Joint;
	}

	/*====================================================================
	Crea una union tipo deslizante*/

	DLL_EXPORT void* DLL_APIENTRY CreateJointSlider(float X,float Y,float Z,float DX,float DY,float DZ,CBodySceneNode* B1,CBodySceneNode* B2)
	{
		CJointSceneNode* Joint = new CJointSceneNode(0,SceneManager,-1);
		Joint->addJointSlider(X,Y,Z,DX,DY,DZ,B1->getBody(),B2->getBody());
		return (void*)Joint;
	}

	/*====================================================================
	Crea una union tipo tornillo*/

	DLL_EXPORT void* DLL_APIENTRY CreateJointCorkscrew(float X,float Y,float Z,float DX,float DY,float DZ,CBodySceneNode* B1,CBodySceneNode* B2)
	{
		CJointSceneNode* Joint = new CJointSceneNode(0,SceneManager,-1);
		Joint->addJointCorkscrew(X,Y,Z,DX,DY,DZ,B1->getBody(),B2->getBody());
		return (void*)Joint;
	}

	/*====================================================================
	Crea una union tipo jugador*/

	DLL_EXPORT void* DLL_APIENTRY CreateJointUpVector(float X,float Y,float Z,CBodySceneNode* B1)
	{
		CJointSceneNode* Joint = new CJointSceneNode(0,SceneManager,-1);
		Joint->addJointUpVector(X,Y,Z,B1->getBody());
		return (void*)Joint;
	}

	/*====================================================================
	Crea un cuerpo vacio*/

	DLL_EXPORT void DLL_APIENTRY JointCollisionState(CJointSceneNode* Joint,int State)
	{
		Joint->setCollisionState(State);
	}

	

	/*====================================================================
	Limite de movimiento de la union tipo bola*/

	DLL_EXPORT void DLL_APIENTRY BallLimits(CJointSceneNode* Joint,float MaxConeAngle,float MinTwistAngle,float MaxTwistAngle)
	{
		Joint->setBallLimits(MaxConeAngle,MinTwistAngle,MaxTwistAngle);
	}

	/*====================================================================
	Limite de movimiento de la union tipo bisagra*/

	DLL_EXPORT void DLL_APIENTRY HingeLimits(CJointSceneNode* Joint,float MinAngle,float MaxAngle)
	{
		Joint->setHingeLimits(MinAngle,MaxAngle);
	}

	/*====================================================================
	Limite de movimiento de la union tipo deslizante*/

	DLL_EXPORT void DLL_APIENTRY SliderLimits(CJointSceneNode* Joint,float MinAngle,float MaxAngle)
	{
		Joint->setSliderLimits(MinAngle,MaxAngle);
	}

	/*====================================================================
	Limite de movimiento lineal de la union tipo tornillo*/

	DLL_EXPORT void DLL_APIENTRY CorkScrewLinearLimits(CJointSceneNode* Joint,float MinDist,float MaxDist)
	{
		Joint->setCorkScrewLinearLimits(MinDist,MaxDist);
	}

	/*====================================================================
	Limite de movimiento angular de la union tipo tornillo*/

	DLL_EXPORT void DLL_APIENTRY CorkScrewAngularLimits(CJointSceneNode* Joint,float MinDist,float MaxDist)
	{
		Joint->setCorkScrewAngularLimits(MinDist,MaxDist);
	}

	
}