//------------------------------------------------------------------------------------
// irr::scene::IParticleSystemSceneNode wrappers (parent is ISceneNode)
//------------------------------------------------------------------------------------
extern "C" 
{

	void IrrScene_IParticleSystemSceneNode_addAffector(IParticleSystemSceneNode* node,IParticleAffector *affector)
	{
		if (node)
			node->addAffector(affector);
	}
	
	// you must call drop for this when done.
	IParticleEmitter* IrrScene_IParticleSystemSceneNode_createBoxEmitter(IParticleSystemSceneNode* node,
		aabbox3d<f32>* box=0,
		vector3df* direction=0,
		u32 minParticlesPerSecond=5, u32 maxParticlePerSecond=10,
		SColor* minStartColor=0,
		SColor* maxStartColor=0,
		u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, s32 maxAngleDegrees=0,
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0)
	{
		IParticleEmitter* pRetVal=0;
	
		bool delB=false,delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (box==0) {box=new aabbox3d<f32>(-10, 28,-10, 10, 30, 10); delB=true;}
		if (direction==0) {direction=new vector3df(0.0f, 0.03f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}
	
		if (node)
			pRetVal=node->createBoxEmitter(*box,*direction,minParticlesPerSecond,maxParticlePerSecond,*minStartColor,*maxStartColor,lifeTimeMin,lifeTimeMax,maxAngleDegrees, *minStartSize, *maxStartSize);
	
		if (delB) delete box;
		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;
	}
	
	IParticleAttractionAffector* IrrScene_IParticleSystemSceneNode_createAttractionAffector(IParticleSystemSceneNode* node,
		vector3df* point, f32 speed = 1.0f, bool attract = true,
		bool affectX = true, bool affectY = true, bool affectZ = true) {
		
		if (node) {
			return node->createAttractionAffector(*point, speed, attract, affectX, affectY, affectZ);
		} else return 0;
	}
	
	// you must call drop for this when done.
	IParticleFadeOutAffector* IrrScene_IParticleSystemSceneNode_createFadeOutParticleAffector(IParticleSystemSceneNode* node,SColor* targetColor=0,u32 timeNeededToFadeOut=1000)
	{
		IParticleFadeOutAffector* pRetVal=0;
	
		bool delT=false;
		if (!targetColor) {targetColor=new SColor(0, 0, 0, 0); delT=true;}
	
		if (node)
			pRetVal=node->createFadeOutParticleAffector(*targetColor,timeNeededToFadeOut);
	
		if (delT) delete targetColor;
	
		return pRetVal;
	}
	
	//  you must call drop for this when done.
	IParticleGravityAffector* IrrScene_IParticleSystemSceneNode_createGravityAffector(IParticleSystemSceneNode* node,vector3df* gravity=0,u32 timeForceLost=1000)
	{
		IParticleGravityAffector* pRetVal=0;
	
		bool delG=false;
		if (!gravity) {gravity=new vector3df(0.0f,-0.03f, 0.0f); delG=true;}
	
		if (node)
			pRetVal=node->createGravityAffector(*gravity,timeForceLost);
	
		if (delG) delete gravity;
	
		return pRetVal;
	}

	IParticleRotationAffector* IrrScene_IParticleSystemSceneNode_createRotationAffector(IParticleSystemSceneNode* node, vector3df* speed = 0, vector3df* pivotPoint = 0 ) 
	{
		IParticleRotationAffector* pRetVal=0;
	
		bool delS = false;
		bool delPP = false;
		if (!speed) {speed=new vector3df(5.0f,5.0f,5.0f); delS=true;}
		if (!pivotPoint) {pivotPoint=new vector3df(0.0f,0.0f,0.0f); delPP=true;}
	
		if (node) {
			pRetVal=node->createRotationAffector(*speed, *pivotPoint);
		}
	
		if (delS) delete speed;
		if (delPP) delete pivotPoint;
	
		return pRetVal;
	}
	
	// you must call drop for this when done.
	IParticleEmitter* IrrScene_IParticleSystemSceneNode_createPointEmitter(IParticleSystemSceneNode* node,
		vector3df* direction=0,
		u32 minParticlesPerSecond=5, u32 maxParticlePerSecond=10,
		SColor* minStartColor=0, 
		SColor* maxStartColor=0, 
		u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, s32 maxAngleDegrees=0, 
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0)
	{
		IParticleEmitter* pRetVal=0;
	
		bool delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (direction==0) {direction=new vector3df(0.0f, 0.03f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}
	
		if (node)
			pRetVal=node->createPointEmitter(*direction,minParticlesPerSecond,maxParticlePerSecond,*minStartColor,*maxStartColor,lifeTimeMin,lifeTimeMax,maxAngleDegrees, *minStartSize, *maxStartSize);
	
		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;
	}


	IParticleAnimatedMeshSceneNodeEmitter* IrrScene_IParticleSystemSceneNode_createAnimatedMeshSceneNodeEmitter(IParticleSystemSceneNode* node, 
		IAnimatedMeshSceneNode* am_node, bool useNormalDirection = true,
		vector3df* direction = 0, f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
		bool everyMeshVertex = false, u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
		SColor* minStartColor = 0, SColor* maxStartColor = 0,
		u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, s32 maxAngleDegrees = 0, 
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0) {
	
		IParticleAnimatedMeshSceneNodeEmitter* pRetVal=0;

		bool delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (direction==0) {direction=new vector3df(0.0f, 0.03f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}

		if (node) {
			pRetVal = node->createAnimatedMeshSceneNodeEmitter(
				am_node, useNormalDirection, 
				*direction, normalDirectionModifier, mbNumber,
				everyMeshVertex, minParticlesPerSecond, maxParticlesPerSecond, 
				*minStartColor, *maxStartColor, 
				lifeTimeMin, lifeTimeMax, maxAngleDegrees, *minStartSize, *maxStartSize
			);
		}

		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;	
	}

	IParticleCylinderEmitter* IrrScene_IParticleSystemSceneNode_createCylinderEmitter(IParticleSystemSceneNode* node, 
		vector3df* center, f32 radius, vector3df* normal, f32 length, bool outlineOnly = false,
		vector3df* direction = 0, u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
		SColor* minStartColor = 0, SColor* maxStartColor = 0,
		u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, s32 maxAngleDegrees = 0,
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0 ) {

		IParticleCylinderEmitter* pRetVal=0;

		bool delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (direction==0) {direction=new vector3df(0.0f, 0.03f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}

		if (node) {
			pRetVal = node->createCylinderEmitter(
				*center, radius, *normal, length, outlineOnly,
				*direction, minParticlesPerSecond, maxParticlesPerSecond, 
				*minStartColor, *maxStartColor, 
				lifeTimeMin, lifeTimeMax, maxAngleDegrees, *minStartSize, *maxStartSize
			);
		}

		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;	
	}
	
	IParticleMeshEmitter* IrrScene_IParticleSystemSceneNode_createMeshEmitter(IParticleSystemSceneNode* node, 
		IMesh* mesh, bool useNormalDirection = true, 
		vector3df* direction = 0, f32 normalDirectionModifier = 100.0f, s32 mbNumber = -1,
		bool everyMeshVertex = false, u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
		SColor* minStartColor = 0, SColor* maxStartColor = 0,
		u32 lifeTimeMin = 2000, u32 lifeTimeMax = 4000, s32 maxAngleDegrees = 0,
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0 ) {
	
		IParticleMeshEmitter* pRetVal=0;

		bool delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (direction==0) {direction=new vector3df(0.0f, 0.03f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}

		if (node) {
			pRetVal = node->createMeshEmitter(
				mesh, useNormalDirection, 
				*direction, normalDirectionModifier, mbNumber,
				everyMeshVertex, minParticlesPerSecond, maxParticlesPerSecond, 
				*minStartColor, *maxStartColor, 
				lifeTimeMin, lifeTimeMax, maxAngleDegrees, *minStartSize, *maxStartSize
			);
		}

		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;	
	}

	IParticleRingEmitter* IrrScene_IParticleSystemSceneNode_createRingEmitter(IParticleSystemSceneNode* node, 
		vector3df* center, f32 radius, f32 ringThickness, 
		vector3df* direction = 0, u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
		SColor* minStartColor = 0, SColor* maxStartColor = 0,
		u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, s32 maxAngleDegrees=0,
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0 ) {

		IParticleRingEmitter* pRetVal=0;

		bool delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (direction==0) {direction=new vector3df(0.0f, 0.3f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}

		if (node) {
			pRetVal = node->createRingEmitter(
				*center, radius, ringThickness, 
				*direction, minParticlesPerSecond, maxParticlesPerSecond, 
				*minStartColor, *maxStartColor, 
				lifeTimeMin, lifeTimeMax, maxAngleDegrees, *minStartSize, *maxStartSize
			);
		}

		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;	
	}

	IParticleSphereEmitter* IrrScene_IParticleSystemSceneNode_createSphereEmitter(IParticleSystemSceneNode* node, 
		vector3df* center, f32 radius,
		vector3df* direction = 0, u32 minParticlesPerSecond = 5, u32 maxParticlesPerSecond = 10,
		SColor* minStartColor = 0, SColor* maxStartColor = 0,
		u32 lifeTimeMin=2000, u32 lifeTimeMax=4000, s32 maxAngleDegrees=0,
		const core::dimension2df* minStartSize = 0, const core::dimension2df* maxStartSize = 0 ) {

		IParticleSphereEmitter* pRetVal=0;

		bool delD=false,delMin=false,delMax=false, delMinSize=false, delMaxSize=false;
		if (direction==0) {direction=new vector3df(0.0f, 0.3f, 0.0f); delD=true;}
		if (minStartColor==0) {minStartColor=new SColor(255, 0, 0, 0); delMin=true;}
		if (maxStartColor==0) {maxStartColor=new SColor(255, 255, 255, 255); delMax=true;}
		if (minStartSize==0) {minStartSize=new dimension2df(5.0f,5.0f); delMinSize=true;}
		if (maxStartSize==0) {maxStartSize=new dimension2df(5.0f,5.0f); delMaxSize=true;}

		if (node) {
			pRetVal = node->createSphereEmitter(
				*center, radius, 
				*direction, minParticlesPerSecond, maxParticlesPerSecond, 
				*minStartColor, *maxStartColor, 
				lifeTimeMin, lifeTimeMax, maxAngleDegrees, *minStartSize, *maxStartSize
			);
		}

		if (delD) delete direction;
		if (delMin) delete minStartColor;
		if (delMax) delete maxStartColor;
		if (delMinSize) delete minStartSize;
		if (delMaxSize) delete maxStartSize;
	
		return pRetVal;			
	}

	void IrrScene_IParticleSystemSceneNode_removeAllAffectors(IParticleSystemSceneNode* node)
	{
		if (node)
			node->removeAllAffectors();
	}
	
	void IrrScene_IParticleSystemSceneNode_setEmitter(IParticleSystemSceneNode* node,IParticleEmitter* emitter=0)
	{
		if (node)
			node->setEmitter(emitter);
	}

	IParticleEmitter* IrrScene_IParticleSystemSceneNode_getEmitter(IParticleSystemSceneNode* node)
	{
		if (node)
			return node->getEmitter();
		else return 0;
	}
	
	void IrrScene_IParticleSystemSceneNode_setParticlesAreGlobal(IParticleSystemSceneNode* node, bool global = true)
	{
		if (node)
			node->setParticlesAreGlobal(global);
	}
	
	void IrrScene_IParticleSystemSceneNode_setParticleSize(IParticleSystemSceneNode* node,dimension2d<f32>* size=0)
	{
	
		bool delS=false;
		if (!size) {size=new dimension2d<f32>(5.0f, 5.0f); delS=true;}
	
		if (node)
			node->setParticleSize(*size);
		
		if (delS) delete size;
	}

} // extern "C"