💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
2.4 KiB

  1. /*
  2. * Copyright (C) 2021 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. #ifndef ANTKEEPER_SCENE_BILLBOARD_HPP
  20. #define ANTKEEPER_SCENE_BILLBOARD_HPP
  21. #include "scene/object.hpp"
  22. #include "geometry/aabb.hpp"
  23. #include "utility/fundamental-types.hpp"
  24. class material;
  25. namespace scene {
  26. /// Enumerates billboard types.
  27. enum class billboard_type
  28. {
  29. // No alignment
  30. flat,
  31. // Aligns to face camera
  32. spherical,
  33. // Rotates about an alignment axis to face camera
  34. cylindrical
  35. };
  36. /**
  37. * A 2D unit quad with one material.
  38. */
  39. class billboard: public object<billboard>
  40. {
  41. public:
  42. billboard();
  43. billboard(const billboard& other);
  44. billboard& operator=(const billboard& other);
  45. void set_material(material* material);
  46. /// Sets the billboard alignment mode.
  47. void set_billboard_type(billboard_type type);
  48. /// Sets the axis around which the billboard will be rotated when the alignment is set to billboard_alignment::cylindrical.
  49. void set_alignment_axis(const float3& axis);
  50. virtual const bounding_volume<float>& get_bounds() const;
  51. material* get_material() const;
  52. billboard_type get_billboard_type() const;
  53. const float3& get_alignment_axis() const;
  54. virtual void update_tweens();
  55. private:
  56. static const aabb<float> untransformed_bounds;
  57. virtual void transformed();
  58. aabb<float> bounds;
  59. material* material;
  60. billboard_type type;
  61. float3 alignment_axis;
  62. };
  63. inline const bounding_volume<float>& billboard::get_bounds() const
  64. {
  65. return bounds;
  66. }
  67. inline material* billboard::get_material() const
  68. {
  69. return material;
  70. }
  71. inline billboard_type billboard::get_billboard_type() const
  72. {
  73. return type;
  74. }
  75. inline const float3& billboard::get_alignment_axis() const
  76. {
  77. return alignment_axis;
  78. }
  79. } // namespace scene
  80. #endif // ANTKEEPER_SCENE_BILLBOARD_HPP