Antkeeper  0.0.1
billboard.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_SCENE_BILLBOARD_HPP
21 #define ANTKEEPER_SCENE_BILLBOARD_HPP
22 
23 #include <engine/scene/object.hpp>
24 #include <engine/math/vector.hpp>
30 #include <memory>
31 
32 namespace scene {
33 
37 class billboard: public object<billboard>
38 {
39 public:
41  billboard();
42 
43  void render(render::context& ctx) const override;
44 
50  void set_material(std::shared_ptr<render::material> material);
51 
58 
64  inline void set_alignment_axis(const math::fvec3& axis) noexcept
65  {
66  m_alignment_axis = axis;
67  }
68 
69  [[nodiscard]] inline const aabb_type& get_bounds() const noexcept override
70  {
71  return m_bounds;
72  }
73 
74  [[nodiscard]] inline std::shared_ptr<render::material> get_material() const noexcept
75  {
76  return m_render_op.material;
77  }
78 
79  [[nodiscard]] inline billboard_type get_billboard_type() const noexcept
80  {
81  return m_billboard_type;
82  }
83 
84  [[nodiscard]] inline const math::fvec3& get_alignment_axis() const noexcept
85  {
86  return m_alignment_axis;
87  }
88 
89 private:
90  void transformed() override;
91 
92  std::unique_ptr<gl::vertex_array> m_vertex_array;
93  std::unique_ptr<gl::vertex_buffer> m_vertex_buffer;
94  mutable render::operation m_render_op;
95  aabb_type m_bounds{{-1.0f, -1.0f, -1.0f}, {1.0f, 1.0f, 1.0f}};
96  billboard_type m_billboard_type{billboard_type::flat};
97  math::fvec3 m_alignment_axis{0.0f, 1.0f, 0.0f};
98 };
99 
100 } // namespace scene
101 
102 #endif // ANTKEEPER_SCENE_BILLBOARD_HPP
2D unit quad with a single material.
Definition: billboard.hpp:38
const math::fvec3 & get_alignment_axis() const noexcept
Definition: billboard.hpp:84
void render(render::context &ctx) const override
Adds render operations to a render context.
Definition: billboard.cpp:81
void set_billboard_type(billboard_type type)
Sets the billboard type.
Definition: billboard.cpp:130
billboard()
Constructs a billboard.
Definition: billboard.cpp:57
std::shared_ptr< render::material > get_material() const noexcept
Definition: billboard.hpp:74
void set_alignment_axis(const math::fvec3 &axis) noexcept
Sets alignment axis for cylindrical billboards.
Definition: billboard.hpp:64
billboard_type get_billboard_type() const noexcept
Definition: billboard.hpp:79
const aabb_type & get_bounds() const noexcept override
Returns the bounds of the object.
Definition: billboard.hpp:69
void set_material(std::shared_ptr< render::material > material)
Sets the billboard material.
Definition: billboard.cpp:125
geom::box< float > aabb_type
Definition: object.hpp:42
Abstract base class for lights, cameras, model instances, and other scene objects.
Definition: object.hpp:172
3D scene.
Definition: context.hpp:28
billboard_type
Billboard types.
@ flat
Billboard is unaligned.
Text and typography.
Definition: bitmap-font.cpp:24
n-dimensional axis-aligned rectangle.
n-dimensional vector.
Definition: vector.hpp:44
Context of a renderer.
Definition: context.hpp:40
Atomic render operation.
Definition: operation.hpp:38
std::shared_ptr< render::material > material
Definition: operation.hpp:49