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 {
Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, new vector<uint32_t>{
0, 2, 1,
2, 3, 1,
1, 3, 5,
3, 7, 5,
5, 7, 4,
7, 6, 4,
4, 6, 0,
6, 2, 0,
2, 7, 3,
2, 6, 7,
4, 1, 5,
4, 0, 1
}, {new vector<Point3D>}, {new vector<Vector3>{
Cube::Cube(): MeshData3D("", Mesh::Primitive::Triangles, nullptr, {new vector<Point3D>{
{-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}, /* +X */
{ 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}, /* +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}, /* -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}, /* -Y */
{-1.0f, -1.0f, -1.0f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(0)->end());
}
}}

3
src/Primitives/Cube.h

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

Loading…
Cancel
Save