12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #ifndef GAME_H
- #define GAME_H
- #include "client/input/Control.h"
- #include "client/utils/Clock.h"
- #include "client/rendering/RenderSettings.h"
- #include "client/rendering/Renderer.h"
- #include "client/rendering/Mesh.h"
- #include "client/rendering/FileTexture.h"
- #include "client/rendering/FontRenderer.h"
- #include "common/world/World.h"
- #include "common/block/BlockRegistry.h"
- #include "rendering/renderer/WorldRenderer.h"
- #include "common/utils/KDTree.h"
- #include "client/rendering/Lines.h"
- #include "client/rendering/WindowSize.h"
- class Game final {
- public:
- Game(const Control& control, const Clock& fps, const Clock& tps, RenderSettings& renderSettings,
- const WindowSize& size, const char* file);
- void tick();
- void renderWorld(float lag, Renderer& renderer) const;
- void renderWorldLines(float lag, Renderer& renderer) const;
- void renderTextOverlay(float lag, Renderer& renderer, FontRenderer& fr) const;
- bool isRunning() const;
- private:
- Vector3 splineTangent(const Vector3& prev, const Vector3& current, const Vector3& next) const;
- Vector3 interpolate(const Vector3& a, const Vector3& b, const Vector3& tanA, const Vector3& tanB, float t) const;
- float distance(uint index, uint splits) const;
- Vector3 pointUntilDistance(float leftDistance, uint index, uint splits) const;
- void getPointsAndTangents(uint index, Vector3& a, Vector3& b, Vector3& tanA, Vector3& tanB) const;
- void updateDistances();
- void generateSphere(std::vector<KDTree::Triangle>& data);
- void generateRandom(std::vector<KDTree::Triangle>& data);
- const Control& control;
- const Clock& fps;
- const Clock& tps;
- RenderSettings& renderSettings;
- const WindowSize& size;
- Vector3 lastPos;
- mutable Vector3 pos;
- Quaternion lastRotation;
- Quaternion rotation;
- BlockRegistry blockRegistry;
- World world;
- WorldRenderer worldRenderer;
- struct Point {
- Vector3 pos;
- Quaternion q;
- float distance;
- };
- List<Point, 25> cameraPoints;
- uint pointIndex;
- float moveSpeed;
- float movedLength;
- enum Mode {
- AUTO, PLAYER
- };
- Mode mode;
- KDTree kdTree;
- Lines lines;
- Mesh treeData;
- Lines clickLine;
- };
- #endif
|