VOXELFORMAT: extract vxc content to access it

master
Martin Gerhardy 2022-05-12 00:18:06 +02:00
parent 33f87bafc0
commit 86ad634ad9
1 changed files with 17 additions and 7 deletions

View File

@ -3,9 +3,13 @@
*/
#include "VXCFormat.h"
#include "app/App.h"
#include "core/Log.h"
#include "core/StringUtil.h"
#include "io/BufferedReadWriteStream.h"
#include "io/FileStream.h"
#include "io/Filesystem.h"
#include "app/App.h"
#include "io/ZipReadStream.h"
#include "voxelformat/VXMFormat.h"
#include "voxelformat/VXRFormat.h"
@ -44,24 +48,30 @@ bool VXCFormat::loadGroups(const core::String &filename, io::SeekableReadStream
uint32_t entries;
wrap(stream.readUInt32(entries))
core::String vxr;
for (uint32_t i = 0; i < entries; ++i) {
char path[1024];
wrapBool(stream.readString(sizeof(path), path, true))
uint32_t fileSize;
wrap(stream.readUInt32(fileSize))
io::BufferedReadWriteStream substream(stream, fileSize);
substream.seek(0);
// TODO: currently we need them as files - we don't have a virtual filesystem that could deal with this yet...
io::filesystem()->write(path, substream.getBuffer(), substream.size());
const core::String &ext = core::string::extractExtension(path);
if (ext == "vxr") {
VXRFormat f;
f.loadGroups(path, substream, sceneGraph);
} else if (ext == "vxm") {
VXMFormat f;
f.loadGroups(path, substream, sceneGraph);
} else {
Log::warn("Ignore file %s in vxc (size: %u)", path, fileSize);
vxr = path;
}
}
if (!vxr.empty()) {
VXRFormat f;
io::FilePtr vxrFile = io::filesystem()->open(vxr);
if (vxrFile->validHandle()) {
io::FileStream fstream(vxrFile);
f.loadGroups(vxr, fstream, sceneGraph);
}
}
return !sceneGraph.empty();
}