From 341a70a7f4c5d24dfa62ad4159b2a695301736c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 21 Jan 2018 22:32:47 +0100 Subject: [PATCH] Primitives: document how to scale capsule / cylinder to preserve normals. --- src/Magnum/Primitives/Capsule.h | 6 ++++++ src/Magnum/Primitives/Cylinder.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/Magnum/Primitives/Capsule.h b/src/Magnum/Primitives/Capsule.h index cfe7a7920..cfb052149 100644 --- a/src/Magnum/Primitives/Capsule.h +++ b/src/Magnum/Primitives/Capsule.h @@ -81,6 +81,12 @@ class MAGNUM_PRIMITIVES_EXPORT Capsule3D { * Indexed @ref MeshPrimitive::Triangles with normals and optional 2D * texture coordinates. If texture coordinates are generated, vertices * of one segment are duplicated for texture wrapping. + * + * The capsule is by default created with radius set to @cpp 1.0f @ce. + * In order to get radius @f$ r @f$, length @f$ l @f$ and preserve + * correct normals, set @p halfLength to @f$ 0.5 \frac{l}{r} @f$ and + * then scale all @ref Trade::MeshData3D::positions() by @f$ r @f$, for + * example using @ref MeshTools::transformPointsInPlace(). */ static Trade::MeshData3D solid(UnsignedInt hemisphereRings, UnsignedInt cylinderRings, UnsignedInt segments, Float halfLength, TextureCoords textureCoords = TextureCoords::DontGenerate); diff --git a/src/Magnum/Primitives/Cylinder.h b/src/Magnum/Primitives/Cylinder.h index e3035f893..39f4a3d7d 100644 --- a/src/Magnum/Primitives/Cylinder.h +++ b/src/Magnum/Primitives/Cylinder.h @@ -74,6 +74,12 @@ class MAGNUM_PRIMITIVES_EXPORT Cylinder { * texture coordinates and optional capped ends. If texture coordinates * are generated, vertices of one segment are duplicated for texture * wrapping. + * + * The cylinder is by default created with radius set to @cpp 1.0f @ce. + * In order to get radius @f$ r @f$, length @f$ l @f$ and preserve + * correct normals, set @p halfLength to @f$ 0.5 \frac{l}{r} @f$ and + * then scale all @ref Trade::MeshData3D::positions() by @f$ r @f$, for + * example using @ref MeshTools::transformPointsInPlace(). */ static Trade::MeshData3D solid(UnsignedInt rings, UnsignedInt segments, Float halfLength, Flags flags = Flags());