Browse Source

Primitives: Plane can be now solid or wireframe.

pull/7/head
Vladimír Vondruš 13 years ago
parent
commit
25b752a311
  1. 34
      src/Primitives/Plane.cpp
  2. 22
      src/Primitives/Plane.h

34
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<Point3D>{
{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<Vector3>{
{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<Point3D>{
{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<Vector3>{
{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<Point3D>{
{-1.0f, -1.0f, 0.0f},
{1.0f, -1.0f, 0.0f},
{1.0f, 1.0f, 0.0f},
{-1.0f, 1.0f, 0.0f}
}}, {}, {});
}
}}

22
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;
};
}}

Loading…
Cancel
Save