mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-18 00:27:02 +08:00
feat: add tree generation
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <Cubed/renderer.hpp>
|
||||
#include <Cubed/texture_manager.hpp>
|
||||
#include <Cubed/window.hpp>
|
||||
namespace Cubed {
|
||||
|
||||
class App {
|
||||
public:
|
||||
@@ -35,7 +36,6 @@ private:
|
||||
inline static double fps_time_count = 0.0f;
|
||||
inline static int frame_count = 0;
|
||||
inline static int fps = 0;
|
||||
inline static unsigned int m_seed = 0;
|
||||
|
||||
void init();
|
||||
|
||||
@@ -46,4 +46,6 @@ private:
|
||||
void render();
|
||||
void run();
|
||||
void update();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
constexpr int WORLD_SIZE_Y = 256;
|
||||
constexpr int MAX_BLOCK_NUM = 5;
|
||||
constexpr int MAX_BLOCK_NUM = 7;
|
||||
constexpr int MAX_UI_NUM = 1;
|
||||
|
||||
constexpr int CHUCK_SIZE = 16;
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
|
||||
constexpr float BIOME_NOISE_FREQUENCY = 0.003f;
|
||||
|
||||
constexpr float PLAIN_FREQ = 0.5f;
|
||||
constexpr float FOREST_FREQ = 1.0f;
|
||||
constexpr float DESERT_FREQ = 1.0f;
|
||||
constexpr float PLAIN_FREQ = 0.4f;
|
||||
constexpr float FOREST_FREQ = 1.2f;
|
||||
constexpr float DESERT_FREQ = 1.2f;
|
||||
constexpr float MOUNTAIN_FREQ = 2.0f;
|
||||
|
||||
enum class Biome {
|
||||
|
||||
@@ -47,7 +47,7 @@ public:
|
||||
const std::vector<uint8_t>& get_chunk_blocks() const;
|
||||
|
||||
static int get_index(int x, int y, int z);
|
||||
|
||||
static int get_index(const glm::vec3& pos);
|
||||
void init_chunk();
|
||||
void gen_vertex_data();
|
||||
// 0 : (1, 0)
|
||||
|
||||
12
include/Cubed/gameplay/tree.hpp
Normal file
12
include/Cubed/gameplay/tree.hpp
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
|
||||
class Chunk;
|
||||
|
||||
struct TreeStructNode {
|
||||
glm::ivec3 offset{0, 0, 0};
|
||||
unsigned id = 0;
|
||||
};
|
||||
|
||||
bool build_tree(Chunk& chunk, const glm::ivec3& pos);
|
||||
21
include/Cubed/tools/cubed_random.hpp
Normal file
21
include/Cubed/tools/cubed_random.hpp
Normal file
@@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
#include <random>
|
||||
namespace Cubed {
|
||||
|
||||
class Random {
|
||||
public:
|
||||
Random();
|
||||
|
||||
static Random& get();
|
||||
|
||||
bool random_bool(double probability);
|
||||
std::mt19937& engine();
|
||||
unsigned seed();
|
||||
|
||||
private:
|
||||
unsigned int m_seed = 0;
|
||||
std::mt19937 m_engine;
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
class PerlinNoise {
|
||||
public:
|
||||
static void init(unsigned int seed);
|
||||
static void init();
|
||||
static float noise(float x, float y, float z);
|
||||
private:
|
||||
static inline bool is_init = false;
|
||||
|
||||
Reference in New Issue
Block a user