1 #ifndef BLOBS_WORLD_PLANET_HPP_
2 #define BLOBS_WORLD_PLANET_HPP_
7 #include "../graphics/glm.hpp"
8 #include "../graphics/SimpleVAO.hpp"
20 /// A planet has six surfaces, numbered 0 to 5, each filled with
21 /// sidelength² tiles.
26 explicit Planet(int sidelength);
29 Planet(const Planet &) = delete;
30 Planet &operator =(const Planet &) = delete;
32 Planet(Planet &&) = delete;
33 Planet &operator =(Planet &&) = delete;
36 /// Get the tile at given surface and coordinates.
37 Tile &TileAt(int surface, int x, int y) {
38 return tiles[IndexOf(surface, x, y)];
40 const Tile &TileAt(int surface, int x, int y) const {
41 return tiles[IndexOf(surface, x, y)];
44 /// Convert coordinates into a tile index.
45 int IndexOf(int surface, int x, int y) const {
46 assert(0 <= surface && surface <= 5);
47 assert(0 <= x && x <= sidelength);
48 assert(0 <= y && y <= sidelength);
49 return surface * TilesPerSurface() + y * SideLength() + x;
51 /// The length of the side of each surface.
52 int SideLength() const {
55 /// The number of tiles of one surface.
56 int TilesPerSurface() const {
57 return SideLength() * SideLength();
59 /// Total number of tiles of all surfaces combined.
60 int TilesTotal() const {
61 return 6 * TilesPerSurface();
65 void Draw(app::Assets &, graphics::Viewport &) override;
69 std::unique_ptr<Tile []> tiles;
75 graphics::SimpleVAO<Attributes, unsigned int> vao;
79 void GenerateTest(Planet &);