Skip to content

Commit

Permalink
VOXELFORMAT: added spritestack source files
Browse files Browse the repository at this point in the history
see issue #569 - just the empty files for now
  • Loading branch information
mgerhardy committed Jan 11, 2025
1 parent f36020e commit 8c8420f
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/modules/voxelformat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ set(SRCS
private/slab6/KV6Format.h private/slab6/KV6Format.cpp
private/slab6/SLAB6VoxFormat.h private/slab6/SLAB6VoxFormat.cpp
private/slab6/SLABShared.h private/slab6/SLABShared.cpp
private/spritestack/SpriteStackFormat.h private/spritestack/SpriteStackFormat.cpp
private/sproxel/SproxelFormat.h private/sproxel/SproxelFormat.cpp
private/starmade/SMFormat.h private/starmade/SMFormat.cpp
private/starmade/SMTPLFormat.h private/starmade/SMTPLFormat.cpp
Expand Down Expand Up @@ -144,6 +145,7 @@ set(TEST_SRCS
tests/QEFFormatTest.cpp
tests/QuakeBSPFormatTest.cpp
tests/SchematicFormatTest.cpp
tests/SpriteStackFormatTest.cpp
tests/SproxelFormatTest.cpp
tests/SLABSharedTest.cpp
tests/SLAB6VoxFormatTest.cpp
Expand Down Expand Up @@ -255,6 +257,7 @@ set(TEST_FILES
tests/slab6_vox_test.kv6
tests/slab6_vox_test.kvx
tests/slab6_vox_test.vox
tests/spritestack.zip
tests/blockbench_meshtypes.bbmodel
tests/female_template_head_4_10.bbmodel
tests/loy_s_goodies_female_template.bbmodel
Expand Down
4 changes: 4 additions & 0 deletions src/modules/voxelformat/VolumeFormat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "voxelformat/private/slab6/KV6Format.h"
#include "voxelformat/private/slab6/KVXFormat.h"
#include "voxelformat/private/slab6/SLAB6VoxFormat.h"
#include "voxelformat/private/spritestack/SpriteStackFormat.h"
#include "voxelformat/private/sproxel/SproxelFormat.h"
#include "voxelformat/private/starmade/SMFormat.h"
#include "voxelformat/private/starmade/SMTPLFormat.h"
Expand Down Expand Up @@ -126,6 +127,7 @@ const io::FormatDescription *voxelLoad() {
CSMFormat::format(),
CSMFormat::formatNVM(),
SLAB6VoxFormat::format(),
SpriteStackFormat::format(),
VMaxFormat::format(),
io::format::png(),
{"", {}, {}, 0u}};
Expand Down Expand Up @@ -247,6 +249,8 @@ static core::SharedPtr<Format> getFormat(const io::FormatDescription &desc, uint
return core::make_shared<PNGFormat>();
} else if (GLTFFormat::format().matchesExtension(ext)) {
return core::make_shared<GLTFFormat>();
} else if (ext == SpriteStackFormat::format().mainExtension()) {
return core::make_shared<SpriteStackFormat>();
} else if (BenVoxelFormat::format().matchesExtension(ext)) {
return core::make_shared<BenVoxelFormat>();
} else {
Expand Down
31 changes: 31 additions & 0 deletions src/modules/voxelformat/private/spritestack/SpriteStackFormat.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* @file
*/

#include "SpriteStackFormat.h"
#include "core/Log.h"
#include "core/ScopedPtr.h"
#include "io/ZipArchive.h"
#include "scenegraph/SceneGraphNode.h"
#include <glm/common.hpp>

namespace voxelformat {

bool SpriteStackFormat::loadGroupsPalette(const core::String &filename, const io::ArchivePtr &archive,
scenegraph::SceneGraph &sceneGraph, palette::Palette &palette,
const LoadContext &ctx) {
core::ScopedPtr<io::SeekableReadStream> stream(archive->readStream(filename));
if (!stream) {
Log::error("Could not load file %s", filename.c_str());
return false;
}
const io::ArchivePtr &zipArchive = io::openZipArchive(stream);
if (!zipArchive) {
Log::error("Failed to open zip archive");
return false;
}

return false;
}

} // namespace voxelformat
36 changes: 36 additions & 0 deletions src/modules/voxelformat/private/spritestack/SpriteStackFormat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* @file
*/

#pragma once

#include "io/Archive.h"
#include "io/Stream.h"
#include "voxelformat/Format.h"

namespace voxelformat {

/**
* @brief SpriteStack (*.zip)
*
* @ingroup Formats
*/
class SpriteStackFormat : public PaletteFormat {
private:
bool loadGroupsPalette(const core::String &filename, const io::ArchivePtr &archive,
scenegraph::SceneGraph &sceneGraph, palette::Palette &palette,
const LoadContext &ctx) override;

public:
bool saveGroups(const scenegraph::SceneGraph &sceneGraph, const core::String &filename,
const io::ArchivePtr &archive, const SaveContext &ctx) override {
return false;
}

static const io::FormatDescription &format() {
static io::FormatDescription f{"SpriteStack", {"zip"}, {}, 0u};
return f;
}
};

} // namespace voxelformat
15 changes: 15 additions & 0 deletions src/modules/voxelformat/tests/SpriteStackFormatTest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @file
*/

#include "AbstractFormatTest.h"

namespace voxelformat {

class SpriteStackFormatTest : public AbstractFormatTest {};

TEST_F(SpriteStackFormatTest, testLoad) {
testLoad("spritestack.zip", 1);
}

} // namespace voxelformat

0 comments on commit 8c8420f

Please sign in to comment.