Allolib  1.0
C++ Components For Interactive Multimedia
al_Shapes.hpp
1 #ifndef INCLUDE_AL_GRAPHICS_SHAPES_HPP
2 #define INCLUDE_AL_GRAPHICS_SHAPES_HPP
3 
4 /* Allocore --
5  Multimedia / virtual environment application class library
6 
7  Copyright (C) 2009. AlloSphere Research Group, Media Arts & Technology, UCSB.
8  Copyright (C) 2012. The Regents of the University of California.
9  All rights reserved.
10 
11  Redistribution and use in source and binary forms, with or without
12  modification, are permitted provided that the following conditions are met:
13 
14  Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16 
17  Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20 
21  Neither the name of the University of California nor the names of its
22  contributors may be used to endorse or promote products derived from
23  this software without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
29  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35  POSSIBILITY OF SUCH DAMAGE.
36 
37 
38  File description:
39  Factory methods for standard geometries
40 
41  File author(s):
42  Lance Putnam, 2010, putnam.lance@gmail.com
43  Keehong Youn, 2017, younkeehong@gmail.com
44 
45 */
46 
47 #include "al/graphics/al_Mesh.hpp"
48 
49 namespace al {
50 
52 
58 int addTetrahedron(Mesh& m, float radius = 1);
59 
61 
67 int addCube(Mesh& m, bool withNormalsAndTexcoords = false,
68  float radius = M_SQRT_1_3);
69 
71 
77 int addOctahedron(Mesh& m, float radius = 1);
78 
80 
86 int addDodecahedron(Mesh& m, float radius = 1);
87 
89 
95 int addIcosahedron(Mesh& m, float radius = 1);
96 
98 
103 int addIcosphere(Mesh& m, double radius = 1, int divisions = 2);
104 
106 
118 int addSphere(Mesh& m, double radius = 1, int slices = 16, int stacks = 16);
119 int addSphereWithTexcoords(Mesh& m, double radius = 1, int bands = 16);
120 
122 
130 int addWireBox(Mesh& m, float width, float height, float depth);
131 inline int addWireBox(Mesh& m, float size = 1) {
132  return addWireBox(m, size, size, size);
133 }
134 
136 
149 int addCone(Mesh& m, float radius = 1, const Vec3f& apex = Vec3f(0, 0, 2),
150  unsigned slices = 16, unsigned cycles = 1);
151 
153 
160 int addDisc(Mesh& m, float radius = 1, unsigned slices = 16);
161 
163 
177 int addPrism(Mesh& m, float btmRadius = 1, float topRadius = 1,
178  float height = 2, unsigned slices = 16, float twist = 0);
179 
181 
190 int addAnnulus(Mesh& m, float inRadius = 0.5, float outRadius = 1,
191  unsigned slices = 16, float twist = 0);
192 
194 
206 int addCylinder(Mesh& m, float radius = 1, float height = 2,
207  unsigned slices = 16, float twist = 0);
208 
210 
225 int addSurface(Mesh& m, int Nx, int Ny, double width = 2, double height = 2,
226  double x = 0, double y = 0);
227 
229 
249 int addSurfaceLoop(Mesh& m, int Nx, int Ny, int loopMode, double width = 2,
250  double height = 2, double x = 0, double y = 0);
251 
253 
265 int addTorus(Mesh& m, double minRadius = 0.3, double majRadius = 0.7,
266  int Nmin = 16, int Nmaj = 16, double minPhase = 0);
267 
268 int addTexQuad(Mesh& m, float half_width = 1, float half_height = 1);
269 int addQuad(Mesh& m, float half_width = 1, float half_height = 1);
270 int addRect(Mesh& m, float x, float y, float w, float h);
271 int addTexRect(Mesh& m, float x, float y, float w, float h);
272 
273 } // namespace al
274 
275 #endif
Stores buffers related to rendering graphical objects.
Definition: al_Mesh.hpp:62
Definition: al_App.hpp:23
int addIcosahedron(Mesh &m, float radius=1)
Add icosahedron as indexed triangles.
int addDisc(Mesh &m, float radius=1, unsigned slices=16)
Add a disc/regular polygon as indexed triangles.
int addIcosphere(Mesh &m, double radius=1, int divisions=2)
Add sphere produced from subdivided icosahedron as indexed triangles.
int addSphere(Mesh &m, double radius=1, int slices=16, int stacks=16)
Add sphere as indexed triangles.
int addWireBox(Mesh &m, float width, float height, float depth)
Add wireframe box as indexed lines.
int addAnnulus(Mesh &m, float inRadius=0.5, float outRadius=1, unsigned slices=16, float twist=0)
Add an annulus ("little ring") as an indexed triangle strip.
int addCone(Mesh &m, float radius=1, const Vec3f &apex=Vec3f(0, 0, 2), unsigned slices=16, unsigned cycles=1)
Add a cone/pyramid as indexed triangles.
int addDodecahedron(Mesh &m, float radius=1)
Add dodecahedron as indexed triangles.
int addTetrahedron(Mesh &m, float radius=1)
Add tetrahedron as indexed triangles.
int addPrism(Mesh &m, float btmRadius=1, float topRadius=1, float height=2, unsigned slices=16, float twist=0)
Add a prism as an indexed triangle strip.
Vec< 3, float > Vec3f
float 3-vector
Definition: al_Vec.hpp:59
int addTorus(Mesh &m, double minRadius=0.3, double majRadius=0.7, int Nmin=16, int Nmaj=16, double minPhase=0)
Add a torus as an indexed triangle strip.
int addCube(Mesh &m, bool withNormalsAndTexcoords=false, float radius=M_SQRT_1_3)
Add cube as indexed triangles.
int addSurface(Mesh &m, int Nx, int Ny, double width=2, double height=2, double x=0, double y=0)
Add a tessellated rectangular surface as an indexed triangle strip.
int addCylinder(Mesh &m, float radius=1, float height=2, unsigned slices=16, float twist=0)
Add an open cylinder as an indexed triangle strip.
int addOctahedron(Mesh &m, float radius=1)
Add octahedron as triangle vertices and indices.
int addSurfaceLoop(Mesh &m, int Nx, int Ny, int loopMode, double width=2, double height=2, double x=0, double y=0)
Add a tessellated rectangular surface with connected edges.