Clone of Bael'Zharon's Respite @ https://github.com/boardwalk/bzr

Land.h 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Bael'Zharon's Respite
  3. * Copyright (C) 2014 Daniel Skorupski
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License along
  15. * with this program; if not, write to the Free Software Foundation, Inc.,
  16. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  17. */
  18. #ifndef BZR_LAND_H
  19. #define BZR_LAND_H
  20. #include "physics/Plane.h"
  21. #include "Landcell.h"
  22. struct Scene;
  23. class Land : public Landcell
  24. {
  25. public:
  26. static const int kGridSize = 9;
  27. static const fp_t kCellSize;
  28. static const fp_t kBlockSize;
  29. static const int kOffsetMapSize = 64;
  30. Land(const void* data, size_t size);
  31. void init();
  32. fp_t getHeight(int gridX, int gridY) const;
  33. uint8_t getRoad(int gridX, int gridY) const;
  34. uint8_t getTerrain(int gridX, int gridY) const;
  35. uint8_t getTerrainScene(int gridX, int gridY) const;
  36. bool isSplitNESW(int gridX, int gridY) const;
  37. Plane calcPlane(fp_t x, fp_t y) const;
  38. fp_t calcHeight(fp_t x, fp_t y) const;
  39. fp_t calcHeightUnbounded(fp_t x, fp_t y) const;
  40. LandcellId id() const override;
  41. uint32_t numStructures() const;
  42. const uint8_t* normalMap() const;
  43. private:
  44. // AC: CLandBlock
  45. PACK(struct Data
  46. {
  47. uint32_t fileId;
  48. uint32_t flags;
  49. uint16_t styles[kGridSize][kGridSize];
  50. uint8_t heightIndices[kGridSize][kGridSize];
  51. uint8_t pad;
  52. });
  53. void initStaticObjects();
  54. void initScenes();
  55. void initScene(int x, int y, const Scene& scene);
  56. bool roadAtPoint(fp_t x, fp_t y) const;
  57. Data data_;
  58. fp_t heights_[kGridSize][kGridSize];
  59. uint32_t numStructures_;
  60. vector<uint16_t> offsetMap_;
  61. fp_t offsetMapBase_;
  62. fp_t offsetMapScale_;
  63. vector<uint8_t> normalMap_;
  64. };
  65. #endif