FBXExportProperty: implement float and long array properties.

pull/1857/head
Tommy 2018-03-26 18:27:15 +02:00
parent 72800bf072
commit 2dff6e2d5b
2 changed files with 38 additions and 0 deletions

View File

@ -116,6 +116,20 @@ FBX::Property::Property(const std::vector<int32_t>& va)
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; } for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; }
} }
FBX::Property::Property(const std::vector<int64_t>& va)
: type('l'), data(8*va.size())
{
int64_t* d = reinterpret_cast<int64_t*>(data.data());
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; }
}
FBX::Property::Property(const std::vector<float>& va)
: type('f'), data(4*va.size())
{
float* d = reinterpret_cast<float*>(data.data());
for (size_t i = 0; i < va.size(); ++i) { d[i] = va[i]; }
}
FBX::Property::Property(const std::vector<double>& va) FBX::Property::Property(const std::vector<double>& va)
: type('d'), data(8*va.size()) : type('d'), data(8*va.size())
{ {
@ -178,6 +192,28 @@ void FBX::Property::Dump(Assimp::StreamWriterLE &s)
s.PutI4((reinterpret_cast<int32_t*>(d))[i]); s.PutI4((reinterpret_cast<int32_t*>(d))[i]);
} }
return; 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<int64_t*>(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<float*>(d))[i]);
}
return;
case 'd': case 'd':
N = data.size() / 8; N = data.size() / 8;
s.PutU4(uint32_t(N)); // number of elements s.PutU4(uint32_t(N)); // number of elements

View File

@ -96,7 +96,9 @@ public:
explicit Property(const std::string& s, bool raw=false); explicit Property(const std::string& s, bool raw=false);
explicit Property(const std::vector<uint8_t>& r); explicit Property(const std::vector<uint8_t>& r);
explicit Property(const std::vector<int32_t>& va); explicit Property(const std::vector<int32_t>& va);
explicit Property(const std::vector<int64_t>& va);
explicit Property(const std::vector<double>& va); explicit Property(const std::vector<double>& va);
explicit Property(const std::vector<float>& va);
explicit Property(const aiMatrix4x4& vm); explicit Property(const aiMatrix4x4& vm);
// this will catch any type not defined above, // this will catch any type not defined above,