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