
#ifndef TFLAG_LOW_H_INCLUDED
#define TFLAG_LOW_H_INCLUDED

/*
OBJET       classe d'un drapeau simple flottant au vent

DATE        02/2026

AUTEUR      philippe Thebaud

COMMENTAIRE pour effet realiste voir Tflag_med et +
*/

#include <GL/glew.h>
#include <string>
#include <vector>
#include <deque>
//#include <cstring> //memcopy pour VBO
#include <iostream>

#include "../ECO/OUtils.h"
//#include "OTextureList.h"
#include "../ECO/OMesh_obj.h"
#include "../ECO/defered/ODshGeo.h"

#include "common.h"


#include "../ECO/defered/ODshader.h"


class TDshFlag_low : public ODshader
{
public:

    TDshFlag_low();

    bool        create();

    void        setVP(const OMat4& vp);
    void        setTexture(uint32_t texture);
    void        setTime(float value);
    void        setWind(float speed, float dir);
    void        setAmplitude_factor(float value);

private:

    uint32_t    m_vp;
	uint32_t    m_colorMap, m_normalMap, m_specularMap;
	uint32_t    m_time;
	uint32_t    m_wind_speed, m_wind_dir;
	uint32_t    m_amplitude_factor;
};


class Tflag_low
{
public:

	Tflag_low();
    ~Tflag_low();

    void        addModel(std::string flux);

    void        create(std::string file);

    void        draw(const OMat4& vp, ODshGeo& dshGeo);

    void        setWind(float speed, float dir);

private:

    void        _clear();
    void        _composition();

    void        _generate_flag();

    uint32_t    _load_texture(std::string file);

    void        _make_vao();

    void        _setModel(size_t idx);

private:

    // --- le mat/pole = base
    std::string m_code, m_file, m_path;
    OMesh_obj   mesh;

    std::vector<OVec3_f> m_pos;
    std::vector<OVec3_f> m_rot;
    std::vector<OVec3_f> m_scale;
	std::vector<OMat4>  m_model_multi;

    // --- le drapeau

	TDshFlag_low dshFlag;

    // pour isoler les données du drapeau
    static const int nbr_vao_buffer = 8;
    struct s_flag
    {
        OVec3_f     decal_pos;
        float       width, height;
        int         nbCol, nbRow;
        std::string img_tex; //, img_bump;
        //
        uint32_t                vao, vao_buffer[nbr_vao_buffer];
        std::vector<OVec3_f>    vertex;
        std::vector<OVec3_f>    normal;
        std::vector<OVec2_f>    uv;
        std::vector<unsigned>   indice;
        uint32_t                tex_image; //, tex_bump;

        std::vector<OMat4>      model_multi;
    };
    s_flag m_flag;


};

#endif
