#include "SmokeGenerator.h"

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

#include "MemoryManager/DebugNew.h"

using namespace ParticleSystem;

SmokeGenerator::SmokeGenerator(float size){
	this->size = size;
	maxGeneration = 10;
	this->generationDelay = 0.005f;
	this->previousTime = 0.0f;
	loop = true;

}

SmokeGenerator::~SmokeGenerator(void){
}

void SmokeGenerator::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] + size;
		particle->pos[2] = pos[2];// + deltaZ*posScale;
		particle->direction[0] = cosf((float)rand())*0.3f;
		particle->direction[1] = fabs(cos((float)rand()))*5;
		particle->direction[2] = cosf((float)rand())*0.3f;
		particle->life = 0;
		particle->maxLife = (cos((float)rand())+2.0f) * (1-scale);
		particle->beginCouleur[0] = 2.0f;
		particle->beginCouleur[1] = 2.0f;
		particle->beginCouleur[2] = 2.0f;
		particle->beginCouleur[3] = -0.5f;
		particle->endCouleur[0] = 0.0f;
		particle->endCouleur[1] = 0.0f;
		particle->endCouleur[2] = 0.0f;
		particle->endCouleur[3] = 0.8f;
		particle->masse = 1.0f;
		particle->size = fabs(cos((float)rand()))*3;
		generation++;
	}
}
