
#ifndef TPRTJET_H_INCLUDED
#define TPRTJET_H_INCLUDED

/*
OBJET       particules -> jet (d'eau)(sang)(feu d'artifice)

DATE        12/2023

AUTEUR      philippe Thebaud

COMMENTAIRE
*/

#include <GL/glew.h>
#include <string>
#include <vector>
#include <fstream>

#include "../ECO/OUtils.h"
#include "../ECO/OSurface.h"



class TprtJet
{
public:

	TprtJet();
    ~TprtJet();

    void        create_by(std::string code);
    void    	create(std::ifstream& flux);
    void        create(std::string flux);

    void        draw();

    void        generation();
    std::string getCode();

    void        hide();

    void        save(std::ofstream& flux);
    void        setPos(OVec3_f& pos);
    void        start(OVec3_f& pos);
    void        stop();

    void        update(float ambient);

    // propriété
    static void p_setFps(uint64_t value);

private:

    void        _composition();

    void        _load_texture(std::string file);

    void        _make();

private:

	bool        m_visible;
    std::string m_code, m_path, m_file;
	OVec3_f		m_pos;
	ORect_i     m_src;

    struct s_particle
    {
        OVec3_f     pos, speed;
        float       r,g,b,a;
        float       size;
        uint64_t    life;
    };
    std::vector<s_particle> m_particle;
    // pour toutes les particules
    int         m_maxParticles, m_nbParticles;
    float       m_var_air, m_var_gravite, m_var_color;
    int         m_loop;

    // pour la construction
    struct s_param
    {
        OVec2_f angleH, angleV, vit_ejection;
        OVec4_f zone;
        OVec2_f size_var;
        OVec4_f color_min, color_max;
        OVec2_f life_var;
        int     generation_nbr, generation_loop;
    };
    s_param m_param;

    //affichage
    uint32_t    m_vertex, m_uv;
	uint32_t	m_particle_buffer;
	uint32_t	m_particle_color_buffer;
	s_texParam  m_texParam;

	std::vector<float> m_particle_data;    //position+taille
	std::vector<float> m_particle_color;   //couleur
};

#endif
