#include "RainGenerator.h"

#include <math.h>
#include <stdlib.h>

#include "MemoryManager/DebugNew.h"


using namespace ParticleSystem;

RainGenerator::RainGenerator(float size){
	this->size = size;
	maxGeneration = 15;
	this->generationDelay = 0.005f;
	this->previousTime = 0.0f;
	loop = true;
}

RainGenerator::~RainGenerator(void){
}


void RainGenerator::generate(ParticleEngine::Particle * particle){
	if (canGenerate()){
		float deltaX = cos((float)rand());
		float deltaZ = cos((float)rand());
		float scale = cos((float)rand());
		float posScale = scale*size;
		particle->pos[0] = pos[0] + deltaX*posScale;
		particle->pos[1] = pos[1];
		particle->pos[2] = pos[2] + deltaZ*posScale;
		particle->direction[0] = 0;
		particle->direction[1] = -50;
		particle->direction[2] = 0;
		particle->life = 0;
		particle->maxLife = (cos((float)rand())+1.0f)  +2;
		particle->beginCouleur[0] = 0.5f;
		particle->beginCouleur[1] = 0.5f;
		particle->beginCouleur[2] = 0.9f;
		particle->beginCouleur[3] = 0.0f;
		particle->endCouleur[0] = 0.2f;
		particle->endCouleur[1] = 0.2f;
		particle->endCouleur[2] = 0.9f;
		particle->endCouleur[3] = 0.5f;
		particle->masse = 3.0f;
		particle->size = 1;
		generation++;
	}
}
