Browse Source

MeshTools: updates for the new documentation theme.

pull/225/head
Vladimír Vondruš 8 years ago
parent
commit
eee9cbb353
  1. 3
      src/Magnum/MeshTools/CombineIndexedArrays.h
  2. 4
      src/Magnum/MeshTools/Compile.h
  3. 6
      src/Magnum/MeshTools/CompressIndices.h
  4. 13
      src/Magnum/MeshTools/FullScreenTriangle.h
  5. 4
      src/Magnum/MeshTools/GenerateFlatNormals.h
  6. 9
      src/Magnum/MeshTools/Interleave.h
  7. 8
      src/Magnum/MeshTools/RemoveDuplicates.h
  8. 24
      src/Magnum/MeshTools/Subdivide.h
  9. 2
      src/Magnum/MeshTools/Tipsify.h
  10. 6
      src/Magnum/MeshTools/Transform.h

3
src/Magnum/MeshTools/CombineIndexedArrays.h

@ -157,7 +157,8 @@ attribute array as reference, so it can be replaced with combined data. To
avoid explicit verbose specification of tuple type, you can write it with help
of some STL functions like shown below. Also if one index array is shared by
more than one attribute array, just pass the index array more times. Example:
@code
@code{.cpp}
std::vector<UnsignedInt> vertexIndices;
std::vector<Vector3> positions;
std::vector<UnsignedInt> normalTextureIndices;

4
src/Magnum/MeshTools/Compile.h

@ -49,7 +49,7 @@ attribute. No data compression or index optimization (except for index buffer
packing) is done. The @p usage parameter is used for both vertex and index
buffer.
The second returned buffer may be `nullptr` if the mesh is not indexed.
The second returned buffer may be @cpp nullptr @ce if the mesh is not indexed.
This is just a convenience function for creating generic meshes, you might want
to use @ref interleave() and @ref compressIndices() functions instead for
@ -70,7 +70,7 @@ bound to @ref Shaders::Generic2D::TextureCoordinates attribute. No data
compression or index optimization (except for index buffer packing) is done.
The @p usage parameter is used for both vertex and index buffer.
The second returned buffer may be `nullptr` if the mesh is not indexed.
The second returned buffer may be @cpp nullptr @ce if the mesh is not indexed.
This is just a convenience function for creating generic meshes, you might want
to use @ref interleave() and @ref compressIndices() functions instead for

6
src/Magnum/MeshTools/CompressIndices.h

@ -47,7 +47,8 @@ wasteful to store them in array of 32bit integers, array of 16bit integers is
sufficient.
Example usage:
@code
@code{.cpp}
std::vector<UnsignedInt> indices;
Containers::Array<char> indexData;
@ -76,7 +77,8 @@ The type can be either @ref Magnum::UnsignedByte "UnsignedByte",
Values in the index array are expected to be representable with given type.
Example usage:
@code
@code{.cpp}
std::vector<UnsignedInt> indices;
Containers::Array<UnsignedShort> indexData = MeshTools::compressIndicesAs<UnsignedShort>(indices);
@endcode

13
src/Magnum/MeshTools/FullScreenTriangle.h

@ -52,15 +52,16 @@ computed from them. The vertex positions are, in order:
@f]
Based on @p version parameter, on OpenGL 2.1 and OpenGL ES 2.0 the vertex
positions are passed explicitly as attribute `0`, contained in the buffer. On
OpenGL 3.0+ and OpenGL ES 3.0+ the mesh is attribute-less and the vertex
positions can be computed using `gl_VertexID` builtin shader variable, thus
`nullptr` is returned instead of vertex buffer.
positions are passed explicitly as attribute @cpp 0 @ce, contained in the
buffer. On OpenGL 3.0+ and OpenGL ES 3.0+ the mesh is attribute-less and the
vertex positions can be computed using @glsl gl_VertexID @ce builtin shader
variable, thus @cpp nullptr @ce is returned instead of vertex buffer.
Computing positions in vertex shader in a portable way might be done like this.
For OpenGL 2.1 and OpenGL ES 2.0 you then need to bind the location of `position`
attribute to `0`.
@code
attribute to @cpp 0 @ce.
@code{.glsl}
#if (!defined(GL_ES) && __VERSION__ >= 130) || (defined(GL_ES) && __VERSION__ >= 300)
#define NEW_GLSL
#endif

4
src/Magnum/MeshTools/GenerateFlatNormals.h

