//------------------------------------------------------------------------------------
// irr::core::triangle3di wrappers
//------------------------------------------------------------------------------------

extern "C" 
{

	triangle3di* IrrCore_Triangle3di_new()
	{
		triangle3di* pRetVal=new triangle3di();
		return pRetVal;
	}

	// defaults: x,y,z=0
	triangle3di* IrrCore_Triangle3di_newFromVals(s32 x1,s32 y1,s32 z1,s32 x2,s32 y2,s32 z2,s32 x3,s32 y3,s32 z3)
	{
		triangle3di* pRetVal=new triangle3di(vector3di(x1,y1,z1),vector3di(x2,y2,z2),vector3di(x3,y3,z3));
		return pRetVal;
	}
	
	triangle3di* IrrCore_Triangle3di_newFromVect(vector3di* vect1,vector3di* vect2,vector3di* vect3)
	{
		triangle3di* pRetVal=new triangle3di(*vect1,*vect2,*vect3);
		return pRetVal;
	}
	
	void IrrCore_Triangle3di_del(triangle3di* del)
	{
		if (del)
			delete del;
			
		del=0;
	}
	
	void IrrCore_Triangle3di_setFromVect(triangle3di* tri,vector3di* vect1,vector3di* vect2,vector3di* vect3)
	{
		if (tri>0)
			tri->set(*vect1,*vect2,*vect3);
	}
	
	// defaults: x,y,z=0.0f
	triangle3di* IrrCore_Triangle3di_setFromVals(triangle3di* tri,s32 x1,s32 y1,s32 z1,s32 x2,s32 y2,s32 z2,s32 x3,s32 y3,s32 z3)
	{
		if (tri>0)
			tri->set(vector3di(x1,y1,z1),vector3di(x2,y2,z2),vector3di(x3,y3,z3));
	}
	
	bool IrrCore_Triangle3di_isPointInside(triangle3di* tri,vector3di* p)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->isPointInside(*p);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3di_isPointInsideFast(triangle3di* tri,vector3di* p)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->isPointInsideFast(*p);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3di_getIntersectionWithLimitedLine(triangle3di* tri,line3d<s32>* line,vector3di* outIntersection)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->getIntersectionWithLimitedLine(*line,*outIntersection);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3di_getIntersectionWithLine(triangle3di* tri,vector3di* linePoint,vector3di* lineVect,vector3di* outIntersection)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->getIntersectionWithLine(*linePoint,*lineVect,*outIntersection);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3di_getIntersectionOfPlaneWithLine(triangle3di* tri,vector3di* linePoint,vector3di* lineVect,vector3di* outIntersection)
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->getIntersectionOfPlaneWithLine(*linePoint,*lineVect,*outIntersection);
	
		return lRetVal;
	}
	
	vector3di* IrrCore_Triangle3di_getNormal(triangle3di* tri)
	{
		vector3di* pRetVal=0;
	
		if (tri>0)
			pRetVal=new vector3di(tri->getNormal());
	
		return pRetVal;
	}
	
	bool IrrCore_Triangle3di_isFrontFacing(triangle3di* tri,vector3di* lookDirection) 
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=tri->isFrontFacing(*lookDirection);
	
		return lRetVal;
	}
	
	plane3di* IrrCore_Triangle3di_getPlane(triangle3di* tri)
	{
		plane3di* pRetVal=0;
	
		if (tri>0)
			pRetVal=new plane3di(tri->getPlane());
	
		return pRetVal;
	}
	
	vector3di* IrrCore_Triangle3di_getPointA(triangle3di* tri)
	{
		vector3di* pRetVal=0;
	
		if (tri>0)
			pRetVal=&tri->pointA;
	
		return pRetVal;
	}
	
	vector3di* IrrCore_Triangle3di_getPointB(triangle3di* tri)
	{
		vector3di* pRetVal=0;
	
		if (tri>0)
			pRetVal=&tri->pointB;
	
		return pRetVal;
	}
	
	vector3di* IrrCore_Triangle3di_getPointC(triangle3di* tri)
	{
		vector3di* pRetVal=0;
	
		if (tri>0)
			pRetVal=&tri->pointC;
	
		return pRetVal;
	}
	
	void IrrCore_Triangle3di_setPointA(triangle3di* tri,vector3di* p)
	{
		if (tri>0)
			tri->pointA=*p;
	}
	
	void IrrCore_Triangle3di_setPointB(triangle3di* tri,vector3di* p)
	{
		if (tri>0)
			tri->pointB=*p;
	}
	
	void IrrCore_Triangle3di_setPointC(triangle3di* tri,vector3di* p)
	{
		if (tri>0)
			tri->pointC=*p;
	}
	
	bool IrrCore_Triangle3di_EqEq(triangle3di* tri,triangle3di* other) 
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=(*tri==*other);
	
		return lRetVal;
	}
	
	bool IrrCore_Triangle3di_NotEq(triangle3di* tri,triangle3di* other) 
	{
		bool lRetVal=false;
	
		if (tri>0)
			lRetVal=(*tri!=*other);
	
		return lRetVal;
	}
	
	
	bool IrrCore_Triangle3di_isTotalInsideBox(triangle3di* tri, aabbox3di* box)
	{
		bool lRetVal=false;
		
		if (tri>0)
			lRetVal=tri->isTotalInsideBox(*box);
	
		return lRetVal;
	}

	bool IrrCore_Triangle3di_isTotalOutsideBox(triangle3di* tri, const aabbox3di& box)	
	{
		if (tri)
			return tri->isTotalOutsideBox(box);
		else return false;
	}

	vector3di* IrrCore_Triangle3di_closestPointOnTriangle(triangle3di* tri,vector3di* p)
	{
		vector3di* pRetVal=0;
	
		if (tri>0)
			pRetVal=new vector3di(tri->closestPointOnTriangle(*p));
	
		return pRetVal;
	}

	s32 IrrCore_Triangle3di_getArea(triangle3di* tri)
	{
		if (tri)
			return tri->getArea();
		else return 0;
	}
}