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

sphere.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_SHAPES_SPHERE_HPP
10 #define EAGINE_SHAPES_SPHERE_HPP
11 
12 #include "../config/basic.hpp"
13 #include "../valid_if/greater_than.hpp"
14 #include "gen_base.hpp"
15 #include <cassert>
16 
17 namespace eagine {
18 namespace shapes {
19 //------------------------------------------------------------------------------
24 public:
26  vertex_attrib_bits attr_bits,
28  valid_if_greater_than<int, 3> sections) noexcept;
29 
30  unit_sphere_gen(vertex_attrib_bits attr_bits) noexcept
31  : unit_sphere_gen(attr_bits, 12, 18) {}
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 tangentials(span<float> dest) noexcept;
40 
41  void bitangentials(span<float> dest) noexcept;
42 
43  void wrap_coords(span<float> dest) noexcept;
44 
45  void attrib_values(vertex_attrib_variant, span<float>) override;
46 
47  auto index_type(drawing_variant) -> index_data_type override;
48 
49  auto index_count(drawing_variant) -> span_size_t override;
50 
51  void indices(drawing_variant, span<std::uint8_t> dest) override;
52 
53  void indices(drawing_variant, span<std::uint16_t> dest) override;
54 
55  void indices(drawing_variant, span<std::uint32_t> dest) override;
56 
58 
59  void instructions(drawing_variant, span<draw_operation> ops) override;
60 
61  auto bounding_sphere() -> math::sphere<float, true> override;
62 
63  void ray_intersections(
65  span<const math::line<float, true>> rays,
66  span<optionally_valid<float>> intersections) override;
67 
68 private:
70 
71  span_size_t _rings;
72  span_size_t _sections;
73 
74  static auto _attr_mask() noexcept -> vertex_attrib_bits;
75 
76  template <typename T>
77  void _indices(drawing_variant, span<T> dest) noexcept;
78 };
79 //------------------------------------------------------------------------------
89 static inline auto unit_sphere(
90  vertex_attrib_bits attr_bits,
93  return std::make_unique<unit_sphere_gen>(
94  attr_bits, std::move(rings), std::move(sections));
95 }
96 //------------------------------------------------------------------------------
106 static inline auto unit_sphere(vertex_attrib_bits attr_bits) {
107  return unit_sphere(attr_bits, 18, 36);
108 }
109 //------------------------------------------------------------------------------
110 } // namespace shapes
111 } // namespace eagine
112 
113 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
114 #include <eagine/shapes/sphere.inl>
115 #endif
116 
117 #endif // EAGINE_SHAPES_SPHERE_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
void attrib_values(vertex_attrib_variant, span< float >) override
Fetches the vertex attribute data for the specified variant as floats.
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
auto bounding_sphere() -> math::sphere< float, true > override
Returns the bounding sphere for the generated shape.
Primary template for conditionally valid values.
Definition: decl.hpp:49
static auto unit_sphere(vertex_attrib_bits attr_bits, valid_if_greater_than< int, 2 > rings, valid_if_greater_than< int, 3 > sections)
Constructs instances of unit_sphere_gen.
Definition: sphere.hpp:89
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
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.
void instructions(drawing_variant, span< draw_operation > ops) override
Fetches the drawing operations for the specified drawing variant.
void indices(drawing_variant, span< std::uint8_t > dest) override
Fetches the index data for the specified drawing variant.
span_size_t drawing_variant
Alias for shape drawing variant index type.
Definition: gen_base.hpp:31
Generator of centered UV-sphere shape with unit diameter.
Definition: sphere.hpp:23
Base class for shape generators re-calculating the center.
Definition: gen_base.hpp:320
auto index_type() -> index_data_type
Returns the index data type for the default draw variant.
Definition: gen_base.hpp:139
auto vertex_count() -> span_size_t override
Returns the shaped vertex count.
index_data_type
Shape element index type enumeration.
Definition: drawing.hpp:111
auto index_count()
Returns the index count for the default drawing variant.
Definition: gen_base.hpp:147

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