
#ifndef TSEA3D_LOW_1_H_INCLUDED
#define TSEA3D_LOW_1_H_INCLUDED

/*
OBJET       classe d'un effet de mer basse qualité

DATE        06/2025

AUTEUR      philippe Thebaud

COMMENTAIRE
*/

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

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

#include "common.h"



class Tsea3d_low_1_sh : public OShader
{
public:

    Tsea3d_low_1_sh();

    bool        create();

    void        setVP(const OMat4& vp);
    void        setModel(const OMat4& model);

    void        setEyePos(const OVec3_f& EyePos);
    void        setLight(float ambient, const OVec3_f& direction, const OVec3_f& color);
    void        setMulti(bool mode);
    void        setSizeTexture(int size);
    void        setTextures(uint32_t refraction, uint32_t reflection);
    void        setTime(float time);
    void        setTurbidity(float value);
    void        setWave(float hight, float frequency);

private:

    uint32_t    m_vp, m_model;
    uint32_t    m_refractionMap, m_reflectionMap;
    uint32_t    m_eyePos;
    uint32_t    m_time;

    uint32_t    m_light_color, m_light_ambient, m_light_dir;
    uint32_t    m_multi;
    uint32_t    m_sizeTexture;

    uint32_t    m_wave_hight, m_wave_frequency;
    uint32_t    m_turbidity;
};

// pour la surface eau

class Tsea3d_low_1_shw : public OShader
{
public:

    Tsea3d_low_1_shw();

    bool        create();

    void        setVP(const OMat4& vp);
    void        setModel(const OMat4& model);
    void        setMulti(bool mode);
    void        setTime(float value);

private:

    uint32_t    m_vp, m_model;
	uint32_t    m_multi;
	uint32_t    m_time;

};


// --- map / carte / plan ---

class Tsea3d_low_1_plan
{
public:

    Tsea3d_low_1_plan();
    ~Tsea3d_low_1_plan();

    void        addModel(std::string flux);
    void        addModel(float px, float py, float pz);

    void        create(uint32_t size, float scale_uv);

    void        draw();
    void        draw_multi();

    OMat4&      getModel();
    size_t      getSize();
    bool        getVisible();

    void        setPos(OVec3_f& pos, size_t idx = 0);
    void        setPos(float px, float py, float pz, size_t idx = 0);

private:

    void        _make_vao();

    void        _setModel(size_t idx);
    //void        _setModelMulti(std::vector<OMat4>& modelMulti);

private:

    std::vector<OVec3_f>    m_pos;
    std::vector<OMat4>      m_model;
    std::vector<OMat4>      m_model_multi; // avec mat4 'horizontale'

    uint32_t                m_vao, m_vao_buffer[10];
    std::vector<uint32_t>   m_indice;
    std::vector<OVec3_f>    m_vertex;
    std::vector<OVec3_f>    m_normal;
    std::vector<OVec2_f>    m_uv;

};

// -----------------
// classe principale
// -----------------

class Tsea3d_low_1
{
public:

    Tsea3d_low_1();
    ~Tsea3d_low_1();

    void        create(int size, float scale_uv);

    void        draw(OMat4& vp, OVec3_f& eyePos, uint32_t reflectionMap);
    void        draw_water_reflection(OMat4& vp);

    void        setLight(float ambient, OVec3_f& dir, OVec3_f& color);

private:

    OTextureList        textureList;
    uint32_t            m_reflectionMap, m_refractionMap;
    float               m_time;

public:

    Tsea3d_low_1_sh     shSea3d_low;
    Tsea3d_low_1_shw    shSea3d_low_w;
    Tsea3d_low_1_plan   plan;
};


#endif // TSEA3D_LOW_1_H_INCLUDED


