#include "SpringGenerator.h"

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

#include "MemoryManager/DebugNew.h"

using namespace ParticleSystem;

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

}

SpringGenerator::~SpringGenerator(void){
}

void SpringGenerator::generate(ParticleEngine::Particle * particle){
	if (canGenerate()){
		float deltaX = cos((float)rand());
		float deltaZ = cos((float)rand());
		float scale = cos((float)rand());
		particle->pos[0] = pos[0];
		particle->pos[1] = pos[1] + size;
		particle->pos[2] = pos[2];
		particle->direction[0] = cosf((float)rand())*0.6f;
		particle->direction[1] = fabs(cos((float)rand()))*5;
		particle->direction[2] = cosf((float)rand())*0.6f;
		particle->life = 0;
		particle->maxLife = (cos((float)rand())+3.0f);
		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.5f;
		particle->masse = 5.0f;
		particle->size = fabs(cos((float)rand()))*3;
		generation++;
	}
}
