mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
feat: add perlin noise
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
#pragma once
|
||||
constexpr int WORLD_SIZE_X = 32;
|
||||
constexpr int WORLD_SIZE_Z = 32;
|
||||
constexpr int WORLD_SIZE_Y = 16;
|
||||
constexpr int WORLD_SIZE_Y = 256;
|
||||
constexpr int MAX_BLOCK_NUM = 2;
|
||||
constexpr int MAX_UI_NUM = 1;
|
||||
|
||||
constexpr int CHUCK_SIZE = 16;
|
||||
constexpr int DISTANCE = 8;
|
||||
constexpr int DISTANCE = 16;
|
||||
constexpr int MAX_BLOCK_STATUS = 1;
|
||||
constexpr int MAX_CHARACTER = 128;
|
||||
constexpr float FOV = 70.0f;
|
||||
|
||||
constexpr int SEED = 999;
|
||||
|
||||
constexpr float VERTICES_POS[6][6][3] = {
|
||||
// ===== front (z = +1) =====
|
||||
0.0f, 0.0f, 1.0f, // bottom left
|
||||
|
||||
@@ -16,6 +16,9 @@ private:
|
||||
std::vector<uint8_t> m_blocks;
|
||||
GLuint m_vbo = 0;
|
||||
std::vector<Vertex> m_vertexs_data;
|
||||
|
||||
float frequency = 0.01f;
|
||||
float height = 80;
|
||||
|
||||
public:
|
||||
Chunk(World& world, ChunkPos chunk_pos);
|
||||
|
||||
@@ -21,7 +21,8 @@ private:
|
||||
|
||||
float m_sensitivity = 0.15f;
|
||||
|
||||
float max_speed = 4.5f;
|
||||
//float max_speed = 4.5f;
|
||||
float max_speed = 7.5f;
|
||||
float y_speed = 0.0f;
|
||||
bool can_up = true;
|
||||
float speed = 0;
|
||||
@@ -29,7 +30,7 @@ private:
|
||||
glm::vec3 direction = glm::vec3(0.0f, 0.0f, 0.0f);
|
||||
glm::vec3 move_distance {0.0f, 0.0f, 0.0f};
|
||||
// player is tow block tall, the pos is the lower pos
|
||||
glm::vec3 m_player_pos {0.0f, 15.0f, 0.0f};
|
||||
glm::vec3 m_player_pos {0.0f, 120.0f, 0.0f};
|
||||
glm::vec3 m_front {0, 0, -1};
|
||||
glm::vec3 m_right {0, 0, 0};
|
||||
glm::vec3 m_size {0.6f, 1.8f, 0.6f};
|
||||
|
||||
16
include/Cubed/tools/perlin_noise.hpp
Normal file
16
include/Cubed/tools/perlin_noise.hpp
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
class PerlinNoise {
|
||||
public:
|
||||
static void init();
|
||||
static float noise(float x, float y, float z);
|
||||
private:
|
||||
static inline bool is_init = false;
|
||||
static inline std::vector<int> p;
|
||||
|
||||
static float fade(float t);
|
||||
static float lerp(float t, float a, float b);
|
||||
static float grad(int hash, float x, float y, float z);
|
||||
};
|
||||
Reference in New Issue
Block a user