EntityModel.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include "Entity.h"
  17. /**
  18. * A 3D model for an entity.
  19. */
  20. class EntityModel : public Entity{
  21. public:
  22. /**
  23. * Constructor.
  24. *
  25. * @param name[in] Entity name.
  26. * @param file_name[in] File with the model data.
  27. * @param node[in] Scene node to attach the model to.
  28. */
  29. EntityModel(
  30. const Ogre::String& name, const Ogre::String file_name,
  31. Ogre::SceneNode* node
  32. );
  33. virtual ~EntityModel();
  34. /**
  35. * Updates the model status.
  36. */
  37. virtual void Update();
  38. /**
  39. * Toggles the model visibility.
  40. *
  41. * @param visible[in] True to make the model visible, false to turn it
  42. * invisible.
  43. */
  44. virtual void SetVisible(const bool visible);
  45. /**
  46. * Checks the model visibility.
  47. *
  48. * @return True if the model is visible, false if it's invisible.
  49. */
  50. virtual bool IsVisible() const;
  51. /**
  52. * Plays an animation of the model.
  53. *
  54. * @param animation[in] Name of the animation to play.
  55. * @param state[in] Initial state of the animation.
  56. * @param play_type[in] Play mode, for single or looped playbacks.
  57. * @param start[in] Start point in time of the animation, in seconds.
  58. * @param end[in] End point in time of the animation, in seconds.
  59. */
  60. virtual void PlayAnimation(
  61. const Ogre::String& animation, AnimationState state,
  62. AnimationPlayType play_type, const float start, const float end
  63. );
  64. /**
  65. * Resumes an animation.
  66. *
  67. * @param animation[in] The name of the animation to resume.
  68. */
  69. virtual void PlayAnimationContinue(const Ogre::String& animation);
  70. /**
  71. * Updates the animation.
  72. *
  73. * @param delta[in] Ellapsed time.
  74. */
  75. virtual void UpdateAnimation(const float delta);
  76. private:
  77. /**
  78. * Constructor.
  79. */
  80. EntityModel();
  81. /**
  82. * The model.
  83. */
  84. Ogre::Entity* model_;
  85. /**
  86. * The current animation state.
  87. */
  88. Ogre::AnimationState* animation_current_;
  89. };