💿🐜 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.

101 lines
2.4 KiB

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