13 #ifndef OGLPLUS_SHAPES_PLANE_1107121519_HPP
14 #define OGLPLUS_SHAPES_PLANE_1107121519_HPP
32 :
public DrawingInstructionWriter
38 unsigned _udiv, _vdiv;
40 unsigned _vertex_count(
void)
const
42 return (_udiv+1)*(_vdiv+1);
47 : _point(0.0f, 0.0f, 0.0f)
48 , _u(1.0f, 0.0f, 0.0f)
49 , _v(0.0f, 0.0f,-1.0f)
55 Plane(
unsigned udiv,
unsigned vdiv)
56 : _point(0.0f, 0.0f, 0.0f)
57 , _u(1.0f, 0.0f, 0.0f)
58 , _v(0.0f, 0.0f,-1.0f)
68 : _point(0.0f, 0.0f, 0.0f)
74 assert(Length(_u) > 0.0f);
75 assert(Length(_v) > 0.0f);
91 assert(Length(_u) > 0.0f);
92 assert(Length(_v) > 0.0f);
97 const Vec3f& Point(
void)
const
102 const Vec3f& U(
void)
const
107 const Vec3f& V(
void)
const
112 inline Vec3f Normal(
void)
const
114 return Normalized(Cross(_u, _v));
117 inline Vec3f Tangential(
void)
const
119 return Normalized(_u);
122 inline Vec3f Bitangential(
void)
const
124 return Normalized(_v);
127 Vec4f Equation(
void)
const
129 return Vec4f(Normal(), -Dot(Normal(), _point));
139 template <
typename T>
142 unsigned k = 0, n = _vertex_count();
144 Vec3f normal = Normal();
146 for(
unsigned i=0; i!=n; ++i)
148 dest[k++] =
T(normal.x());
149 dest[k++] =
T(normal.
y());
150 dest[k++] =
T(normal.
z());
153 assert(k == dest.size());
159 template <
typename T>
162 unsigned k = 0, n = _vertex_count();
164 Vec3f tangent(Normalized(_u));
166 for(
unsigned i=0; i!=n; ++i)
168 dest[k++] =
T(tangent.x());
169 dest[k++] =
T(tangent.
y());
170 dest[k++] =
T(tangent.
z());
173 assert(k == dest.size());
179 template <
typename T>
182 unsigned k = 0, n = _vertex_count();
184 Vec3f bitangent(Normalized(_v));
186 for(
unsigned i=0; i!=n; ++i)
188 dest[k++] =
T(bitangent.x());
189 dest[k++] =
T(bitangent.
y());
190 dest[k++] =
T(bitangent.
z());
193 assert(k == dest.size());
199 template <
typename T>
202 unsigned k = 0, n = _vertex_count();
206 Vec3f pos(_point - _u - _v);
207 Vec3f ustep(_u * (2.0 / _udiv));
208 Vec3f vstep(_v * (2.0 / _vdiv));
210 unsigned leap = _udiv+1;
212 for(
unsigned j=0; j!=(_vdiv+1); ++j)
215 for(
unsigned i=0; i!=leap; ++i)
217 dest[k++] =
T(tmp.x());
218 dest[k++] =
T(tmp.
y());
219 dest[k++] =
T(tmp.
z());
224 assert(k == dest.size());
229 template <
typename T>
232 unsigned k = 0, n = _vertex_count();
237 T ustep =
T(1) / _udiv;
238 T vstep =
T(1) / _vdiv;
240 unsigned leap = _udiv+1;
243 for(
unsigned j=0; j!=(_vdiv+1); ++j)
246 for(
unsigned i=0; i!=leap; ++i)
254 assert(k == dest.size());
259 #if OGLPLUS_DOCUMENTATION_ONLY
271 typedef VertexAttribsInfo<
278 VertexTexCoordinatesTag
284 template <
typename T>
304 #if OGLPLUS_DOCUMENTATION_ONLY || GL_VERSION_4_0
328 #if !OGLPLUS_LINK_LIBRARY || defined(OGLPLUS_IMPLEMENTING_LIBRARY)
329 #include <oglplus/shapes/plane.ipp>
330 #endif // OGLPLUS_LINK_LIBRARY
332 #endif // include guard
Implementation of shape draw instructions.
void BoundingSphere(oglplus::Sphere< T > &bounding_sphere) const
Queries the bounding sphere coordinates and dimensions.
Definition: plane.hpp:285
Vector< GLfloat, 4 > Vec4f
4D float vector
Definition: vector.hpp:85
VertexAttribsInfo< Plane > VertexAttribs
Vertex attribute information for this shape builder.
Definition: plane.hpp:269
std::vector< GLuint > IndexArray
The type of index container returned by Indices()
Definition: plane.hpp:296
GLuint Positions(std::vector< T > &dest) const
Makes vertex coordinates and returns number of values per vertex.
Definition: plane.hpp:200
Vector< GLfloat, 3 > Vec3f
3D float vector
Definition: vector.hpp:79
Plane(const Vec3f p, const Vec3f u, const Vec3f v, unsigned udiv, unsigned vdiv)
Creates a plane going through p specified by u and v.
Definition: plane.hpp:79
Class providing vertex attributes and instructions for rendering of a Plane.
Definition: plane.hpp:31
Plane(const Vec3f u, const Vec3f v)
Creates a plane going through origin specified by u and v.
Definition: plane.hpp:67
FaceOrientation
Face orientation enumeration.
Definition: face_mode.hpp:62
OpenGL face type-related enumeration.
T z(void) const
Returns the 2-nd component.
Definition: vector.hpp:237
FaceOrientation FaceWinding(void) const
Returns the winding direction of faces.
Definition: plane.hpp:133
GLuint Normals(std::vector< T > &dest) const
Makes vertex normals and returns number of values per vertex.
Definition: plane.hpp:140
T y(void) const
Returns the 1-st component.
Definition: vector.hpp:231
GLuint TexCoordinates(std::vector< T > &dest) const
Makes texture-coorinates and returns number of values per vertex.
Definition: plane.hpp:230
IndexArray Indices(Default=Default()) const
Returns element indices that are used with the drawing instructions.
GLuint Bitangents(std::vector< T > &dest) const
Makes vertex bi-tangents and returns number of values per vertex.
Definition: plane.hpp:180
Plane(unsigned udiv, unsigned vdiv)
Creates a default plane with udiv and vdiv divisions.
Definition: plane.hpp:55
Classes providing additional information about the shape builders.
GLuint Tangents(std::vector< T > &dest) const
Makes vertex tangents and returns number of values per vertex.
Definition: plane.hpp:160
Class encapsulating the instructions for drawing of a shape.
Definition: draw.hpp:219
Class implementing sphere-related functionality.
Definition: sphere.hpp:29
Plane(void)
Creates a default plane.
Definition: plane.hpp:46
DrawingInstructions Instructions(Default=Default()) const
Returns the instructions for rendering.