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

112 lines
2.2 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  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 TOOL_HPP
  20. #define TOOL_HPP
  21. #include <emergent/emergent.hpp>
  22. using namespace Emergent;
  23. class OrbitCam;
  24. /**
  25. * Abstract base class for tools. Tools are the only way for the user to interact with the world.
  26. */
  27. class Tool
  28. {
  29. public:
  30. /**
  31. * Creates an instance of Tool.
  32. */
  33. Tool();
  34. /**
  35. * Destroys an instance of Tool.
  36. */
  37. virtual ~Tool();
  38. /**
  39. * Updates the tool.
  40. *
  41. * @param dt Game timestep.
  42. */
  43. virtual void update(float dt) = 0;
  44. /**
  45. * Activates or deactivates the tool.
  46. */
  47. void setActive(bool active);
  48. /**
  49. * Sets the picking position.
  50. *
  51. * @param pick Picking position
  52. */
  53. void setPick(const Vector3& pick);
  54. /**
  55. * Sets the camera.
  56. *
  57. * @param camera Pointer to the camera.
  58. */
  59. void setOrbitCam(const OrbitCam* orbitCam);
  60. bool isActive() const;
  61. const Vector3& getPick() const;
  62. /**
  63. * Returns the model instance.
  64. */
  65. const ModelInstance* getModelInstance() const;
  66. ModelInstance* getModelInstance();
  67. protected:
  68. ModelInstance modelInstance;
  69. bool active;
  70. Vector3 pick;
  71. const OrbitCam* orbitCam;
  72. };
  73. inline bool Tool::isActive() const
  74. {
  75. return active;
  76. }
  77. inline void Tool::setPick(const Vector3& pick)
  78. {
  79. this->pick = pick;
  80. }
  81. inline const Vector3& Tool::getPick() const
  82. {
  83. return pick;
  84. }
  85. inline const ModelInstance* Tool::getModelInstance() const
  86. {
  87. return &modelInstance;
  88. }
  89. inline ModelInstance* Tool::getModelInstance()
  90. {
  91. return &modelInstance;
  92. }
  93. #endif // TOOL_HPP