From 25b752a31116997d94c7b4c1f30151a34f635b43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 24 Jan 2013 20:38:25 +0100 Subject: [PATCH] Primitives: Plane can be now solid or wireframe. --- src/Primitives/Plane.cpp | 34 +++++++++++++++++++++++----------- src/Primitives/Plane.h | 22 ++++++++++++++++++---- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/Primitives/Plane.cpp b/src/Primitives/Plane.cpp index aec78371c..8bcd58c4c 100644 --- a/src/Primitives/Plane.cpp +++ b/src/Primitives/Plane.cpp @@ -16,19 +16,31 @@ #include "Plane.h" #include "Math/Point3D.h" +#include "Trade/MeshData3D.h" namespace Magnum { namespace Primitives { -Plane::Plane(): MeshData3D(Mesh::Primitive::TriangleStrip, nullptr, {new std::vector{ - {1.0f, -1.0f, 0.0f}, - {1.0f, 1.0f, 0.0f}, - {-1.0f, -1.0f, 0.0f}, - {-1.0f, 1.0f, 0.0f} -}}, {new std::vector{ - {0.0f, 0.0f, 1.0f}, - {0.0f, 0.0f, 1.0f}, - {0.0f, 0.0f, 1.0f}, - {0.0f, 0.0f, 1.0f} -}}, {}) {} +Trade::MeshData3D Plane::solid() { + return Trade::MeshData3D(Mesh::Primitive::TriangleStrip, nullptr, {new std::vector{ + {1.0f, -1.0f, 0.0f}, + {1.0f, 1.0f, 0.0f}, + {-1.0f, -1.0f, 0.0f}, + {-1.0f, 1.0f, 0.0f} + }}, {new std::vector{ + {0.0f, 0.0f, 1.0f}, + {0.0f, 0.0f, 1.0f}, + {0.0f, 0.0f, 1.0f}, + {0.0f, 0.0f, 1.0f} + }}, {}); +} + +Trade::MeshData3D Plane::wireframe() { + return Trade::MeshData3D(Mesh::Primitive::LineLoop, nullptr, {new std::vector{ + {-1.0f, -1.0f, 0.0f}, + {1.0f, -1.0f, 0.0f}, + {1.0f, 1.0f, 0.0f}, + {-1.0f, 1.0f, 0.0f} + }}, {}, {}); +} }} diff --git a/src/Primitives/Plane.h b/src/Primitives/Plane.h index 9de4f9a2b..b19ef792a 100644 --- a/src/Primitives/Plane.h +++ b/src/Primitives/Plane.h @@ -19,7 +19,7 @@ * @brief Class Magnum::Primitives::Plane */ -#include "Trade/MeshData3D.h" +#include "Trade/Trade.h" namespace Magnum { namespace Primitives { @@ -28,10 +28,24 @@ namespace Magnum { namespace Primitives { 2x2 plane as triangle strip, non-indexed with normals in positive Z direction. */ -class Plane: public Trade::MeshData3D { +class Plane { public: - /** @brief Constructor */ - explicit Plane(); + /** + * @brief Solid plane + * + * Non-indexed @ref Mesh::Primitive "TriangleStrip" with normals in + * positive Z direction. + */ + static Trade::MeshData3D solid(); + + /** + * @brief Wireframe plane + * + * Non-indexed @ref Mesh::Primitive "LineLoop". + */ + static Trade::MeshData3D wireframe(); + + Plane() = delete; }; }}