15#ifndef DL_DISABLE_RENDER
17#include <unordered_map>
70 static std::vector<ModelObject*>
Create(std::string_view path_name, std::string_view res_name);
72 void Load(std::string_view path_name)
82 s.
Read(&_allVertexBone);
88 _allMaterial.resize(size);
89 for (
size_t i = 0; i < size; ++i)
91 _allMaterial[i].Load(s);
110 s.
Write(&_allVertex);
111 s.
Write(&_allVertexBone);
115 size_t size = _allMaterial.size();
117 for (
size_t i = 0; i < size; ++i)
119 _allMaterial[i].Save(s);
122 bool has_bone = _boneData;
129 s.
Save(path_name,
true);
134 for (
auto& iter : _allMaterial)
136 if (!iter._pathTexDiffuse.empty()
137 || !iter._pathTexNormal.empty())
147 std::unordered_map<std::string, std::string> map_out;
149 auto fn_output = [&map_out, path](std::string& path_name,
size_t i, std::string_view tag)
151 if (path_name.empty())
153 auto iter = map_out.find(path_name);
154 if (iter == map_out.end())
157 std::string name = fmt::format(
"{}{}{}.{}", path, tag, i, fmt);
159 map_out[path_name] = name;
164 path_name = iter->second;
168 for (
auto& iter : _allMaterial)
170 fn_output(iter._pathTexDiffuse, i,
"diffuse#");
171 fn_output(iter._pathTexNormal, i,
"normal#");
179 std::vector<ModelObjectSub> _allSub;
181 std::vector<Vertex> _allVertex;
182 std::vector<VertexBone> _allVertexBone;
183 std::vector<uint32_t> _allIndex;
186 std::vector<ModelObjectMaterial> _allMaterial;
void Save(StreamOutput &s)
void Load(StreamInput &s)
void Load(std::string_view path_name)
void ConvertTexturePath(std::string_view path)
static std::vector< ModelObject * > Create(std::string_view path_name, std::string_view res_name)
void SaveToFile(std::string_view path_name)
bool Save(std::string_view path_name, bool compress=false)
保存到文件
void Write64(const T *data)
写入一个类型以64位,对于在64位平台的大小不一致,所以特殊处理
void Write(const T *data)
写入一个对象
bool Copy(std::string_view source, std::string_view target, CopyMode mode=CopyMode::NONE, bool recursion=false)
复制文件或文件夹
std::string GetExtension(std::string_view path_name, bool has_dot=false)
返回文件后缀
void Save(StreamOutput &s)
std::string _pathTexDiffuse
void Load(StreamInput &s)
std::string _pathTexNormal
std::string _materialName
ModelTriangleRange _range