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

96 lines
2.1 KiB

  1. /*
  2. * Copyright (C) 2017-2019 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 LENS_HPP
  20. #define LENS_HPP
  21. #include "tool.hpp"
  22. class ParticleSystem;
  23. /**
  24. * The lens tool can be used to burn ants.
  25. *
  26. * @see https://taylorpetrick.com/blog/post/dispersion-opengl
  27. * @see https://taylorpetrick.com/portfolio/webgl/lense
  28. */
  29. class Lens: public Tool
  30. {
  31. public:
  32. /**
  33. * Creates an instance of Lens.
  34. *
  35. * @param model Lens model
  36. */
  37. Lens(const Model* model, Animator* animator);
  38. /**
  39. * Destroys an instance of Lens.
  40. */
  41. ~Lens();
  42. /**
  43. * Updates the lens.
  44. *
  45. * @param dt Application timestep.
  46. */
  47. virtual void update(float dt);
  48. void focus();
  49. void unfocus();
  50. void setSunDirection(const Vector3& direction);
  51. void setParticleSystem(ParticleSystem* particleSystem);
  52. /**
  53. * Returns the spotlight.
  54. */
  55. const Spotlight* getSpotlight() const;
  56. Spotlight* getSpotlight();
  57. private:
  58. Spotlight spotlight;
  59. float focusedDistance;
  60. float unfocusedDistance;
  61. float focusDuration;
  62. float unfocusDuration;
  63. float lensDistance;
  64. float lastDistance;
  65. bool focused;
  66. Vector3 sunDirection;
  67. Animation<float> focusAnimation;
  68. Animation<float> unfocusAnimation;
  69. AnimationClip<float> focusClip;
  70. AnimationClip<float> unfocusClip;
  71. bool wasActive;
  72. ParticleSystem* particleSystem;
  73. };
  74. inline const Spotlight* Lens::getSpotlight() const
  75. {
  76. return &spotlight;
  77. }
  78. inline Spotlight* Lens::getSpotlight()
  79. {
  80. return &spotlight;
  81. }
  82. #endif // LENS_HPP