#ifndef RENDER_IMG_IMPORTER_H
#define RENDER_IMG_IMPORTER_H
#include <render_type_def.h>


namespace SHADER {
struct PropertyInfo {
    int index;
    Z::ShaderInfo::PropType type{};
    std::string name;
    Z::ShaderInfo::Value value{};
};
struct CbufferInfo {
    int index;
    std::string name;
    std::vector<PropertyInfo> props;
};
struct TextureInfo {
    int index; // 该texinfo在ShaderInfo里array的index
    std::string name; //renderer里通过name索引picture
    std::string cur_tex; // UTF8,默认为空,当前选择的texture的path字符串
};
struct ShaderInfo {
    std::string name;
    std::filesystem::path path;
    std::vector<CbufferInfo> cbuffer;
    int idx_cbPerMat{-1};
    std::vector<TextureInfo> textures;
};
}

namespace MAT {
struct MatInstance {
    std::string name;
    SHADER::ShaderInfo info;

    explicit MatInstance(std::string name, const SHADER::ShaderInfo *shader);
    bool Update(int index);
};
}

namespace RENDEROBJ {
class Object {
public:
    bool Update(float *pos, float *rot, float *scale);

private:

public:
    std::string name; // 显示在面板上的
    int id; // 用来找renderer的索引
    float position[3]{};
    float rotation[3]{};
    float scale[3]{1.0f, 1.0f, 1.0f};
    std::vector<MAT::MatInstance *> m_mats;
};
}

namespace LoadedResource {
Z::Model *GetLoadedModel(std::filesystem::path &path);
void RemoveLoadedModel(std::filesystem::path &path);

Z::TextureData *GetLoadedTexture(std::filesystem::path &path);
void RemoveLoadedTexture(std::filesystem::path &path);

SHADER::ShaderInfo *GetLoadedShader(std::string &name);
void RemoveLoadedShader(std::string &name);

MAT::MatInstance *GetLoadedMaterial(std::string &name);
void RemoveLoadedMaterial(std::string &name);
}


class ModelImporter { //=
public:
    static bool LoadFromFile(const std::filesystem::path &path, Z::Model **out);
};

class ImgImporter { //=
public:
    static Z::TextureData *ImportFromFile(const std::filesystem::path &path,
                                          bool revG, Z::TextureType type);
};

class ShaderImporter { //=
public:
    static SHADER::ShaderInfo *ImportFromFile(const std::filesystem::path &path);
};

class MatCreater { //=
public:
    static MAT::MatInstance *CreateMat(const std::string &name, const SHADER::ShaderInfo *shaderInfo);
};













#endif //RENDER_IMG_IMPORTER_H
