mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-04-10 06:14:07 +08:00
feat: add outline for block that is looked
This commit is contained in:
@@ -5,7 +5,7 @@ constexpr int WORLD_SIZE_Y = 16;
|
||||
constexpr int MAX_BLOCK_NUM = 2;
|
||||
constexpr int CHUCK_SIZE = 16;
|
||||
constexpr int DISTANCE = 8;
|
||||
|
||||
constexpr int MAX_BLOCK_STATUS = 1;
|
||||
|
||||
constexpr float VERTICES_POS[6][6][3] = {
|
||||
// ===== front (z = +1) =====
|
||||
@@ -60,4 +60,21 @@ constexpr float TEX_COORDS[6][6][2] = {
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f,
|
||||
|
||||
};
|
||||
|
||||
constexpr float CUBE_VER[24] = {
|
||||
-0.5, -0.5, -0.5,
|
||||
0.5, -0.5, -0.5,
|
||||
0.5, 0.5, -0.5,
|
||||
-0.5, 0.5, -0.5,
|
||||
-0.5, -0.5, 0.5,
|
||||
0.5, -0.5, 0.5,
|
||||
0.5, 0.5, 0.5,
|
||||
-0.5, 0.5, 0.5
|
||||
};
|
||||
|
||||
constexpr int OUTLINE_CUBE_INDICES[24] = {
|
||||
0,1, 1,2, 2,3, 3,0,
|
||||
4,5, 5,6, 6,7, 7,4,
|
||||
0,4, 1,5, 2,6, 3,7
|
||||
};
|
||||
@@ -31,11 +31,12 @@ private:
|
||||
MoveState m_move_state;
|
||||
|
||||
std::string m_name;
|
||||
const World& m_world;
|
||||
World& m_world;
|
||||
|
||||
bool ray_cast(const glm::vec3& start, const glm::vec3& dir, glm::ivec3& block_pos, float distance = 4.0f);
|
||||
|
||||
public:
|
||||
Player(const World& world, const std::string& name);
|
||||
Player(World& world, const std::string& name);
|
||||
~Player();
|
||||
const glm::vec3& get_front() const;
|
||||
const glm::vec3& get_player_pos() const;
|
||||
|
||||
@@ -8,6 +8,7 @@ class Player;
|
||||
class World {
|
||||
private:
|
||||
BlockRenderData m_block_render_data;
|
||||
glm::ivec3 last_block_pos = glm::ivec3(0, 0, 0);
|
||||
std::unordered_map<ChunkPos , Chunk, ChunkPos::Hash> m_chunks;
|
||||
std::unordered_map<std::size_t, Player> m_players;
|
||||
public:
|
||||
@@ -16,8 +17,11 @@ public:
|
||||
~World();
|
||||
|
||||
const BlockRenderData& get_block_render_data(int x, int y ,int z);
|
||||
const glm::ivec3& get_last_block_pos() const;
|
||||
Player& get_player(const std::string& name);
|
||||
void init_world();
|
||||
bool is_block(const glm::ivec3& block_pos) const;
|
||||
void mark_looked_block(const glm::ivec3& block_pos);
|
||||
void render();
|
||||
void update(float delta_time);
|
||||
|
||||
|
||||
@@ -7,15 +7,18 @@
|
||||
class TextureManager {
|
||||
private:
|
||||
GLuint m_texture_array;
|
||||
|
||||
GLuint m_block_status_array;
|
||||
void load_block_status(int status_id);
|
||||
void load_block_texture(unsigned block_id);
|
||||
|
||||
|
||||
public:
|
||||
TextureManager();
|
||||
~TextureManager();
|
||||
|
||||
void delet_texture();
|
||||
GLuint get_block_status_array();
|
||||
GLuint get_texture_array();
|
||||
|
||||
// Must call after MapTable::init_map() and glfwMakeContextCurrent(window);
|
||||
void init_texture();
|
||||
};
|
||||
@@ -5,10 +5,11 @@
|
||||
#include <string>
|
||||
|
||||
namespace Shader {
|
||||
GLuint create_shader_program(const std::string& v_shader_path, const std::string& f_shader_path);
|
||||
void print_shader_log(GLuint shader);
|
||||
void print_program_info(int prog);
|
||||
bool check_opengl_error();
|
||||
std::string read_shader_source(const char* file_path);
|
||||
std::string read_shader_source(const std::string& file_path);
|
||||
void delete_image_data(unsigned char* data);
|
||||
unsigned char* load_image_data(const std::string& tex_image_path);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user