1/*
2Open Asset Import Library (assimp)
3----------------------------------------------------------------------
4
5Copyright (c) 2006-2017, assimp team
6
7All rights reserved.
8
9Redistribution and use of this software in source and binary forms,
10with or without modification, are permitted provided that the
11following conditions are met:
12
13* Redistributions of source code must retain the above
14 copyright notice, this list of conditions and the
15 following disclaimer.
16
17* Redistributions in binary form must reproduce the above
18 copyright notice, this list of conditions and the
19 following disclaimer in the documentation and/or other
20 materials provided with the distribution.
21
22* Neither the name of the assimp team, nor the names of its
23 contributors may be used to endorse or promote products
24 derived from this software without specific prior
25 written permission of the assimp team.
26
27THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
30A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
31OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
33LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
37OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38
39----------------------------------------------------------------------
40*/
41
42/** @file Declares a helper class, "StandardShapes" which generates
43 * vertices for standard shapes, such as cylnders, cones, spheres ..
44 */
45#ifndef AI_STANDARD_SHAPES_H_INC
46#define AI_STANDARD_SHAPES_H_INC
47
48#include <assimp/vector3.h>
49#include <vector>
50
51struct aiMesh;
52
53namespace Assimp {
54
55// ---------------------------------------------------------------------------
56/** \brief Helper class to generate vertex buffers for standard geometric
57 * shapes, such as cylinders, cones, boxes, spheres, elipsoids ... .
58 */
59class StandardShapes
60{
61 // class cannot be instanced
62 StandardShapes() {}
63
64public:
65
66
67 // ----------------------------------------------------------------
68 /** Generates a mesh from an array of vertex positions.
69 *
70 * @param positions List of vertex positions
71 * @param numIndices Number of indices per primitive
72 * @return Output mesh
73 */
74 static aiMesh* MakeMesh(const std::vector<aiVector3D>& positions,
75 unsigned int numIndices);
76
77
78 static aiMesh* MakeMesh ( unsigned int (*GenerateFunc)
79 (std::vector<aiVector3D>&));
80
81 static aiMesh* MakeMesh ( unsigned int (*GenerateFunc)
82 (std::vector<aiVector3D>&, bool));
83
84 static aiMesh* MakeMesh ( unsigned int n, void (*GenerateFunc)
85 (unsigned int,std::vector<aiVector3D>&));
86
87 // ----------------------------------------------------------------
88 /** @brief Generates a hexahedron (cube)
89 *
90 * Hexahedrons can be scaled on all axes.
91 * @param positions Receives output triangles.
92 * @param polygons If you pass true here quads will be returned
93 * @return Number of vertices per face
94 */
95 static unsigned int MakeHexahedron(
96 std::vector<aiVector3D>& positions,
97 bool polygons = false);
98
99 // ----------------------------------------------------------------
100 /** @brief Generates an icosahedron
101 *
102 * @param positions Receives output triangles.
103 * @return Number of vertices per face
104 */
105 static unsigned int MakeIcosahedron(
106 std::vector<aiVector3D>& positions);
107
108
109 // ----------------------------------------------------------------
110 /** @brief Generates a dodecahedron
111 *
112 * @param positions Receives output triangles
113 * @param polygons If you pass true here pentagons will be returned
114 * @return Number of vertices per face
115 */
116 static unsigned int MakeDodecahedron(
117 std::vector<aiVector3D>& positions,
118 bool polygons = false);
119
120
121 // ----------------------------------------------------------------
122 /** @brief Generates an octahedron
123 *
124 * @param positions Receives output triangles.
125 * @return Number of vertices per face
126 */
127 static unsigned int MakeOctahedron(
128 std::vector<aiVector3D>& positions);
129
130
131 // ----------------------------------------------------------------
132 /** @brief Generates a tetrahedron
133 *
134 * @param positions Receives output triangles.
135 * @return Number of vertices per face
136 */
137 static unsigned int MakeTetrahedron(
138 std::vector<aiVector3D>& positions);
139
140
141
142 // ----------------------------------------------------------------
143 /** @brief Generates a sphere
144 *
145 * @param tess Number of subdivions - 0 generates a octahedron
146 * @param positions Receives output triangles.
147 */
148 static void MakeSphere(unsigned int tess,
149 std::vector<aiVector3D>& positions);
150
151
152 // ----------------------------------------------------------------
153 /** @brief Generates a cone or a cylinder, either open or closed.
154 *
155 * @code
156 *
157 * |-----| <- radius 1
158 *
159 * __x__ <- ] ^
160 * / \ | height |
161 * / \ | Y
162 * / \ |
163 * / \ |
164 * /______x______\ <- ] <- end cap
165 *
166 * |-------------| <- radius 2
167 *
168 * @endcode
169 *
170 * @param height Height of the cone
171 * @param radius1 First radius
172 * @param radius2 Second radius
173 * @param tess Number of triangles.
174 * @param bOpened true for an open cone/cylinder. An open shape has
175 * no 'end caps'
176 * @param positions Receives output triangles
177 */
178 static void MakeCone(ai_real height,ai_real radius1,
179 ai_real radius2,unsigned int tess,
180 std::vector<aiVector3D>& positions,bool bOpen= false);
181
182
183 // ----------------------------------------------------------------
184 /** @brief Generates a flat circle
185 *
186 * The circle is constructed in the planned formed by the x,z
187 * axes of the cartesian coordinate system.
188 *
189 * @param radius Radius of the circle
190 * @param tess Number of segments.
191 * @param positions Receives output triangles.
192 */
193 static void MakeCircle(ai_real radius, unsigned int tess,
194 std::vector<aiVector3D>& positions);
195
196};
197} // ! Assimp
198
199#endif // !! AI_STANDARD_SHAPES_H_INC
200