OGLplus  (0.59.0) a C++ wrapper for rendering APIs

twisted_torus.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SHAPES_TWISTED_TORUS_HPP
10 #define EAGINE_SHAPES_TWISTED_TORUS_HPP
11 
12 #include "../config/basic.hpp"
13 #include "../valid_if/ge0_lt1.hpp"
14 #include "../valid_if/greater_than.hpp"
15 #include "gen_base.hpp"
16 #include <cassert>
17 
18 namespace eagine {
19 namespace shapes {
20 //------------------------------------------------------------------------------
25 public:
27  vertex_attrib_bits attr_bits,
28  int twist,
31  valid_if_ge0_lt1<float> radius_ratio) noexcept;
32 
33  auto vertex_count() -> span_size_t override;
34 
35  void positions(span<float> dest) noexcept;
36 
37  void normals(span<float> dest) noexcept;
38 
39  void wrap_coords(span<float> dest) noexcept;
40 
41  void attrib_values(vertex_attrib_variant, span<float>) override;
42 
44 
45  void instructions(drawing_variant, span<draw_operation> ops) override;
46 
47  auto bounding_sphere() -> math::sphere<float, true> override;
48 
49  void ray_intersections(
51  span<const math::line<float, true>> rays,
52  span<optionally_valid<float>> intersections) override;
53 
54 private:
56 
57  int _twist;
58  int _rings;
59  int _sections;
60  float _radius_ratio{0.50F};
61  float _thickness_ratio{0.1F};
62 
63  static auto _attr_mask() noexcept -> vertex_attrib_bits;
64 
65  template <typename T>
66  void _indices(drawing_variant, span<T> dest) noexcept;
67 };
68 //------------------------------------------------------------------------------
77 static inline auto unit_twisted_torus(
78  vertex_attrib_bits attr_bits,
79  int twist,
82  valid_if_ge0_lt1<float> radius_ratio) {
83  return std::make_unique<unit_twisted_torus_gen>(
84  attr_bits,
85  twist,
86  std::move(rings),
87  std::move(sections),
88  std::move(radius_ratio));
89 }
90 //------------------------------------------------------------------------------
99 static inline auto unit_twisted_torus(vertex_attrib_bits attr_bits) {
100  return unit_twisted_torus(attr_bits, 12, 38, 12, 0.5F);
101 }
102 //------------------------------------------------------------------------------
103 } // namespace shapes
104 } // namespace eagine
105 
106 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
107 #include <eagine/shapes/twisted_torus.inl>
108 #endif
109 
110 #endif // EAGINE_SHAPES_TWISTED_TORUS_HPP
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
bitfield< vertex_attrib_kind > vertex_attrib_bits
Alias for vertex_attrib_kind bitfield type.
Definition: vertex_attrib.hpp:85
Basic template for spheres in N-dimensional space.
Definition: primitives.hpp:122
Basic template for lines in N-dimensional space.
Definition: primitives.hpp:19
Common code is placed in this namespace.
Definition: eagine.hpp:21
auto operation_count()
Returns the number of drawing instructions for the default variant.
Definition: gen_base.hpp:179
Primary template for conditionally valid values.
Definition: decl.hpp:49
void attrib_values(vertex_attrib_variant, span< float >) override
Fetches the vertex attribute data for the specified variant as floats.
basic_span< T, T *, S > span
Default alias for basic memory spans with native pointer type.
Definition: span.hpp:415
Class designating an vertex attribute variant in a shape generator.
Definition: vertex_attrib.hpp:104
auto vertex_count() -> span_size_t override
Returns the shaped vertex count.
auto bounding_sphere() -> math::sphere< float, true > override
Returns the bounding sphere for the generated shape.
span_size_t drawing_variant
Alias for shape drawing variant index type.
Definition: gen_base.hpp:31
void ray_intersections(drawing_variant, span< const math::line< float, true >> rays, span< optionally_valid< float >> intersections) override
Calculates the intersections of the shape geometry with a ray.
Base class for shape generators re-calculating the center.
Definition: gen_base.hpp:320
static auto unit_twisted_torus(vertex_attrib_bits attr_bits, int twist, valid_if_greater_than< int, 2 > rings, valid_if_greater_than< int, 3 > sections, valid_if_ge0_lt1< float > radius_ratio)
Constructs instances of unit_twisted_torus_gen.
Definition: twisted_torus.hpp:77
Generator of centered UV-sphere shape with unit diameter.
Definition: twisted_torus.hpp:24
void instructions(drawing_variant, span< draw_operation > ops) override
Fetches the drawing operations for the specified drawing variant.

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).