Browse Source

Making Icosahedron primitive data public, so it could be reused.

pull/279/head
Vladimír Vondruš 15 years ago
parent
commit
2b3aab35f6
  1. 11
      src/Primitives/Icosphere.cpp
  2. 21
      src/Primitives/Icosphere.h

11
src/Primitives/Icosphere.cpp

@ -17,13 +17,7 @@
namespace Magnum { namespace Primitives {
/**
* @todo Use own computed (and more precise) icosahedron data, not these stolen
* from Blender.
*/
#ifndef DOXYGEN_GENERATING_OUTPUT
const Vector4 _AbstractIcosphere::initialVertices[] = {
const Vector4 Icosahedron::vertices[] = {
Vector4(0, -0.525731f, 0.850651f),
Vector4(0.850651f, 0, 0.525731f),
Vector4(0.850651f, 0, -0.525731f),
@ -37,7 +31,7 @@ const Vector4 _AbstractIcosphere::initialVertices[] = {
Vector4(0, 0.525731f, -0.850651f),
Vector4(0, 0.525731f, 0.850651f),
};
const GLubyte _AbstractIcosphere::initialIndices[] = {
const GLubyte Icosahedron::indices[] = {
1, 2, 6,
1, 7, 2,
3, 4, 5,
@ -59,6 +53,5 @@ const GLubyte _AbstractIcosphere::initialIndices[] = {
3, 9, 8,
4, 8, 0
};
#endif
}}

21
src/Primitives/Icosphere.h

@ -25,22 +25,23 @@
namespace Magnum { namespace Primitives {
#ifndef DOXYGEN_GENERATING_OUTPUT
class _AbstractIcosphere {
public:
~_AbstractIcosphere() {}
/**
@brief Icosahedron
protected:
static const Vector4 initialVertices[];
static const GLubyte initialIndices[];
@todo Use own computed (and more precise) icosahedron data, not these stolen
from Blender.
*/
class Icosahedron {
public:
static const Vector4 vertices[]; /**< @brief Vertices */
static const GLubyte indices[]; /**< @brief Indices */
};
#endif
/**
* @brief %Icosphere primitive
* @tparam subdivisions Number of subdivisions
*/
template<size_t subdivisions> class Icosphere: public AbstractPrimitive<typename SizeTraits<Log<256, Pow<4, subdivisions>::value*20*3>::value>::SizeType>, _AbstractIcosphere {
template<size_t subdivisions> class Icosphere: public AbstractPrimitive<typename SizeTraits<Log<256, Pow<4, subdivisions>::value*20*3>::value>::SizeType> {
public:
Icosphere() {
if(vertexCount() == 0) subdivide();
@ -63,7 +64,7 @@ template<size_t subdivisions> class Icosphere: public AbstractPrimitive<typename
}
static void subdivide() {
builder()->setData(initialVertices, initialIndices, 12, 60);
builder()->setData(Icosahedron::vertices, Icosahedron::indices, 12, 60);
for(size_t i = 0; i != subdivisions; ++i)
builder()->subdivide([](const Vector4& a, const Vector4& b) {

Loading…
Cancel
Save