Browse Source

Cube primitive has now flat normals.

Exactly how would everyone expect.
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
72ffca1dad
  1. 95
      src/Primitives/Cube.cpp
  2. 3
      src/Primitives/Cube.h

95
src/Primitives/Cube.cpp

@ -21,30 +21,91 @@ using namespace std;
namespace Magnum { namespace Primitives { namespace Magnum { namespace Primitives {
Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, new vector<uint32_t>{ Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, nullptr, {new vector<Point3D>{
0, 2, 1, {-1.0f, -1.0f, 1.0f},
2, 3, 1, { 1.0f, -1.0f, 1.0f},
1, 3, 5, { 1.0f, 1.0f, 1.0f}, /* +Z */
3, 7, 5, {-1.0f, -1.0f, 1.0f},
5, 7, 4, { 1.0f, 1.0f, 1.0f},
7, 6, 4, {-1.0f, 1.0f, 1.0f},
4, 6, 0,
6, 2, 0, { 1.0f, -1.0f, 1.0f},
2, 7, 3, { 1.0f, -1.0f, -1.0f},
2, 6, 7, { 1.0f, 1.0f, -1.0f}, /* +X */
4, 1, 5, { 1.0f, -1.0f, 1.0f},
4, 0, 1 { 1.0f, 1.0f, -1.0f},
}, {new vector<Point3D>}, {new vector<Vector3>{ { 1.0f, 1.0f, 1.0f},
{-1.0f, 1.0f, 1.0f},
{ 1.0f, 1.0f, 1.0f},
{ 1.0f, 1.0f, -1.0f}, /* +Y */
{-1.0f, 1.0f, 1.0f},
{ 1.0f, 1.0f, -1.0f},
{-1.0f, 1.0f, -1.0f},
{ 1.0f, -1.0f, -1.0f},
{-1.0f, -1.0f, -1.0f}, {-1.0f, -1.0f, -1.0f},
{-1.0f, 1.0f, -1.0f}, /* -Z */
{ 1.0f, -1.0f, -1.0f}, { 1.0f, -1.0f, -1.0f},
{-1.0f, 1.0f, -1.0f}, {-1.0f, 1.0f, -1.0f},
{ 1.0f, 1.0f, -1.0f}, { 1.0f, 1.0f, -1.0f},
{-1.0f, -1.0f, 1.0f},
{-1.0f, -1.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
{-1.0f, 0.0f, 0.0f}, /* -X */
{-1.0f, 0.0f, 0.0f},
{-1.0f, 0.0f, 0.0f},
{-1.0f, 0.0f, 0.0f}
}}, {}) { }}, {}) {
positions(0)->assign(normals(0)->begin(), normals(0)->end());
} }
}} }}

3
src/Primitives/Cube.h

@ -26,8 +26,7 @@ namespace Magnum { namespace Primitives {
/** /**
@brief 3D cube primitive @brief 3D cube primitive
Indexed triangle mesh with smooth normals. 2x2x2 cube. Non-indexed triangle mesh with flat normals.
@todo Does anyone EVER want smooth normals on a cube?!
*/ */
class Cube: public Trade::MeshData3D { class Cube: public Trade::MeshData3D {
public: public:

Loading…
Cancel
Save