Fixed anim header write to account for vector of objects

prepare for merge into main
This commit is contained in:
Xiao Qi 2023-01-07 20:49:52 +08:00
parent 5d6cdc7fd3
commit 6eca9b021f
2 changed files with 65 additions and 43 deletions

View File

@ -231,15 +231,37 @@ namespace SH_COMP
sizeof(asset.header) sizeof(asset.header)
); );
if (asset.header.meshCount > 0)
{
file.write( file.write(
reinterpret_cast<char const*>(asset.meshHeaders.data()), reinterpret_cast<char const*>(asset.meshHeaders.data()),
sizeof(MeshDataHeader) * asset.header.meshCount sizeof(MeshDataHeader) * asset.header.meshCount
); );
}
if (asset.header.animCount > 0)
{
for(auto const& animHeader : asset.animHeaders)
{
file.write(
reinterpret_cast<char const*>(&animHeader.charCount),
sizeof(uint32_t)
);
file.write( file.write(
reinterpret_cast<char const*>(asset.animHeaders.data()), reinterpret_cast<char const*>(&animHeader.animNodeCount),
sizeof(AnimDataHeader) * asset.header.animCount sizeof(uint32_t)
); );
for (auto const& nodeHeader : animHeader.nodeHeaders)
{
file.write(
reinterpret_cast<char const*>(&nodeHeader),
sizeof(nodeHeader)
);
}
}
}
} }
void MeshWriter::WriteData(FileReference file, ModelConstRef asset) void MeshWriter::WriteData(FileReference file, ModelConstRef asset)

View File

@ -16,44 +16,44 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
//std::vector<std::string> paths; std::vector<std::string> paths;
//if (argc == 1) if (argc == 1)
//{ {
// if (std::filesystem::is_directory(ASSET_ROOT)) if (std::filesystem::is_directory(ASSET_ROOT))
// { {
// for (auto& dir : for (auto& dir :
// std::filesystem::recursive_directory_iterator{ ASSET_ROOT }) std::filesystem::recursive_directory_iterator{ ASSET_ROOT })
// { {
// if (dir.path().extension().string() == GLTF_EXTENSION || if (dir.path().extension().string() == GLTF_EXTENSION ||
// dir.path().extension().string() == FBX_EXTENSION) dir.path().extension().string() == FBX_EXTENSION)
// { {
// auto path = dir.path(); auto path = dir.path();
// path.make_preferred(); path.make_preferred();
// paths.push_back(path.string()); paths.push_back(path.string());
// } }
// } }
// } }
// else else
// { {
// std::cout << "Default path not found!" << std::endl; std::cout << "Default path not found!" << std::endl;
// return 1; return 1;
// } }
//} }
//else if (argc > 1) else if (argc > 1)
//{ {
// for (int i { 1 }; i < argc; ++i) for (int i { 1 }; i < argc; ++i)
// { {
// paths.emplace_back(argv[i]); paths.emplace_back(argv[i]);
// } }
//} }
//for (auto const& path : paths) for (auto const& path : paths)
//{ {
// SH_COMP::MeshCompiler::LoadAndCompile(path); SH_COMP::MeshCompiler::LoadAndCompile(path);
//} }
SH_COMP::MeshCompiler::LoadAndCompile("Raccoon.gltf"); //SH_COMP::MeshCompiler::LoadAndCompile("Raccoon.gltf");
return 0; return 0;
} }