QGearsWalkmeshFile.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 "common/QGearsResource.h"
  17. #include "core/Walkmesh.h"
  18. namespace QGears{
  19. /**
  20. * Handles walkmesh files.
  21. */
  22. class WalkmeshFile : public Resource{
  23. public:
  24. /**
  25. * Constructor.
  26. *
  27. * @param creator[in] Pointer to the ResourceManager that is
  28. * creating this resource.
  29. * @param name[in] The unique name of the resource.
  30. * @param handle[in] @todo Understand and document.
  31. * @param group[in] The name of the resource group to which this
  32. * resource belong.
  33. * @param is_manual[in] True if the resource is manually loaded,
  34. * false otherwise.
  35. * @param loader[in] Pointer to a ManualResourceLoader
  36. * implementation which will be called when the Resource wishes to
  37. * load (should be supplied if is_manual is set to true). It can be
  38. * null, but the Resource will never be able to reload if anything
  39. * ever causes it to unload. Therefore provision of a proper
  40. * ManualResourceLoader instance is strongly recommended.
  41. */
  42. WalkmeshFile(
  43. Ogre::ResourceManager* creator, const String &name,
  44. Ogre::ResourceHandle handle, const String& group,
  45. bool is_manual = false,
  46. Ogre::ManualResourceLoader* loader = NULL
  47. );
  48. /**
  49. * Destructor.
  50. */
  51. virtual ~WalkmeshFile();
  52. /**
  53. * The type of resource.
  54. */
  55. static const String RESOURCE_TYPE;
  56. typedef ::WalkmeshTriangle Triangle;
  57. typedef std::vector<Triangle> TriangleList;
  58. /**
  59. * Retrieves the list of triangles.
  60. */
  61. virtual TriangleList& GetTriangles();
  62. protected:
  63. /**
  64. * Loads the file.
  65. */
  66. virtual void loadImpl() override;
  67. /**
  68. * Unloads the file.
  69. */
  70. virtual void unloadImpl() override;
  71. /**
  72. * Calculates the size of the palette.
  73. *
  74. * @return The size of the palette.
  75. * @todo Units?
  76. */
  77. virtual size_t calculateSize() const;
  78. private:
  79. TriangleList triangles_;
  80. };
  81. typedef Ogre::SharedPtr<WalkmeshFile> WalkmeshFilePtr;
  82. }