From 4dbd2367f4e012c8f913e3569666a54b6d491594 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 30 Sep 2014 17:34:01 -0700 Subject: [PATCH] Working on shapes for metavoxel edits. --- .../metavoxels/src/MetavoxelMessages.cpp | 20 +++++++++ libraries/metavoxels/src/MetavoxelMessages.h | 42 +++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/libraries/metavoxels/src/MetavoxelMessages.cpp b/libraries/metavoxels/src/MetavoxelMessages.cpp index 04ed5c5d02..fd528a4f1c 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.cpp +++ b/libraries/metavoxels/src/MetavoxelMessages.cpp @@ -1135,3 +1135,23 @@ void VoxelMaterialSphereEdit::apply(MetavoxelData& data, const WeakSharedObjectH VoxelMaterialSphereEditVisitor visitor(center, radius, bounds, granularity, material, averageColor); data.guide(visitor); } + +MetavoxelShape::MetavoxelShape(const glm::vec3& translation, const glm::quat& rotation, float scale) : + translation(translation), + rotation(rotation), + scale(scale) { +} + +MetavoxelShape::~MetavoxelShape() { +} + +MetavoxelSphere::MetavoxelSphere(const glm::vec3& translation, const glm::quat& rotation, float scale) : + MetavoxelShape(translation, rotation, scale) { +} + +MetavoxelBox::MetavoxelBox(const glm::vec3& translation, const glm::quat& rotation, float scale, + float aspectXY, float aspectXZ) : + MetavoxelShape(translation, rotation, scale), + aspectXY(aspectXY), + aspectXZ(aspectXZ) { +} diff --git a/libraries/metavoxels/src/MetavoxelMessages.h b/libraries/metavoxels/src/MetavoxelMessages.h index fec8e69aaa..abfbe79773 100644 --- a/libraries/metavoxels/src/MetavoxelMessages.h +++ b/libraries/metavoxels/src/MetavoxelMessages.h @@ -282,4 +282,46 @@ public: DECLARE_STREAMABLE_METATYPE(VoxelMaterialSphereEdit) +/// Abstract base class for shapes. +class MetavoxelShape { + STREAMABLE + +public: + + STREAM glm::vec3 translation; + STREAM glm::quat rotation; + STREAM float scale; + + MetavoxelShape(const glm::vec3& translation = glm::vec3(), const glm::quat& rotation = glm::quat(), float scale = 1.0f); + virtual ~MetavoxelShape(); +}; + +DECLARE_STREAMABLE_METATYPE(MetavoxelShape) + +// A sphere shape. +class MetavoxelSphere : public MetavoxelShape { + STREAMABLE + +public: + + MetavoxelSphere(const glm::vec3& translation = glm::vec3(), const glm::quat& rotation = glm::quat(), float scale = 1.0f); +}; + +DECLARE_STREAMABLE_METATYPE(MetavoxelSphere) + +// A box shape. +class MetavoxelBox : public MetavoxelShape { + STREAMABLE + +public: + + STREAM float aspectXY; + STREAM float aspectXZ; + + MetavoxelBox(const glm::vec3& translation = glm::vec3(), const glm::quat& rotation = glm::quat(), float scale = 1.0f, + float aspectXY = 1.0f, float aspectXZ = 1.0f); +}; + +DECLARE_STREAMABLE_METATYPE(MetavoxelBox) + #endif // hifi_MetavoxelMessages_h