vrshoot

diff libs/assimp/StandardShapes.h @ 0:b2f14e535253

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 01 Feb 2014 19:58:19 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libs/assimp/StandardShapes.h	Sat Feb 01 19:58:19 2014 +0200
     1.3 @@ -0,0 +1,196 @@
     1.4 +/*
     1.5 +Open Asset Import Library (assimp)
     1.6 +----------------------------------------------------------------------
     1.7 +
     1.8 +Copyright (c) 2006-2012, assimp team
     1.9 +All rights reserved.
    1.10 +
    1.11 +Redistribution and use of this software in source and binary forms, 
    1.12 +with or without modification, are permitted provided that the 
    1.13 +following conditions are met:
    1.14 +
    1.15 +* Redistributions of source code must retain the above
    1.16 +  copyright notice, this list of conditions and the
    1.17 +  following disclaimer.
    1.18 +
    1.19 +* Redistributions in binary form must reproduce the above
    1.20 +  copyright notice, this list of conditions and the
    1.21 +  following disclaimer in the documentation and/or other
    1.22 +  materials provided with the distribution.
    1.23 +
    1.24 +* Neither the name of the assimp team, nor the names of its
    1.25 +  contributors may be used to endorse or promote products
    1.26 +  derived from this software without specific prior
    1.27 +  written permission of the assimp team.
    1.28 +
    1.29 +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    1.30 +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    1.31 +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    1.32 +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    1.33 +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    1.34 +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
    1.35 +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    1.36 +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
    1.37 +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    1.38 +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
    1.39 +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    1.40 +
    1.41 +----------------------------------------------------------------------
    1.42 +*/
    1.43 +
    1.44 +/** @file Declares a helper class, "StandardShapes" which generates
    1.45 + *  vertices for standard shapes, such as cylnders, cones, spheres ..
    1.46 + */
    1.47 +#ifndef AI_STANDARD_SHAPES_H_INC
    1.48 +#define AI_STANDARD_SHAPES_H_INC
    1.49 +
    1.50 +#include <vector>
    1.51 +
    1.52 +
    1.53 +namespace Assimp	{
    1.54 +
    1.55 +// ---------------------------------------------------------------------------
    1.56 +/** \brief Helper class to generate vertex buffers for standard geometric
    1.57 + *  shapes, such as cylinders, cones, boxes, spheres, elipsoids ... .
    1.58 + */
    1.59 +class StandardShapes
    1.60 +{
    1.61 +	// class cannot be instanced
    1.62 +	StandardShapes() {}
    1.63 +
    1.64 +public:
    1.65 +
    1.66 +
    1.67 +	// ----------------------------------------------------------------
    1.68 +	/** Generates a mesh from an array of vertex positions.
    1.69 +	 *
    1.70 +	 *  @param positions List of vertex positions
    1.71 +	 *  @param numIndices Number of indices per primitive
    1.72 +	 *  @return Output mesh
    1.73 +	 */
    1.74 +	static aiMesh* MakeMesh(const std::vector<aiVector3D>& positions,
    1.75 +		unsigned int numIndices);
    1.76 +
    1.77 +
    1.78 +	static aiMesh* MakeMesh ( unsigned int (*GenerateFunc)
    1.79 +		(std::vector<aiVector3D>&));
    1.80 +
    1.81 +	static aiMesh* MakeMesh ( unsigned int (*GenerateFunc)
    1.82 +		(std::vector<aiVector3D>&, bool));
    1.83 +
    1.84 +	static aiMesh* MakeMesh ( unsigned int n,  void (*GenerateFunc)
    1.85 +		(unsigned int,std::vector<aiVector3D>&));
    1.86 +
    1.87 +	// ----------------------------------------------------------------
    1.88 +	/** @brief Generates a hexahedron (cube)
    1.89 +	 *
    1.90 +	 *  Hexahedrons can be scaled on all axes.
    1.91 +	 *  @param positions Receives output triangles.
    1.92 +	 *  @param polygons If you pass true here quads will be returned
    1.93 +	 *  @return Number of vertices per face
    1.94 +	 */
    1.95 +	static unsigned int MakeHexahedron(
    1.96 +		std::vector<aiVector3D>& positions,
    1.97 +		bool polygons = false);
    1.98 +
    1.99 +	// ----------------------------------------------------------------
   1.100 +	/** @brief Generates an icosahedron
   1.101 +	 *
   1.102 +	 *  @param positions Receives output triangles.
   1.103 +	 *  @return Number of vertices per face
   1.104 +	 */
   1.105 +	static unsigned int MakeIcosahedron(
   1.106 +		std::vector<aiVector3D>& positions);
   1.107 +
   1.108 +
   1.109 +	// ----------------------------------------------------------------
   1.110 +	/** @brief Generates a dodecahedron
   1.111 +	 *
   1.112 +	 *  @param positions Receives output triangles
   1.113 +	 *  @param polygons If you pass true here pentagons will be returned
   1.114 +	 *  @return Number of vertices per face
   1.115 +	 */
   1.116 +	static unsigned int MakeDodecahedron(
   1.117 +		std::vector<aiVector3D>& positions,
   1.118 +		bool polygons = false);
   1.119 +
   1.120 +
   1.121 +	// ----------------------------------------------------------------
   1.122 +	/** @brief Generates an octahedron
   1.123 +	 *
   1.124 +	 *  @param positions Receives output triangles.
   1.125 +	 *  @return Number of vertices per face
   1.126 +	 */
   1.127 +	static unsigned int MakeOctahedron(
   1.128 +		std::vector<aiVector3D>& positions);
   1.129 +
   1.130 +
   1.131 +	// ----------------------------------------------------------------
   1.132 +	/** @brief Generates a tetrahedron
   1.133 +	 *
   1.134 +	 *  @param positions Receives output triangles.
   1.135 +	 *  @return Number of vertices per face
   1.136 +	 */
   1.137 +	static unsigned int MakeTetrahedron(
   1.138 +		std::vector<aiVector3D>& positions);
   1.139 +
   1.140 +
   1.141 +
   1.142 +	// ----------------------------------------------------------------
   1.143 +	/** @brief Generates a sphere
   1.144 +	 *
   1.145 +	 *  @param tess Number of subdivions - 0 generates a octahedron
   1.146 +	 *  @param positions Receives output triangles.
   1.147 +	 */
   1.148 +	static void MakeSphere(unsigned int tess,
   1.149 +		std::vector<aiVector3D>& positions);
   1.150 +
   1.151 +
   1.152 +	// ----------------------------------------------------------------
   1.153 +	/** @brief Generates a cone or a cylinder, either open or closed.
   1.154 +	 *
   1.155 +	 *  @code
   1.156 +	 *
   1.157 +	 *       |-----|       <- radius 1
   1.158 +	 *
   1.159 +	 *        __x__        <- ]               ^
   1.160 +	 *       /     \          | height        |
   1.161 +	 *      /       \         |               Y                 
   1.162 +	 *     /         \        |
   1.163 +	 *    /	          \       |
   1.164 +	 *   /______x______\   <- ] <- end cap
   1.165 +	 *
   1.166 +	 *   |-------------|   <- radius 2
   1.167 +	 *
   1.168 +	 *  @endcode
   1.169 +	 *
   1.170 +	 *  @param height Height of the cone
   1.171 +	 *  @param radius1 First radius
   1.172 +	 *  @param radius2 Second radius
   1.173 +	 *  @param tess Number of triangles.
   1.174 +	 *  @param bOpened true for an open cone/cylinder. An open shape has
   1.175 +	 *    no 'end caps'
   1.176 +	 *  @param positions Receives output triangles
   1.177 +	 */
   1.178 +	static void MakeCone(float height,float radius1,
   1.179 +		float radius2,unsigned int tess, 
   1.180 +		std::vector<aiVector3D>& positions,bool bOpen= false);
   1.181 +
   1.182 +
   1.183 +	// ----------------------------------------------------------------
   1.184 +	/** @brief Generates a flat circle
   1.185 +	 *
   1.186 +	 *  The circle is constructed in the planed formed by the x,z
   1.187 +	 *  axes of the cartesian coordinate system.
   1.188 +	 *  
   1.189 +	 *  @param radius Radius of the circle
   1.190 +	 *  @param tess Number of segments.
   1.191 +	 *  @param positions Receives output triangles.
   1.192 +	 */
   1.193 +	static void MakeCircle(float radius, unsigned int tess,
   1.194 +		std::vector<aiVector3D>& positions);
   1.195 +	
   1.196 +};
   1.197 +} // ! Assimp
   1.198 +
   1.199 +#endif // !! AI_STANDARD_SHAPES_H_INC