//------------------------------------------------------------------------------------
// irr::core::plane3df wrappers
//------------------------------------------------------------------------------------

extern "C" {

	plane3df* IrrCore_Plane3df_new()
	{
		return new plane3df();
	}

	plane3df* IrrCore_Plane3df_newFromVals(f32 px,f32 py,f32 pz,f32 nx,f32 ny,f32 nz)
	{
		return new plane3df(px,py,pz,nx,ny,nz);
	}

	plane3df* IrrCore_Plane3df_newFromPoints(vector3df* point1,vector3df* point2,vector3df* point3)
	{
		return new plane3df(*point1,*point2,*point3);
	}

	plane3df* IrrCore_Plane3df_newFromPlane(plane3df* other)
	{
		plane3df* plane = new plane3df();
		plane->setPlane(other->Normal,other->D);
		return plane;
	}

	plane3df* IrrCore_Plane3df_newFromPointNormal(vector3df* point, vector3df* normal)
	{
		return new plane3df(*point,*normal);
	}

	plane3df* IrrCore_Plane3df_newFromNormal(vector3df* normal, const f32 d)
	{
		return new plane3df(*normal, d);
	}

	void IrrCore_Plane3df_del(plane3df* pDel)
	{
		if (pDel>0)
			delete pDel;
		pDel=0;
	}

	void IrrCore_Plane3df_setPlaneFromPoints(plane3df* plane,vector3df* point1,vector3df* point2,vector3df* point3)
	{
		if (plane)
			plane->setPlane(*point1,*point2,*point3);
	}

	void IrrCore_Plane3df_setPlaneFromPointVect(plane3df* plane,vector3df* point,vector3df* vect)
	{
		if (plane)
			plane->setPlane(*point,*vect);
	}

	void IrrCore_Plane3df_setPlaneFromVectVal(plane3df* plane,vector3df* vect,f32 d)
	{
		if (plane)
			plane->setPlane(*vect,d);
	}

	bool IrrCore_Plane3df_getIntersectionWithLine (plane3df* plane,vector3df* linePoint,vector3df* lineVect,vector3df* outIntersection)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithLine(*linePoint,*lineVect,*outIntersection);

		return lRetVal;
	}

	bool IrrCore_Plane3df_getIntersectionWithLimitedLine(plane3df* plane,vector3df* linePoint1,vector3df* linePoint2,vector3df* outIntersection)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithLimitedLine(*linePoint1,*linePoint2,*outIntersection);

		return lRetVal;
	}

	s32 IrrCore_Plane3df_classifyPointRelation(plane3df* plane,vector3df* point)
	{
		s32 nRetVal=0;

		if (plane)
			nRetVal=plane->classifyPointRelation(*point);

		return nRetVal;
	}

	void IrrCore_Plane3df_recalculateD(plane3df* plane,vector3df* MPoint) 
	{
		if (plane)
			plane->recalculateD(*MPoint);
	}

	vector3df* IrrCore_Plane3df_getMemberPoint(plane3df* plane)
	{
		vector3df* pRetVal=0;
		
		if (plane)
			pRetVal=new vector3df(plane->getMemberPoint());

		return pRetVal;
	}

	bool IrrCore_Plane3df_existsIntersection(plane3df* plane,plane3df* other)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->existsIntersection(*other);

		return lRetVal;
	}

	bool IrrCore_Plane3df_getIntersectionWithPlane(plane3df* plane,plane3df* other,vector3df* outLinePoint,vector3df* outLineVect)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithPlane(*other,*outLinePoint,*outLineVect);

		return lRetVal;
	}

	bool IrrCore_Plane3df_getIntersectionWithPlanes(plane3df* plane,plane3df* o1,plane3df* o2,vector3df* outPoint)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->getIntersectionWithPlanes(*o1,*o2,*outPoint);

		return lRetVal;
	}

	bool IrrCore_Plane3df_isFrontFacing(plane3df* plane,vector3df* lookDirection)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=plane->isFrontFacing(*lookDirection);

		return lRetVal;
	}


	f32 IrrCore_Plane3df_getDistanceTo(plane3df* plane,vector3df* point)
	{
		f32 fRetVal=0.0f;
		
		if (plane)
			fRetVal=plane->getDistanceTo(*point);

		return fRetVal;
	}

	f32 IrrCore_Plane3df_getD(plane3df* plane)
	{
		f32 fRetVal=0.0f;
		
		if (plane)
			fRetVal=plane->D;

		return fRetVal;
	}

	vector3df* IrrCore_Plane3df_getNormal(plane3df* plane)
	{
		vector3df* pRetVal=0;

		if (plane)
			pRetVal=&plane->Normal;

		return pRetVal;
	}

	bool IrrCore_Plane3df_EqEq(plane3df* plane,plane3df* other)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=(*plane==*other);

		return lRetVal;
	}

	bool IrrCore_Plane3df_NotEq(plane3df* plane,plane3df* other)
	{
		bool lRetVal=false;
		if (plane)
			lRetVal=(*plane!=*other);

		return lRetVal;
	}
}