
extern "C" 
{

//------------------------------------------------------------------------------------
// irr::scene::ITriangleSelector wrappers
//------------------------------------------------------------------------------------

	s32 IrrScene_ITriangleSelector_getTriangleCount(ITriangleSelector* ts)
	{
		if (ts)
			return ts->getTriangleCount();
		else return 0;
	}
	
	s32 IrrScene_ITriangleSelector_getTriangles(ITriangleSelector* ts,triangle3df** triPtr,matrix4* transform=0)
	{		
		if (ts) {
			
			s32 triCount = ts->getTriangleCount();						
			s32 outTriangleCount = 0;

			triangle3df temp[triCount];
			
			ts->getTriangles(temp,triCount,outTriangleCount,transform);			
			
			for (int i=0; i<outTriangleCount; i++) {
				triangle3df* tempTri = new triangle3df(temp[i]);
				triPtr[i] = tempTri;
			}
								
			return outTriangleCount;
		} else return 0;
	}
	
	s32 IrrScene_ITriangleSelector_getTrianglesOnLine(ITriangleSelector* ts,triangle3df** triPtr,line3d<f32>* line,matrix4* transform=0)
	{
		if (ts) {
			s32 triCount = ts->getTriangleCount();						
			s32 outTriangleCount = 0;

			triangle3df temp[triCount];

			ts->getTriangles(temp,triCount,outTriangleCount,*line,transform);

			// if we received some triangles back, populate the return array
			for (int i=0; i<outTriangleCount; i++) {
				triangle3df* tempTri = new triangle3df(temp[i]);
				triPtr[i] = tempTri;
			}
								
			return outTriangleCount;
		}
	}
	
	s32 IrrScene_ITriangleSelector_getTrianglesInBox(ITriangleSelector* ts,triangle3df** triPtr,aabbox3d<f32>* box,matrix4* transform=0)
	{
		if (ts) {
			s32 triCount = ts->getTriangleCount();						
			s32 outTriangleCount = 0;

			triangle3df temp[triCount];
			
			ts->getTriangles(temp,triCount,outTriangleCount,*box,transform);

			for (int i=0; i<outTriangleCount; i++) {
				triangle3df* tempTri = new triangle3df(temp[i]);
				triPtr[i] = tempTri;
			}
								
			return outTriangleCount;
		}
	}

	const ISceneNode* IrrScene_ITriangleSelector_getSceneNodeForTriangle(ITriangleSelector* ts, u32 triangleIndex) 
	{
		if (ts)
			return ts->getSceneNodeForTriangle(triangleIndex);
		else return 0;
	}

	bool IrrScene_ITriangleSelector_drop(ITriangleSelector* unk)
	{
		if (unk)
			return unk->drop();
		else return 0;
	}
	
	const c8* IrrScene_ITriangleSelector_getDebugName(ITriangleSelector* unk)
	{
		if (unk)
			return unk->getDebugName();
		else return "";
	}
	
	void IrrScene_ITriangleSelector_grab(ITriangleSelector* unk)
	{
		if (unk)
			unk->grab();
	}
}




