le2d v0.4.8
2D game engine framework
 
Loading...
Searching...
No Matches
sector.hpp
Go to the documentation of this file.
1#pragma once
2#include "le2d/geometry.hpp"
4#include <kvf/color.hpp>
5#include <kvf/rect.hpp>
6
7namespace le::shape {
10 kvf::Color color{kvf::white_v};
11 std::int32_t resolution{128};
12 float degrees_begin{0.0f};
13 float degrees_end{360.0f};
14};
15
17class Sector : public IGeometry {
18 public:
20
21 static constexpr auto default_diameter_v = default_length_v;
22
23 explicit(false) Sector(float const diameter = default_diameter_v, SectorParams const& params = {}) { create(diameter, params); }
24
25 [[nodiscard]] auto get_vertices() const -> std::span<Vertex const> final { return m_verts.vertices; }
26 [[nodiscard]] auto get_indices() const -> std::span<std::uint32_t const> final { return m_verts.indices; }
27 [[nodiscard]] auto get_topology() const -> vk::PrimitiveTopology final { return vk::PrimitiveTopology::eTriangleFan; }
28
29 void create(float diameter = default_diameter_v, Params const& params = {});
30
31 [[nodiscard]] auto get_diameter() const -> float { return m_diameter; }
32 [[nodiscard]] auto get_size() const -> glm::vec2 { return glm::vec2{get_diameter()}; }
33
34 [[nodiscard]] auto get_vertex_array() const -> VertexArray const& { return m_verts; }
35
36 private:
37 VertexArray m_verts{};
38 float m_diameter{};
39};
40} // namespace le::shape
Interface for drawable geometry.
Definition geometry.hpp:9
virtual auto get_vertices() const -> std::span< Vertex const >=0
static constexpr auto default_length_v
Definition geometry.hpp:11
virtual auto get_indices() const -> std::span< std::uint32_t const >=0
virtual auto get_topology() const -> vk::PrimitiveTopology=0
Sector Geometry.
Definition sector.hpp:17
SectorParams Params
Definition sector.hpp:19
static constexpr auto default_diameter_v
Definition sector.hpp:21
SectorParams const & params
Definition sector.hpp:23
auto get_size() const -> glm::vec2
Definition sector.hpp:32
auto get_diameter() const -> float
Definition sector.hpp:31
auto get_vertex_array() const -> VertexArray const &
Definition sector.hpp:34
Definition circle.hpp:4
Drawable vertex array.
Definition vertex_array.hpp:9
std::vector< Vertex > vertices
Definition vertex_array.hpp:10
std::vector< std::uint32_t > indices
Definition vertex_array.hpp:11
Drawable vertex.
Definition vertex.hpp:7
Sector creation parameters.
Definition sector.hpp:9
kvf::Color color
Definition sector.hpp:10
float degrees_begin
Definition sector.hpp:12
float degrees_end
Definition sector.hpp:13
std::int32_t resolution
Definition sector.hpp:11