#include "FishGenerator.h"

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

#include "MemoryManager/DebugNew.h"


using namespace ParticleSystem;

FishGenerator::FishGenerator(float size){
	this->size = size;
	maxGeneration = 1;
	this->generationDelay = 1.0f;
	this->previousTime = cos((float)rand()) * this->generationDelay;
	loop = true;

}

FishGenerator::~FishGenerator(void){
}

void FishGenerator::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] = fabs(cos((float)rand()));
		particle->direction[1] = fabs(cos((float)rand()))*10;
		particle->direction[2] = fabs(cos((float)rand()));
		particle->life = 0;
		particle->maxLife = (cos((float)rand())+1.0f)*3  + 2;
		//particle->beginCouleur[0] = 0.25f;
		//particle->beginCouleur[1] = 0.25f;
		//particle->beginCouleur[2] = 0.5f;
		//particle->beginCouleur[3] = 1.0f;
		//particle->endCouleur[0] = 0.25f;
		//particle->endCouleur[1] = 0.25f;
		//particle->endCouleur[2] = 0.5f;
		//particle->endCouleur[3] = 1.0f;
		particle->beginCouleur[0] = 1.0f;
		particle->beginCouleur[1] = 1.0f;
		particle->beginCouleur[2] = 1.0f;
		particle->beginCouleur[3] = 5.0f;
		particle->endCouleur[0] = 1.0f;
		particle->endCouleur[1] = 1.0f;
		particle->endCouleur[2] = 1.0f;
		particle->endCouleur[3] = 0.0f;
		particle->masse = 8.0f;
		particle->size = fabs(cos((float)rand()))*2;
		generation++;
	}
}

