VOXCONVERT: implemented --translate command line option

master
Martin Gerhardy 2021-12-21 17:50:19 +01:00
parent b356e4f231
commit eaa73bc3a4
6 changed files with 25 additions and 2 deletions

3
debian/changelog vendored
View File

@ -6,8 +6,9 @@ vengi (0.0.16.0-1) UNRELEASED; urgency=low
* Fixed bugs in binvox support
* VoxConvert:
* Fixed `--force` handling for target files
* Fixed --force handling for target files
* Allow to operate on multiple input files
* Added --translate command line option
-- Martin Gerhardy <martin.gerhardy@gmail.com> Sat, 18 Dec 2021 14:16:59 +0100

View File

@ -14,6 +14,7 @@ VoxConvert:
- Fixed `--force` handling for target files
- Allow to operate on multiple input files
- Added `--translate` command line option
## 0.0.15 (2021-12-18)

View File

@ -20,6 +20,7 @@ Convert voxel volume formats between each other or export to obj or ply.
* `--scale`: perform lod conversion of the input volume (50% scale per call)
* `--script "<script> <args>"`: execute the given script - see [scripting support](../LUAScript.md) for more details
* `--src-palette`: will use the included palette and doesn't perform any quantization to the default palette
* `--translate <x:y:z>`: translates the volumes by x (right), y (up), z (back)
Just type `vengi-voxconvert` to get a full list of commands and options.

View File

@ -266,7 +266,7 @@ bool VoxFormat::saveGroups(const VoxelVolumes& volumes, const core::String &file
reset();
VoxScopedHeader scoped(stream);
wrapBool(saveChunk_PACK(state,stream, volumes))
wrapBool(saveChunk_PACK(state, stream, volumes))
int modelId = 0;
for (auto& v : volumes) {
if (skipSaving(v)) {

View File

@ -47,6 +47,7 @@ app::AppState VoxConvert::onConstruct() {
registerArg("--scale").setShort("-s").setDescription("Scale layer to 50% of its original size");
registerArg("--script").setDefaultValue("script.lua").setDescription("Apply the given lua script to the output volume");
registerArg("--src-palette").setShort("-p").setDescription("Keep the source palette and don't perform quantization");
registerArg("--translate").setShort("-t").setDescription("Translate the volumes by x (right), y (up), z (back)");
_mergeQuads = core::Var::get(cfg::VoxformatMergequads, "true", core::CV_NOPERSIST);
_mergeQuads->setHelp("Merge similar quads to optimize the mesh");
@ -296,6 +297,14 @@ app::AppState VoxConvert::onInit() {
rotate(getArgVal("--rotate"), volumes);
}
if (hasArg("--translate")) {
const core::String &arguments = getArgVal("--translate");
glm::ivec3 t(0);
if (SDL_sscanf(arguments.c_str(), "%i:%i:%i", &t.x, &t.y, &t.z) >= 1) {
translate(t, volumes);
}
}
Log::debug("Save");
if (!voxelformat::saveFormat(outputFile, volumes)) {
voxelformat::clearVolumes(volumes);
@ -401,6 +410,16 @@ void VoxConvert::rotate(const core::String& axisStr, voxel::VoxelVolumes& volume
}
}
void VoxConvert::translate(const glm::ivec3& pos, voxel::VoxelVolumes& volumes) {
Log::info("Translate by %i:%i:%i", pos.x, pos.y, pos.z);
for (voxel::VoxelVolume &v : volumes) {
if (v.volume == nullptr) {
continue;
}
v.volume->translate(pos);
}
}
int main(int argc, char *argv[]) {
const core::EventBusPtr& eventBus = std::make_shared<core::EventBus>();
const io::FilesystemPtr& filesystem = std::make_shared<io::Filesystem>();

View File

@ -27,6 +27,7 @@ protected:
void usage() const override;
void mirror(const core::String& axisStr, voxel::VoxelVolumes& volumes);
void rotate(const core::String& axisStr, voxel::VoxelVolumes& volumes);
void translate(const glm::ivec3& pos, voxel::VoxelVolumes& volumes);
void filterVolumes(voxel::VoxelVolumes& volumes);
public:
VoxConvert(const metric::MetricPtr& metric, const io::FilesystemPtr& filesystem, const core::EventBusPtr& eventBus, const core::TimeProviderPtr& timeProvider);