From 2dff6e2d5b434d0d738693fadd189f5dcfc7859f Mon Sep 17 00:00:00 2001 From: Tommy Date: Mon, 26 Mar 2018 18:27:15 +0200 Subject: [PATCH] FBXExportProperty: implement float and long array properties. --- code/FBXExportProperty.cpp | 36 ++++++++++++++++++++++++++++++++++++ code/FBXExportProperty.h | 2 ++ 2 files changed, 38 insertions(+) diff --git a/code/FBXExportProperty.cpp b/code/FBXExportProperty.cpp index 975e9a09a..e139bb95a 100644 --- a/code/FBXExportProperty.cpp +++ b/code/FBXExportProperty.cpp @@ -116,6 +116,20 @@ FBX::Property::Property(const std::vector& va) for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } } +FBX::Property::Property(const std::vector& va) + : type('l'), data(8*va.size()) +{ + int64_t* d = reinterpret_cast(data.data()); + for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } +} + +FBX::Property::Property(const std::vector& va) + : type('f'), data(4*va.size()) +{ + float* d = reinterpret_cast(data.data()); + for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } +} + FBX::Property::Property(const std::vector& va) : type('d'), data(8*va.size()) { @@ -178,6 +192,28 @@ void FBX::Property::Dump(Assimp::StreamWriterLE &s) s.PutI4((reinterpret_cast(d))[i]); } return; + case 'l': + N = data.size() / 8; + s.PutU4(uint32_t(N)); // number of elements + s.PutU4(0); // no encoding (1 would be zip-compressed) + // TODO: compress if large? + s.PutU4(uint32_t(data.size())); // data size + d = data.data(); + for (size_t i = 0; i < N; ++i) { + s.PutI8((reinterpret_cast(d))[i]); + } + return; + case 'f': + N = data.size() / 4; + s.PutU4(uint32_t(N)); // number of elements + s.PutU4(0); // no encoding (1 would be zip-compressed) + // TODO: compress if large? + s.PutU4(uint32_t(data.size())); // data size + d = data.data(); + for (size_t i = 0; i < N; ++i) { + s.PutF4((reinterpret_cast(d))[i]); + } + return; case 'd': N = data.size() / 8; s.PutU4(uint32_t(N)); // number of elements diff --git a/code/FBXExportProperty.h b/code/FBXExportProperty.h index 8920346a3..40a020688 100644 --- a/code/FBXExportProperty.h +++ b/code/FBXExportProperty.h @@ -96,7 +96,9 @@ public: explicit Property(const std::string& s, bool raw=false); explicit Property(const std::vector& r); explicit Property(const std::vector& va); + explicit Property(const std::vector& va); explicit Property(const std::vector& va); + explicit Property(const std::vector& va); explicit Property(const aiMatrix4x4& vm); // this will catch any type not defined above,