//------------------------------------------------------------------------------------
// irr::core::triangle3df wrappers
//------------------------------------------------------------------------------------
extern "C" 
{
	
	triangle3df* IrrCore_Triangle3df_new()
	{
		triangle3df* pRetVal=new triangle3df();
		return pRetVal;
	}

	// defaults: x,y,z=0.0f
	triangle3df* IrrCore_Triangle3df_newFromVals(f32 x1,f32 y1,f32 z1,f32 x2,f32 y2,f32 z2,f32 x3,f32 y3,f32 z3)
	{
		triangle3df* pRetVal=new triangle3df(vector3df(x1,y1,z1),vector3df(x2,y2,z2),vector3df(x3,y3,z3));
		return pRetVal;
	}
	
	triangle3df* IrrCore_Triangle3df_newFromVect(vector3df* vect1,vector3df* vect2,vector3df* vect3)
	{
		triangle3df* pRetVal=new triangle3df(*vect1,*vect2,*vect3);
		return pRetVal;
	}
	
	void IrrCore_Triangle3df_del(triangle3df* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	void IrrCore_Triangle3df_setFromVect(triangle3df* tri,vector3df* vect1,vector3df* vect2,vector3df* vect3)
	{
		if (tri>0)
			tri->set(*vect1,*vect2,*vect3);
	}
	
	// defaults: x,y,z=0.0f
	void IrrCore_Triangle3df_setFromVals(triangle3df* tri,f32 x1,f32 y1,f32 z1,f32 x2,f32 y2,f32 z2,f32 x3,f32 y3,f32 z3)
	{
		if (tri>0)
			tri->set(vector3df(x1,y1,z1),vector3df(x2,y2,z2),vector3df(x3,y3,z3));
	}
	
	bool IrrCore_Triangle3df_isTotalInsideBox (triangle3df* tri, aabbox3df* box)
	{
		bool lRetVal=false;
		
		if (tri>0)
			lRetVal=tri->isTotalInsideBox(*box);
	
		return lRetVal;
	}

	bool IrrCore_Triangle3df_isTotalOutsideBox(triangle3df* tri, const aabbox3df& box)	
	{
		if (tri)
			return tri->isTotalOutsideBox(box);
		else return false;
	}
	
	vector3df* IrrCore_Triangle3df_closestPointOnTriangle(triangle3df* tri,vector3df* p)
	{
		vector3df* pRetVal=0;
	
		if (tri>0)
			pRetVal=new vector3df(tri->closestPointOnTriangle(*p));
	
		return pRetVal;
	}
	
	bool IrrCore_Triangle3df_isPointInside(triangle3df* tri,vector3df* p)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->isPointInside(*p);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3df_isPointInsideFast(triangle3df* tri,vector3df* p)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->isPointInsideFast(*p);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3df_getIntersectionWithLimitedLine(triangle3df* tri,line3d<f32>* line,vector3df* outIntersection)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->getIntersectionWithLimitedLine(*line,*outIntersection);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3df_getIntersectionWithLine(triangle3df* tri,vector3df* linePoint,vector3df* lineVect,vector3df* outIntersection)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->getIntersectionWithLine(*linePoint,*lineVect,*outIntersection);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3df_getIntersectionOfPlaneWithLine(triangle3df* tri,vector3df* linePoint,vector3df* lineVect,vector3df* outIntersection)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->getIntersectionOfPlaneWithLine(*linePoint,*lineVect,*outIntersection);
	
		return lRetVal;
	}
	
	vector3df* IrrCore_Triangle3df_getNormal(triangle3df* tri)
	{
		vector3df* pRetVal=0;
	
		if (tri>0)
			pRetVal=new vector3df(tri->getNormal());
	
		return pRetVal;
	}
	
	bool IrrCore_Triangle3df_isFrontFacing(triangle3df* tri,vector3df* lookDirection) 
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->isFrontFacing(*lookDirection);
	
		return lRetVal;
	}
	
	plane3df* IrrCore_Triangle3df_getPlane(triangle3df* tri)
	{
		plane3df* pRetVal=0;
	
		if (tri>0)
			pRetVal=new plane3df(tri->getPlane());
	
		return pRetVal;
	}
	
	vector3df* IrrCore_Triangle3df_getPointA(triangle3df* tri)
	{
		vector3df* pRetVal=0;
	
		if (tri>0)
			pRetVal=&tri->pointA;
	
		return pRetVal;
	}
	
	vector3df* IrrCore_Triangle3df_getPointB(triangle3df* tri)
	{
		vector3df* pRetVal=0;
	
		if (tri>0)
			pRetVal=&tri->pointB;
	
		return pRetVal;
	}
	
	vector3df* IrrCore_Triangle3df_getPointC(triangle3df* tri)
	{
		vector3df* pRetVal=0;
	
		if (tri>0)
			pRetVal=&tri->pointC;
	
		return pRetVal;
	}
	
	void IrrCore_Triangle3df_setPointA(triangle3df* tri,vector3df* p)
	{
		if (tri>0)
			tri->pointA=*p;
	}
	
	void IrrCore_Triangle3df_setPointB(triangle3df* tri,vector3df* p)
	{
		if (tri>0)
			tri->pointB=*p;
	}
	
	void IrrCore_Triangle3df_setPointC(triangle3df* tri,vector3df* p)
	{
		if (tri>0)
			tri->pointC=*p;
	}
	
	bool IrrCore_Triangle3df_EqEq(triangle3df* tri,triangle3df* other) 
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=(*tri==*other);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3df_NotEq(triangle3df* tri,triangle3df* other) 
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=(*tri!=*other);
	
		return lRetVal;
	}
	
	f32 IrrCore_Triangle3df_getArea(triangle3df* tri)
	{
		if (tri)
			return tri->getArea();
		else return 0.0;
	}
}