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

88 lines
2.3 KiB

7 years ago
  1. /*
  2. * Copyright (C) 2017 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 TERRAIN_HPP
  20. #define TERRAIN_HPP
  21. #include <emergent/emergent.hpp>
  22. using namespace Emergent;
  23. class Terrain
  24. {
  25. public:
  26. /**
  27. * Creates a flat terrain surface.
  28. *
  29. * @param columns Specifies the width of the terrain, in cells.
  30. * @param rows Specifies the depth of the terrain, in cells.
  31. * @param dimensions Specifies the dimensions of the terrain.
  32. */
  33. void create(int columns, int rows, const Vector3& dimensions);
  34. /// Returns the winged-edge mesh representing the terrain surface.
  35. const WingedEdge* getSurfaceMesh() const;
  36. /// Returns the winged-edge mesh representing the terrain subsurface.
  37. const WingedEdge* getSubsurfaceMesh() const;
  38. /// Returns the model representing the terrain surface.
  39. const Model* getSurfaceModel() const;
  40. /// Returns the model representing the terrain subsurface.
  41. const Model* getSubsurfaceModel() const;
  42. private:
  43. void createSurface();
  44. void createSubsurface();
  45. int columns;
  46. int rows;
  47. Vector3 dimensions;
  48. std::vector<Vector3> surfaceVertices;
  49. std::vector<Vector3> subsurfaceVertices;
  50. std::vector<std::size_t> surfaceIndices;
  51. std::vector<std::size_t> subsurfaceIndices;
  52. WingedEdge surfaceMesh;
  53. WingedEdge subsurfaceMesh;
  54. Model surfaceModel;
  55. Model subsurfaceModel;
  56. };
  57. inline const WingedEdge* Terrain::getSurfaceMesh() const
  58. {
  59. return &surfaceMesh;
  60. };
  61. inline const WingedEdge* Terrain::getSubsurfaceMesh() const
  62. {
  63. return &subsurfaceMesh;
  64. };
  65. inline const Model* Terrain::getSurfaceModel() const
  66. {
  67. return &surfaceModel;
  68. }
  69. inline const Model* Terrain::getSubsurfaceModel() const
  70. {
  71. return &subsurfaceModel;
  72. }
  73. #endif // TERRAIN_HPP