//------------------------------------------------------------------------------------
// irr::scene::ITerrainSceneNode wrappers (based on ISceneNode)
//------------------------------------------------------------------------------------

extern "C" 
{

	aabbox3d<f32>* IrrScene_ITerrainSceneNode_getBoundingBoxFromPatch(ITerrainSceneNode* sn,s32 patchX,s32 patchZ)
	{
		if (sn)
			return new aabbox3d<f32>(sn->getBoundingBox(patchX,patchZ));
		else return 0;
	}
	
	aabbox3d<f32>* IrrScene_ITerrainSceneNode_getBoundingBox(ITerrainSceneNode* sn)
	{
		if (sn)
			return new aabbox3d<f32>(sn->getBoundingBox());
		else return 0;
	}
	
	s32 IrrScene_ITerrainSceneNode_getCurrentLODOfPatches(ITerrainSceneNode* sn,array<s32>* LODs)
	{
		if (sn)
			return sn->getCurrentLODOfPatches(*LODs);
		else return 0;
	}
	
	u32 IrrScene_ITerrainSceneNode_getIndexCount(ITerrainSceneNode* sn)
	{
		if (sn)
			return sn->getIndexCount();
		else return 0;
	}
	
	// note, this populates outIndicies
	s32 IrrScene_ITerrainSceneNode_getIndicesForPatch(ITerrainSceneNode* sn,array<u32>* outIndicies,s32 patchX,s32 patchZ,s32 LOD=0)
	{
		if (sn)
			return sn->getIndicesForPatch(*outIndicies,patchX,patchZ,LOD);
		else return 0;
	}
	
	// do not delete
	IMesh* IrrScene_ITerrainSceneNode_getMesh(ITerrainSceneNode* sn)
	{
		if (sn)
			return sn->getMesh();
		else return 0;
	}
	
	void IrrScene_ITerrainSceneNode_getMeshBufferForLOD(ITerrainSceneNode* sn, IDynamicMeshBuffer* mb, s32 LOD = 0)
	{
		if (sn)
			sn->getMeshBufferForLOD(*mb, LOD);
	}
	
	void IrrScene_ITerrainSceneNode_setLODOfPatch(ITerrainSceneNode* sn,s32 patchX,s32 patchZ,s32 LOD = 0)
	{
		if (sn)
			sn->setLODOfPatch(patchX,patchZ,LOD);
	}
	
	
	vector3df* IrrScene_ITerrainSceneNode_getTerrainCenter(ITerrainSceneNode* sn)
	{
		if (sn)
			return new vector3df(sn->getTerrainCenter());
		else return 0;
	}
	
	bool IrrScene_ITerrainSceneNode_overrideLODDistance(ITerrainSceneNode* sn,s32 LOD,f64 newDistance)
	{
		if (sn)
			return sn->overrideLODDistance(LOD,newDistance);
		else return false;
	}
	
	void IrrScene_ITerrainSceneNode_scaleTexture(ITerrainSceneNode* sn,f32 scale=1.0f,f32 scale2 = 0.0f)
	{
		if (sn)
			sn->scaleTexture(scale,scale2);
	}
	
	void IrrScene_ITerrainSceneNode_setCameraMovementDelta(ITerrainSceneNode* sn,f32 delta)
	{
		if (sn)
			sn->setCameraMovementDelta(delta);
	}
	
	void IrrScene_ITerrainSceneNode_setCameraRotationDelta(ITerrainSceneNode* sn,f32 delta)
	{
		if (sn)
			sn->setCameraRotationDelta(delta);
	}
	
	void IrrScene_ITerrainSceneNode_setDynamicSelectorUpdate(ITerrainSceneNode* sn,bool bVal)
	{
		if (sn)
			sn->setDynamicSelectorUpdate(bVal);
	}
	
	f32 IrrScene_ITerrainSceneNode_getHeight(ITerrainSceneNode* sn, f32 x, f32 y )
	{
		if (sn)
			return sn->getHeight(x,y);
		else return -1;
	}

	bool IrrScene_ITerrainSceneNode_loadHeightMap(ITerrainSceneNode* sn, IReadFile* file, SColor* vertexColor = 0, s32 smoothFactor=0)
	{
		if (sn)
			return sn->loadHeightMap(file, (vertexColor ? *vertexColor : video::SColor(255,255,255,255)), smoothFactor);
		else return false;
	}
	
	bool IrrScene_ITerrainSceneNode_loadHeightMapRAW(ITerrainSceneNode* sn, IReadFile* file, s32 bitsPerPixel=16, bool signedData=false, bool floatVals=false, s32 width=0, SColor* vertexColor = 0, s32 smoothFactor=0)
	{
		if (sn)
			return sn->loadHeightMapRAW(file, bitsPerPixel, signedData, floatVals, width, (vertexColor ? *vertexColor : video::SColor(255,255,255,255)), smoothFactor);
		else return false;
	}
}
	
