OGLplus (0.52.0) a C++ wrapper for OpenGL

wicker_torus.hpp
Go to the documentation of this file.
1 
12 #pragma once
13 #ifndef OGLPLUS_SHAPES_WICKER_TORUS_1201021336_HPP
14 #define OGLPLUS_SHAPES_WICKER_TORUS_1201021336_HPP
15 
16 #include <oglplus/shapes/draw.hpp>
17 #include <oglplus/face_mode.hpp>
18 
20 
22 #include <oglplus/math/sphere.hpp>
23 
24 namespace oglplus {
25 namespace shapes {
26 
29  : public DrawingInstructionWriter
30  , public DrawMode
31 {
32 private:
33  const GLdouble _radius_out, _radius_in, _thickness;
34  const GLdouble _r_slip_coef, _s_slip_coef;
35  const unsigned _sections, _rings;
36 public:
39  : _radius_out(1.0)
40  , _radius_in(0.5)
41  , _thickness(0.005)
42  , _r_slip_coef(0.25)
43  , _s_slip_coef(0.40)
44  , _sections(24)
45  , _rings(24)
46  { }
47 
50  GLdouble rad_out,
51  GLdouble rad_in,
52  GLdouble thickness,
53  unsigned sects,
54  unsigned rings
55  ): _radius_out(rad_out)
56  , _radius_in(rad_in)
57  , _thickness(thickness)
58  , _r_slip_coef(0.25)
59  , _s_slip_coef(0.40)
60  , _sections(sects)
61  , _rings(rings)
62  {
63  assert(_sections % 2 == 0);
64  assert(_rings % 2 == 0);
65  assert(_thickness > 0.0);
66  assert(_thickness < _radius_in);
67  assert(_radius_in < _radius_out);
68  }
69 
72  {
73  return FaceOrientation::CW;
74  }
75 
76  std::vector<GLfloat> _positions(void) const;
77 
78  GLuint Positions(std::vector<GLfloat>& dest) const
79  {
80  dest = _positions();
81  return 3;
82  }
83 
85  template <typename T>
86  GLuint Positions(std::vector<T>& dest) const
87  {
88  auto v = _positions();
89  dest.assign(v.begin(), v.end());
90  return 3;
91  }
92 
93  std::vector<GLfloat> _normals(void) const;
94 
95  GLuint Normals(std::vector<GLfloat>& dest) const
96  {
97  dest = _normals();
98  return 3;
99  }
100 
102  template <typename T>
103  GLuint Normals(std::vector<T>& dest) const
104  {
105  auto v = _normals();
106  dest.assign(v.begin(), v.end());
107  return 3;
108  }
109 
110  std::vector<GLfloat> _tangents(void) const;
111 
112  GLuint Tangents(std::vector<GLfloat>& dest) const
113  {
114  dest = _tangents();
115  return 3;
116  }
117 
119  template <typename T>
120  GLuint Tangents(std::vector<T>& dest) const
121  {
122  auto v = _tangents();
123  dest.assign(v.begin(), v.end());
124  return 3;
125  }
126 
127  std::vector<GLfloat> _bitangents(void) const;
128 
129  GLuint Bitangents(std::vector<GLfloat>& dest) const
130  {
131  dest = _bitangents();
132  return 3;
133  }
134 
136  template <typename T>
137  GLuint Bitangents(std::vector<T>& dest) const
138  {
139  auto v = _bitangents();
140  dest.assign(v.begin(), v.end());
141  return 3;
142  }
143 
144  std::vector<GLfloat> _tex_coords(void) const;
145 
146  GLuint TexCoordinates(std::vector<GLfloat>& dest) const
147  {
148  dest = _tex_coords();
149  return 2;
150  }
151 
153  template <typename T>
154  GLuint TexCoordinates(std::vector<T>& dest) const
155  {
156  auto v = _tex_coords();
157  dest.assign(v.begin(), v.end());
158  return 2;
159  }
160 
161 #if OGLPLUS_DOCUMENTATION_ONLY
162 
171  typedef VertexAttribsInfo<WickerTorus> VertexAttribs;
172 #else
173  typedef VertexAttribsInfo<
174  WickerTorus,
175  std::tuple<
176  VertexPositionsTag,
177  VertexNormalsTag,
178  VertexTangentsTag,
179  VertexBitangentsTag,
180  VertexTexCoordinatesTag
181  >
182  > VertexAttribs;
183 #endif
184 
186  template <typename T>
187  void BoundingSphere(oglplus::Sphere<T>& bounding_sphere) const
188  {
189  bounding_sphere = oglplus::Sphere<T>(
190  T(0),
191  T(0),
192  T(0),
193  T(_radius_out + _thickness)
194  );
195  }
196 
198  typedef std::vector<GLuint> IndexArray;
199 
201  IndexArray Indices(Default = Default()) const
202  {
203  return IndexArray();
204  }
205 
207  DrawingInstructions Instructions(Default = Default()) const;
208 
210  IndexArray Indices(Edges) const;
211 
213  DrawingInstructions Instructions(Edges) const;
214 };
215 
216 } // shapes
217 } // oglplus
218 
219 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
220 #include <oglplus/shapes/wicker_torus.ipp>
221 #endif // OGLPLUS_LINK_LIBRARY
222 
223 #endif // include guard
Implementation of shape draw instructions.
IndexArray Indices(Default=Default()) const
Returns element indices that are used with the drawing instructions.
Definition: wicker_torus.hpp:201
std::vector< GLuint > IndexArray
The type of index container returned by Indices()
Definition: wicker_torus.hpp:198
WickerTorus(GLdouble rad_out, GLdouble rad_in, GLdouble thickness, unsigned sects, unsigned rings)
Creates a torus with unit radius centered at the origin.
Definition: wicker_torus.hpp:49
DrawingInstructions Instructions(Default=Default()) const
Returns the instructions for rendering.
FaceOrientation FaceWinding(void) const
Returns the winding direction of faces.
Definition: wicker_torus.hpp:71
Sphere utility class.
Class providing vertex attributes and instructions for rendering of a Torus.
Definition: wicker_torus.hpp:28
VertexAttribsInfo< WickerTorus > VertexAttribs
Vertex attribute information for this shape builder.
Definition: wicker_torus.hpp:171
void BoundingSphere(oglplus::Sphere< T > &bounding_sphere) const
Queries the bounding sphere coordinates and dimensions.
Definition: wicker_torus.hpp:187
FaceOrientation
Face orientation enumeration.
Definition: face_mode.hpp:62
OpenGL face type-related enumeration.
GLuint TexCoordinates(std::vector< T > &dest) const
Makes texture coorinates and returns number of values per vertex.
Definition: wicker_torus.hpp:154
WickerTorus(void)
Creates a torus with unit radius centered at the origin.
Definition: wicker_torus.hpp:38
GLuint Bitangents(std::vector< T > &dest) const
Makes vertex bi-tangents and returns number of values per vertex.
Definition: wicker_torus.hpp:137
GLuint Tangents(std::vector< T > &dest) const
Makes vertex tangents and returns number of values per vertex.
Definition: wicker_torus.hpp:120
Classes providing additional information about the shape builders.
Math constants.
Class encapsulating the instructions for drawing of a shape.
Definition: draw.hpp:219
Class implementing sphere-related functionality.
Definition: sphere.hpp:29
GLuint Positions(std::vector< T > &dest) const
Makes vertex coordinates and returns number of values per vertex.
Definition: wicker_torus.hpp:86
GLuint Normals(std::vector< T > &dest) const
Makes vertex normals and returns number of values per vertex.
Definition: wicker_torus.hpp:103

Copyright © 2010-2014 Matúš Chochlík, University of Žilina, Žilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Mon Sep 22 2014 by Doxygen (version 1.8.6).