Visualization Library 2.0.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
GeometryPrimitives.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef GeometricalPrimitives_INCLUDE_ONCE
33 #define GeometricalPrimitives_INCLUDE_ONCE
34 
35 #include <vlCore/Vector4.hpp>
36 #include <vlGraphics/Geometry.hpp>
37 #include <vlCore/Colors.hpp>
38 
39 namespace vl
40 {
42 
44  VLGRAPHICS_EXPORT ref<Geometry> makeBox( const vec3& origin, real xside=1, real yside=1, real zside=1, bool tex_coords=true );
45 
47  VLGRAPHICS_EXPORT ref<Geometry> makeBox( const vec3& min, const vec3& max, bool tex_coords=true );
48 
50  VLGRAPHICS_EXPORT ref<Geometry> makeBox( const AABB& aabb, bool tex_coords=true );
51 
53  VLGRAPHICS_EXPORT ref<Geometry> makeCone( const vec3& origin, real diameter=1, real height=1, int phi=20, bool bottom=true );
54 
56  VLGRAPHICS_EXPORT ref<Geometry> makePyramid( const vec3& origin, real side=1, real height=1 );
57 
59  VLGRAPHICS_EXPORT ref<Geometry> makeIcosahedron( const vec3& origin, real diameter );
60 
62  VLGRAPHICS_EXPORT ref<Geometry> makeIcosphere( const vec3& pos, real diameter=1, int detail=2, bool remove_doubles = true );
63 
65  VLGRAPHICS_EXPORT ref<Geometry> makeUVSphere( const vec3& origin, real diameter=1, int phi=20, int theta=20 );
66 
68  VLGRAPHICS_EXPORT ref<Geometry> makeCylinder( const vec3& origin, real diameter=1, real height=1, int phi=20, int theta=2, bool top=true, bool bottom=true );
69 
71  VLGRAPHICS_EXPORT ref<Geometry> makeTorus( const vec3& origin, real diameter=1, real thickness=0.2, int phi=10, int theta=10, float tex_coords = 0.0f );
72 
74  VLGRAPHICS_EXPORT ref<Geometry> makeCapsule(float radius, float height, int segments, ECapsuleCap top_cap, ECapsuleCap bottom_cap, const fvec4& top_col, const fvec4& bottom_col);
75 
77  VLGRAPHICS_EXPORT ref<Geometry> makeTeapot( const vec3& origin, real diameter=1, int detail=8);
78 
80  VLGRAPHICS_EXPORT ref<Geometry> makeGrid( const vec3& origin, real xside, real zside, int x, int z, bool gen_texcoords = false, fvec2 uv0=fvec2(0,0), fvec2 uv1=fvec2(1,1), bool center=true);
81 
83  VLGRAPHICS_EXPORT ref<Geometry> makePoints( const std::vector< vec3 >& pos, const fvec4& color = white);
84 
86  VLGRAPHICS_EXPORT ref<Geometry> makeCircle( vec3 origin, real radius, int slices = 60 );
87 }
88 
89 #endif
VLGRAPHICS_EXPORT ref< Geometry > makeCylinder(const vec3 &origin, real diameter=1, real height=1, int phi=20, int theta=2, bool top=true, bool bottom=true)
Creates a cylinder.
VLGRAPHICS_EXPORT ref< Geometry > makeCone(const vec3 &origin, real diameter=1, real height=1, int phi=20, bool bottom=true)
Creates a cone.
VLGRAPHICS_EXPORT ref< Geometry > makeTeapot(const vec3 &origin, real diameter=1, int detail=8)
Creates a classic Newell&#39;s teapot.
The Vector4 class is a template class that implements a generic 4 components vector, see also vl::fvec4, vl::dvec4, vl::uvec4, vl::ivec4, vl::svec4, vl::usvec4, vl::bvec4, vl::ubvec4.
Definition: Vector4.hpp:44
Visualization Library main namespace.
Vector2< float > fvec2
A 2 components vector with float precision.
Definition: Vector2.hpp:282
VLGRAPHICS_EXPORT ref< Geometry > makeBox(const vec3 &origin, real xside=1, real yside=1, real zside=1, bool tex_coords=true)
Creates a box.
The AABB class implements an axis-aligned bounding box using vl::real precision.
Definition: AABB.hpp:44
VLGRAPHICS_EXPORT ref< Geometry > makeIcosahedron(const vec3 &origin, real diameter)
Creates an icosahedron.
float max(float a, float b)
Definition: Vector2.hpp:311
float min(float a, float b)
Definition: Vector2.hpp:307
VLGRAPHICS_EXPORT ref< Geometry > makeTorus(const vec3 &origin, real diameter=1, real thickness=0.2, int phi=10, int theta=10, float tex_coords=0.0f)
Creates torus. This function generates also appropriate normals.
VLGRAPHICS_EXPORT ref< Geometry > makeCapsule(float radius, float height, int segments, ECapsuleCap top_cap, ECapsuleCap bottom_cap, const fvec4 &top_col, const fvec4 &bottom_col)
Creates a 3d capsule with rounded, flat or no caps.
VLGRAPHICS_EXPORT ref< Geometry > makePyramid(const vec3 &origin, real side=1, real height=1)
Creates a pyramid.
The Vector2 class is a template class that implements a generic 2 components vector, see also vl::fvec2, vl::dvec2, vl::uvec2, vl::ivec2, vl::svec2, vl::usvec2, vl::bvec2, vl::ubvec2.
Definition: Vector2.hpp:97
VLGRAPHICS_EXPORT ref< Geometry > makeIcosphere(const vec3 &pos, real diameter=1, int detail=2, bool remove_doubles=true)
Creates a sphere by iteratively subdividing an icosahedron.
VLGRAPHICS_EXPORT ref< Geometry > makePoints(const std::vector< vec3 > &pos, const fvec4 &color=white)
Creates a set of points.
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
VLGRAPHICS_EXPORT ref< Geometry > makeGrid(const vec3 &origin, real xside, real zside, int x, int z, bool gen_texcoords=false, fvec2 uv0=fvec2(0, 0), fvec2 uv1=fvec2(1, 1), bool center=true)
Creates a 2D grid.
VLGRAPHICS_EXPORT ref< Geometry > makeUVSphere(const vec3 &origin, real diameter=1, int phi=20, int theta=20)
Creates a uv sphere.
VLGRAPHICS_EXPORT ref< Geometry > makeCircle(vec3 origin, real radius, int slices=60)
Creates a 2D circle.