#ifndef PARTICLE_H
#define PARTICLE_H

#include "./../../lib/GLee/GLee.h"
#include "./context/Context.h"
#include "./exception/Exception.h"
#include "./math/Mathematics.h"
#include "./math/SupportFunctions.h"
#include <cassert>
using namespace ANALYTICAL_GEOMETRY;

///Holds basic informations about generated particle
class BasicParticle
{
protected:
	Vector_3<float> velocity;	/**< velocity vector of the particle */
	float acceleration;			/**< acceleration of the particle */
	float lifeTime;				/**< life time of the particle */
	Point_3<float> position;	/**< position of the particle */

public:
	BasicParticle( const Point_3<float> &position, Vector_3<float> &velocity, float acceleration, int lifeTime );
	BasicParticle(void);
	virtual ~BasicParticle(void)	{};

	void setPosition( const Point_3<float> &position );	/**< sets position of the particle */
	void setVelocity( const Vector_3<float> &velocity ); /**< sets velocity of the particle */
	void setAcceleration( float acceleration );	/**< set acceleration of the particle */
	void setLifeTime( float lifeTime );	/**< set life time of the particle */

	virtual void simulate( float dt );	/**< simulates the particle - moves the particle according to the velocity, acceleration and decrease lifeTime of the particle. Euler discret simulation method is used. */
	virtual bool isAlive( void );	/**< returns true if #BasicParticle::lifeTime is greater than zero, false otherwise. */
};

///Extends BasicParticle about new attributes which can be used for particle rendering
class GraphicParticle : public BasicParticle
{
private:
	float colorOffset[4];	/**< color offset of the particle */
	float sizeOffset;		/**< size offset of the particle */

public:
	float color[4];			/**< color of the particle */
	float size;				/**< size of the particle */
	unsigned int textureID;	/**< texture id of the particle */

	GraphicParticle(void);
	GraphicParticle( const GraphicParticle& );
	GraphicParticle& operator=( const GraphicParticle& );

	virtual ~GraphicParticle(void)	{};

	void setSizeOffset( float sizeOffset );	/**< sets size offset of the particle */
	void setColorOffset( float RedOffset, float GreenOffset, float BlueOffset, float AlphaOffset );

	virtual void simulate( float dt );	/**< simulates the particle - #BasicParticle::simulate is called and afterward #color and #size of the particle is changed according the #colorOffset and #sizeOffset */
	virtual void render( const Vector_3<float> &normRightVec, const Vector_3<float> &normUpVec ); /**< renders the particle as billboard according to the particle parameters. */
};



#endif