@ -45,7 +45,8 @@ namespace Magnum { namespace MeshTools {
For each face generates one normal vector, removes duplicates before
returning. Example usage:
@code
@code{.cpp}
std::vector<UnsignedInt> vertexIndices;
std::vector<Vector3> positions;
@ -53,6 +54,7 @@ std::vector<UnsignedInt> normalIndices;
std::vector<Vector3> normals;
std::tie(normalIndices, normals) = MeshTools::generateFlatNormals(vertexIndices, positions);
@endcode
You can then use @ref combineIndexedArrays() to combine normal and vertex array
to use the same indices.

9
src/Magnum/MeshTools/Interleave.h

@ -99,7 +99,8 @@ This function takes list of attribute arrays and returns them interleaved, so
data for each attribute are in continuous place in memory.
Example usage:
@code
@code{.cpp}
MeshPrimitive primitive;
std::vector<Vector3> positions;
std::vector<Vector2> textureCoordinates;
@ -115,13 +116,15 @@ mesh.setPrimitive(primitive)
It's often desirable to align data for one vertex on 32bit boundaries. To
achieve that, you can specify gaps between the attributes:
@code
@code{.cpp}
std::vector<Vector4> positions;
std::vector<UnsignedShort> weights;
std::vector<Color3ub> vertexColors;
auto data = MeshTools::interleave(positions, weights, 2, textureCoordinates, 1);
@endcode
All gap bytes are set zero. This way vertex stride is 24 bytes, without gaps it
would be 21 bytes, causing possible performance loss.
@ -130,7 +133,7 @@ would be 21 bytes, causing possible performance loss.
@note The only requirements to attribute array type is that it must have
typedef `T::value_type`, forward iterator (to be used with range-based
for) and function `size()` returning count of elements. In most cases it
will be `std::vector` or `std::array`.
will be @ref std::vector or @ref std::array.
@see @ref interleaveInto()
*/

8
src/Magnum/MeshTools/RemoveDuplicates.h

@ -52,7 +52,7 @@ namespace Implementation {
/**
@brief Remove duplicate floating-point vector data from given array
@param[in,out] data Input data array
@param[out] epsilon Epsilon value, vertices nearer than this distance will be
@param[in] epsilon Epsilon value, vertices nearer than this distance will be
melt together
@return Index array and unique data
@ -65,7 +65,8 @@ the usual sorting method is much more efficient.
If you want to remove duplicate data from already indexed array, first remove
duplicates as if the array wasn't indexed at all and then use @ref duplicate()
to combine the two index arrays:
@code
@code{.cpp}
std::vector<UnsignedInt> indices;
std::vector<Vector3> positions;
@ -76,7 +77,8 @@ Removing duplicates in multiple indcidental arrays is also possible -- first
remove duplicates in each array separately and then use @ref combineIndexedArrays()
to combine the resulting index arrays to single index array and reorder the
data accordingly:
@code
@code{.cpp}
std::vector<Vector3> positions;
std::vector<Vector2> texCoords;

24
src/Magnum/MeshTools/Subdivide.h

@ -92,18 +92,18 @@ template<class Vertex, class Interpolator> void Subdivide<Vertex, Interpolator>:
newVertices[j] = addVertex(interpolator(vertices[indices[i+j]], vertices[indices[i+(j+1)%3]]));
/*
* Add three new faces (0, 1, 3) and update original (2)
*
* orig 0
* / \
* / 0 \
* / \
* new 0 ----- new 2
* / \ / \
* / 1 \ 2 / 3 \
* / \ / \
* orig 1 ----- new 1 ---- orig 2
*/
Add three new faces (0, 1, 3) and update original (2)
orig 0
/ \
/ 0 \
/ \
new 0 ----- new 2
/ \ / \
/ 1 \ 2 / 3 \
/ \ / \
orig 1 ----- new 1 ---- orig 2
*/
addFace(indices[i], newVertices[0], newVertices[2]);
addFace(newVertices[0], indices[i+1], newVertices[1]);
addFace(newVertices[2], newVertices[1], indices[i+2]);

2
src/Magnum/MeshTools/Tipsify.h

@ -68,7 +68,7 @@ class MAGNUM_MESHTOOLS_EXPORT Tipsify {
Optimizes the mesh for vertex-bound applications by rearranging its index
array for beter usage of post-transform vertex cache. Algorithm used:
*Pedro V. Sander, Diego Nehab, and Joshua Barczak - Fast Triangle Reordering
*Pedro V. Sander, Diego Nehab, and Joshua Barczak --- Fast Triangle Reordering
for Vertex Locality and Reduced Overdraw, SIGGRAPH 2007,
http://gfx.cs.princeton.edu/pubs/Sander_2007_%3ETR/index.php*.
@todo Ability to compute vertex count automatically

6
src/Magnum/MeshTools/Transform.h

@ -47,7 +47,8 @@ Unlike in @ref transformPointsInPlace(), the transformation does not involve
translation.
Example usage:
@code
@code{.cpp}
std::vector<Vector3> vectors;
auto transformation = Quaternion::rotation(35.0_degf, Vector3::yAxis());
MeshTools::transformVectorsInPlace(rotation, vectors);
@ -102,7 +103,8 @@ Unlike in @ref transformVectorsInPlace(), the transformation also involves
translation.
Example usage:
@code
@code{.cpp}
std::vector<Vector3> points;
auto transformation = DualQuaternion::rotation(35.0_degf, Vector3::yAxis())*
DualQuaternion::translation({0.5f, -1.0f, 3.0f});

Loading…
Cancel
Save