mirror of
https://github.com/zhenyan121/Cubed.git
synced 2026-06-22 10:37:00 +08:00
feat: grass (#11)
* feat: add grass texture and update grass_block texture * feat: add block data * feat: add blocks_tool * feat: add sync info and change function in blocks_tools * feat: add check and new function * refactor: make block texture loading data-driven * feat: add rendering for grass * feat: passable grass * feat: random grass place * fix: memory leak in TextureManager::load_cross_plane_texture
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace Cubed {
|
||||
|
||||
#pragma region NORMAL_BLOCK
|
||||
constexpr float VERTICES_POS[6][6][3] = {
|
||||
// ===== front (z = +1) =====
|
||||
{{0.0f, 0.0f, 1.0f}, // bottom left
|
||||
@@ -91,7 +91,7 @@ constexpr float TEX_COORDS[6][6][2] = {
|
||||
{0.0f, 1.0f}, // back left
|
||||
{0.0f, 0.0f}} // front left
|
||||
};
|
||||
|
||||
#pragma endregion
|
||||
constexpr float CUBE_VER[24] = {0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 1.0,
|
||||
0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 1.0,
|
||||
0.0, 1.0, 1.0, 1.0, 1.0, 0.0, 1.0, 1.0};
|
||||
@@ -112,7 +112,43 @@ constexpr float SQUARE_TEXTURE_POS[6][2] = {
|
||||
{0.0f, 0.0f}, {0.0f, 1.0f}, {1.0f, 1.0f},
|
||||
{1.0f, 1.0f}, {1.0f, 0.0f}, {0.0f, 0.0f},
|
||||
};
|
||||
#pragma region CROSS_PLANE
|
||||
constexpr float CROSS_VERTICES_POS[2][6][3] = {
|
||||
// ===== Plane 1: bottom-front-left to top-back-right =====
|
||||
{{0.0f, 0.0f, 0.0f}, // bottom front left
|
||||
{0.0f, 1.0f, 0.0f}, // top front left
|
||||
{1.0f, 1.0f, 1.0f}, // top back right
|
||||
{1.0f, 1.0f, 1.0f}, // top back right
|
||||
{1.0f, 0.0f, 1.0f}, // bottom back right
|
||||
{0.0f, 0.0f, 0.0f}}, // bottom front left
|
||||
|
||||
// ===== Plane 2: bottom-front-right to top-back-left =====
|
||||
{{1.0f, 0.0f, 0.0f}, // bottom front right
|
||||
{1.0f, 1.0f, 0.0f}, // top front right
|
||||
{0.0f, 1.0f, 1.0f}, // top back left
|
||||
{0.0f, 1.0f, 1.0f}, // top back left
|
||||
{0.0f, 0.0f, 1.0f}, // bottom back left
|
||||
{1.0f, 0.0f, 0.0f}}, // bottom front right
|
||||
};
|
||||
|
||||
constexpr float CROSS_TEX_COORDS[2][6][2] = {
|
||||
// ===== Plane 1: bottom-front-left to top-back-right =====
|
||||
{{0.0f, 1.0f}, // bottom left
|
||||
{0.0f, 0.0f}, // top left
|
||||
{1.0f, 0.0f}, // top right
|
||||
{1.0f, 0.0f}, // top right
|
||||
{1.0f, 1.0f}, // bottom right
|
||||
{0.0f, 1.0f}}, // bottom left
|
||||
|
||||
// ===== Plane 2: bottom-front-right to top-back-left =====
|
||||
{{0.0f, 1.0f}, // bottom left
|
||||
{0.0f, 0.0f}, // top left
|
||||
{1.0f, 0.0f}, // top right
|
||||
{1.0f, 0.0f}, // top right
|
||||
{1.0f, 1.0f}, // bottom right
|
||||
{0.0f, 1.0f}}, // bottom left
|
||||
};
|
||||
#pragma endregion
|
||||
struct Vertex {
|
||||
float x = 0.0f, y = 0.0f, z = 0.0f;
|
||||
float s = 0.0f, t = 0.0f;
|
||||
|
||||
Reference in New Issue
Block a user