diff --git a/src/Libraries/MeshWriter.cpp b/src/Libraries/MeshWriter.cpp index afb29b0..11282cc 100644 --- a/src/Libraries/MeshWriter.cpp +++ b/src/Libraries/MeshWriter.cpp @@ -231,15 +231,37 @@ namespace SH_COMP sizeof(asset.header) ); - file.write( - reinterpret_cast(asset.meshHeaders.data()), - sizeof(MeshDataHeader) * asset.header.meshCount - ); + if (asset.header.meshCount > 0) + { + file.write( + reinterpret_cast(asset.meshHeaders.data()), + sizeof(MeshDataHeader) * asset.header.meshCount + ); + } - file.write( - reinterpret_cast(asset.animHeaders.data()), - sizeof(AnimDataHeader) * asset.header.animCount - ); + if (asset.header.animCount > 0) + { + for(auto const& animHeader : asset.animHeaders) + { + file.write( + reinterpret_cast(&animHeader.charCount), + sizeof(uint32_t) + ); + + file.write( + reinterpret_cast(&animHeader.animNodeCount), + sizeof(uint32_t) + ); + + for (auto const& nodeHeader : animHeader.nodeHeaders) + { + file.write( + reinterpret_cast(&nodeHeader), + sizeof(nodeHeader) + ); + } + } + } } void MeshWriter::WriteData(FileReference file, ModelConstRef asset) diff --git a/src/main.cpp b/src/main.cpp index 1d0e361..85c43c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,44 +16,44 @@ int main(int argc, char* argv[]) { - //std::vector paths; + std::vector 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; }