Browse Source

Primitives: added Cube::solidStrip().

Took me more than year of procrastination until someone finally
completely figured it out for me. Thanks y'all.
pull/94/head
Vladimír Vondruš 11 years ago
parent
commit
7ea9e82796
  1. 42
      src/Magnum/Primitives/Cube.cpp
  2. 8
      src/Magnum/Primitives/Cube.h

42
src/Magnum/Primitives/Cube.cpp

@ -102,6 +102,48 @@ Trade::MeshData3D Cube::solid() {
}}, {});
}
Trade::MeshData3D Cube::solidStrip() {
/* Sources:
https://twitter.com/Donzanoid/status/436843034966507520
http://www.asmcommunity.net/forums/topic/?id=6284#post-45209
https://gist.github.com/cdwfs/2cab675b333632d940cf
0---2---3---1
|E /|\ A|H /|
| / | \ | / |
|/ D|B \|/ I|
4---7---6---5
|C /|
| / |
|/ J|
4---5
|\ K|
| \ |
|L \|
0---1
|\ G|
| \ |
|F \|
2---3
*/
return Trade::MeshData3D(MeshPrimitive::TriangleStrip, {}, {{
{ 1.0f, 1.0f, 1.0f}, /* 3 */
{-1.0f, 1.0f, 1.0f}, /* 2 */
{ 1.0f, -1.0f, 1.0f}, /* 6 */
{-1.0f, -1.0f, 1.0f}, /* 7 */
{-1.0f, -1.0f, -1.0f}, /* 4 */
{-1.0f, 1.0f, 1.0f}, /* 2 */
{-1.0f, 1.0f, -1.0f}, /* 0 */
{ 1.0f, 1.0f, 1.0f}, /* 3 */
{ 1.0f, 1.0f, -1.0f}, /* 1 */
{ 1.0f, -1.0f, 1.0f}, /* 6 */
{ 1.0f, -1.0f, -1.0f}, /* 5 */
{-1.0f, -1.0f, -1.0f}, /* 4 */
{ 1.0f, 1.0f, -1.0f}, /* 1 */
{-1.0f, 1.0f, -1.0f} /* 0 */
}}, {}, {});
}
Trade::MeshData3D Cube::wireframe() {
return Trade::MeshData3D(MeshPrimitive::Lines, {
0, 1, 1, 2, 2, 3, 3, 0, /* +Z */

8
src/Magnum/Primitives/Cube.h

@ -48,6 +48,14 @@ class MAGNUM_PRIMITIVES_EXPORT Cube {
*/
static Trade::MeshData3D solid();
/**
* @brief Solid cube as a single strip
*
* Non-indexed @ref MeshPrimitive::TriangleStrip. Just positions, no
* normals or anything else.
*/
static Trade::MeshData3D solidStrip();
/**
* @brief Wireframe cube
*

Loading…
Cancel
Save