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)
);
file.write(
reinterpret_cast<char const*>(asset.meshHeaders.data()),
sizeof(MeshDataHeader) * asset.header.meshCount
);
if (asset.header.meshCount > 0)
{
file.write(
reinterpret_cast<char const*>(asset.meshHeaders.data()),
sizeof(MeshDataHeader) * asset.header.meshCount
);
}
file.write(
reinterpret_cast<char const*>(asset.animHeaders.data()),
sizeof(AnimDataHeader) * asset.header.animCount
);
if (asset.header.animCount > 0)
{
for(auto const& animHeader : asset.animHeaders)
{
file.write(
reinterpret_cast<char const*>(&animHeader.charCount),
sizeof(uint32_t)
);
file.write(
reinterpret_cast<char const*>(&animHeader.animNodeCount),
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)

View File

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