From f09e5791837bb003f7c5db8c0e3162636bc9a9c2 Mon Sep 17 00:00:00 2001 From: Mel Date: Wed, 12 Jul 2023 03:39:01 +0200 Subject: 3D Clouds --- src/GFX/Util/Primitives.hpp | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/GFX/Util/Primitives.hpp (limited to 'src/GFX/Util/Primitives.hpp') diff --git a/src/GFX/Util/Primitives.hpp b/src/GFX/Util/Primitives.hpp new file mode 100644 index 0000000..b96bc00 --- /dev/null +++ b/src/GFX/Util/Primitives.hpp @@ -0,0 +1,47 @@ +#pragma once + +#include "../../Common/Sizes.hpp" +#include "../../Math/AABB.hpp" +#include + +namespace MC::GFX::Util::Primitives { + +class FaceSet { +public: + enum Value : U8 { + Front = 1 << 0, + Back = 1 << 1, + Top = 1 << 2, + Bottom = 1 << 3, + Right = 1 << 4, + Left = 1 << 5, + }; + + static constexpr UInt Size = 6; + + FaceSet() = default; + FaceSet(const Value set) : m_set(set) {} + + operator Value() const { return m_set; } + + static FaceSet all() { + return static_cast(Front | Back | Top | Bottom | Right | Left); + } +private: + Value m_set; +}; + +template +struct Primitive { + std::array, N> positions; + std::array, N> normals; + std::array indices; +}; + +using PlanePrimitive = Primitive<4>; +PlanePrimitive plane(Math::AABB aabb, FaceSet face); + +using BoxPrimitive = Primitive<4 * 6>; +BoxPrimitive box(Math::AABB aabb, FaceSet faces = FaceSet::all()); + +} -- cgit 1.4.1