Antkeeper  0.0.1
model.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_RENDER_MODEL_HPP
21 #define ANTKEEPER_RENDER_MODEL_HPP
22 
30 #include <cstdint>
31 #include <memory>
32 #include <string>
33 #include <vector>
34 
35 namespace render {
36 
41 {
44  std::uint32_t first_vertex{};
45  std::uint32_t vertex_count{};
46  std::shared_ptr<render::material> material;
47 };
48 
52 class model
53 {
54 public:
57 
63  inline void set_vertex_offset(std::size_t offset) noexcept
64  {
65  m_vertex_offset = offset;
66  }
67 
73  inline void set_vertex_stride(std::size_t stride) noexcept
74  {
75  m_vertex_stride = stride;
76  }
77 
82  [[nodiscard]] inline const std::shared_ptr<gl::vertex_array>& get_vertex_array() const noexcept
83  {
84  return m_vertex_array;
85  }
86  [[nodiscard]] inline std::shared_ptr<gl::vertex_array>& get_vertex_array() noexcept
87  {
88  return m_vertex_array;
89  }
91 
96  [[nodiscard]] inline const std::shared_ptr<gl::vertex_buffer>& get_vertex_buffer() const noexcept
97  {
98  return m_vertex_buffer;
99  }
100  [[nodiscard]] inline std::shared_ptr<gl::vertex_buffer>& get_vertex_buffer() noexcept
101  {
102  return m_vertex_buffer;
103  }
105 
107  [[nodiscard]] inline constexpr std::size_t get_vertex_offset() const noexcept
108  {
109  return m_vertex_offset;
110  }
111 
113  [[nodiscard]] inline constexpr std::size_t get_vertex_stride() const noexcept
114  {
115  return m_vertex_stride;
116  }
117 
122  [[nodiscard]] inline const aabb_type& get_bounds() const noexcept
123  {
124  return m_bounds;
125  }
126  [[nodiscard]] inline aabb_type& get_bounds() noexcept
127  {
128  return m_bounds;
129  }
131 
136  [[nodiscard]] inline const std::vector<model_group>& get_groups() const noexcept
137  {
138  return m_groups;
139  }
140  [[nodiscard]] inline std::vector<model_group>& get_groups() noexcept
141  {
142  return m_groups;
143  }
145 
150  [[nodiscard]] inline const ::skeleton& get_skeleton() const noexcept
151  {
152  return m_skeleton;
153  }
154  [[nodiscard]] inline ::skeleton& get_skeleton() noexcept
155  {
156  return m_skeleton;
157  }
159 
160 private:
161  std::shared_ptr<gl::vertex_array> m_vertex_array;
162  std::shared_ptr<gl::vertex_buffer> m_vertex_buffer;
163  std::size_t m_vertex_offset{};
164  std::size_t m_vertex_stride{};
165  aabb_type m_bounds{{0, 0, 0}, {0, 0, 0}};
166  std::vector<model_group> m_groups;
167  ::skeleton m_skeleton;
168 };
169 
170 } // namespace render
171 
172 #endif // ANTKEEPER_RENDER_MODEL_HPP
aabb_type & get_bounds() noexcept
Returns the bounds of the model.
Definition: model.hpp:126
std::shared_ptr< gl::vertex_array > & get_vertex_array() noexcept
Returns the vertex array associated with this model.
Definition: model.hpp:86
geom::box< float > aabb_type
AABB type.
Definition: model.hpp:56
std::shared_ptr< gl::vertex_buffer > & get_vertex_buffer() noexcept
Returns the vertex buffer associated with this model.
Definition: model.hpp:100
const aabb_type & get_bounds() const noexcept
Returns the bounds of the model.
Definition: model.hpp:122
::skeleton & get_skeleton() noexcept
Returns the skeleton associated with this model.
Definition: model.hpp:154
const std::shared_ptr< gl::vertex_buffer > & get_vertex_buffer() const noexcept
Returns the vertex buffer associated with this model.
Definition: model.hpp:96
constexpr std::size_t get_vertex_stride() const noexcept
Returns the byte stride between consecutive elements within the vertex buffer.
Definition: model.hpp:113
void set_vertex_offset(std::size_t offset) noexcept
Sets the byte offset to the first vertex in the vertex buffer.
Definition: model.hpp:63
void set_vertex_stride(std::size_t stride) noexcept
Sets the byte stride between consecutive elements within the vertex buffer.
Definition: model.hpp:73
constexpr std::size_t get_vertex_offset() const noexcept
Returns the byte offset to the first vertex in the vertex buffer.
Definition: model.hpp:107
std::vector< model_group > & get_groups() noexcept
Returns the model's model groups.
Definition: model.hpp:140
const ::skeleton & get_skeleton() const noexcept
Returns the skeleton associated with this model.
Definition: model.hpp:150
const std::vector< model_group > & get_groups() const noexcept
Returns the model's model groups.
Definition: model.hpp:136
const std::shared_ptr< gl::vertex_array > & get_vertex_array() const noexcept
Returns the vertex array associated with this model.
Definition: model.hpp:82
Skeletal animation skeleton.
Definition: skeleton.hpp:35
primitive_topology
Primitive topologies.
@ triangle_list
Separate triangle primitives.
T offset(T longitude)
Calculates the UTC offset at a given longitude.
Definition: utc.hpp:38
High-level rendering.
n-dimensional axis-aligned rectangle.
32-bit FNV-1a hash value.
Definition: fnv1a.hpp:117
Part of a model which is associated with exactly one material.
Definition: model.hpp:41
std::shared_ptr< render::material > material
Definition: model.hpp:46
gl::primitive_topology primitive_topology
Definition: model.hpp:43
std::uint32_t vertex_count
Definition: model.hpp:45
std::uint32_t first_vertex
Definition: model.hpp:44