Game.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #ifndef GAME_H
  2. #define GAME_H
  3. #include "client/input/Control.h"
  4. #include "client/utils/Clock.h"
  5. #include "client/rendering/RenderSettings.h"
  6. #include "client/rendering/Renderer.h"
  7. #include "client/rendering/Mesh.h"
  8. #include "client/rendering/FileTexture.h"
  9. #include "client/rendering/FontRenderer.h"
  10. #include "common/world/World.h"
  11. #include "common/block/BlockRegistry.h"
  12. #include "rendering/renderer/WorldRenderer.h"
  13. #include "common/utils/KDTree.h"
  14. #include "client/rendering/Lines.h"
  15. #include "client/rendering/WindowSize.h"
  16. class Game final {
  17. public:
  18. Game(const Control& control, const Clock& fps, const Clock& tps, RenderSettings& renderSettings,
  19. const WindowSize& size, const char* file);
  20. void tick();
  21. void renderWorld(float lag, Renderer& renderer) const;
  22. void renderWorldLines(float lag, Renderer& renderer) const;
  23. void renderTextOverlay(float lag, Renderer& renderer, FontRenderer& fr) const;
  24. bool isRunning() const;
  25. private:
  26. Vector3 splineTangent(const Vector3& prev, const Vector3& current, const Vector3& next) const;
  27. Vector3 interpolate(const Vector3& a, const Vector3& b, const Vector3& tanA, const Vector3& tanB, float t) const;
  28. float distance(uint index, uint splits) const;
  29. Vector3 pointUntilDistance(float leftDistance, uint index, uint splits) const;
  30. void getPointsAndTangents(uint index, Vector3& a, Vector3& b, Vector3& tanA, Vector3& tanB) const;
  31. void updateDistances();
  32. void generateSphere(std::vector<KDTree::Triangle>& data);
  33. void generateRandom(std::vector<KDTree::Triangle>& data);
  34. const Control& control;
  35. const Clock& fps;
  36. const Clock& tps;
  37. RenderSettings& renderSettings;
  38. const WindowSize& size;
  39. Vector3 lastPos;
  40. mutable Vector3 pos;
  41. Quaternion lastRotation;
  42. Quaternion rotation;
  43. BlockRegistry blockRegistry;
  44. World world;
  45. WorldRenderer worldRenderer;
  46. struct Point {
  47. Vector3 pos;
  48. Quaternion q;
  49. float distance;
  50. };
  51. List<Point, 25> cameraPoints;
  52. uint pointIndex;
  53. float moveSpeed;
  54. float movedLength;
  55. enum Mode {
  56. AUTO, PLAYER
  57. };
  58. Mode mode;
  59. KDTree kdTree;
  60. Lines lines;
  61. Mesh treeData;
  62. Lines clickLine;
  63. };
  64. #endif