
#ifndef TFIRE1_H_INCLUDED
#define TFIRE1_H_INCLUDED

/*
OBJET       feu 1ere methode > assemblage de 3 plans avec texture animée

DATE        07/2025

AUTEUR      philippe Thebaud

COMMENTAIRE
*/


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

#include "../ECO/OUtils.h"
#include "../ECO/OTextureList.h"
#include "../ECO/shader/OShader.h"

// code flux load save
#define FLUX_FIRE1      "fire1"
#define FLUX_FIRE1_MOD  "fire1m"

class TShFire1 : public OShader
{
public:

    TShFire1();

    bool        create();

    void        setVP(const OMat4& vp);
    void        setTextures(uint32_t fire, uint32_t noise, uint32_t alpha);
    void        setTime(float value);

private:

	uint32_t    m_vp;
	uint32_t    m_time;
	uint32_t    m_fireMap, m_noiseMap, m_alphaMap;
};

class Tfire1
{
public:

    Tfire1();
    ~Tfire1();

    void        addModel(float px, float py, float pz, float sw, float sh);
    void        addModel(std::string flux);
    void        addModel(std::ifstream& flux);

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

    void        draw(OMat4& vp);

    void        save(std::ofstream& flux);

private:

    void        _setModel(OVec3_f& pos, OVec3_f& scale);

    void        _vao();

private:

    OTextureList    textureList;
    std::string     m_code, m_path;

    const int               m_nbr_vao_buffer = 8;
    uint32_t                m_vao, m_vao_buffer[8];
    std::vector<OVec3_f>    m_pos;
    std::vector<OVec3_f>    m_scale;
    std::vector<OMat4>      m_model_multi;

    std::string     m_str_fire, m_str_noise, m_str_alpha;
    s_texParam      m_tex_fire, m_tex_noise, m_tex_alpha;

    OVec3_f         m_vertex[4];
    OVec3_f         m_normal[4];
    OVec2_f         m_uv[4];
    unsigned int    m_indice[4];

public:

    TShFire1        shFire;

};


#endif
