block materials loading

This commit is contained in:
MihailRis
2024-03-09 03:36:08 +03:00
parent 90f3373f46
commit f4cc413f61
11 changed files with 144 additions and 40 deletions
+46 -18
View File
@@ -18,6 +18,8 @@ inline constexpr uint FACE_PY = 3;
inline constexpr uint FACE_MZ = 4;
inline constexpr uint FACE_PZ = 5;
/// @brief Grid size used for physics solver collision checking with
/// complex hitboxes
inline constexpr uint BLOCK_AABB_GRID = 16;
inline std::string DEFAULT_MATERIAL = "base:stone";
@@ -37,7 +39,7 @@ struct CoordSystem {
glm::ivec3 axisY;
glm::ivec3 axisZ;
// Grid 3d position fix offset (for negative vectors)
/// @brief Grid 3d position fix offset (for negative vectors)
glm::ivec3 fix;
CoordSystem() = default;
@@ -57,6 +59,7 @@ struct BlockRotProfile {
/// @brief Wood logs, pillars, pipes
static const BlockRotProfile PIPE;
/// @brief Doors, signs and other panes
static const BlockRotProfile PANE;
};
@@ -80,9 +83,9 @@ using BoxModel = AABB;
/// @brief Common kit of block properties applied to groups of blocks
struct BlockMaterial {
std::string name;
std::string stepsSound;
std::string placeSound;
std::string breakSound;
std::string stepsSound {""};
std::string placeSound {""};
std::string breakSound {""};
};
/// @brief Block properties definition
@@ -90,7 +93,8 @@ class Block {
public:
/// @brief Block string id (with prefix included)
std::string const name;
/// @brief Textures set applied to block sides
/// @brief Textures set applied to block sides
std::string textureFaces[6]; // -x,x, -y,y, -z,z
std::vector<std::string> modelTextures = {};
@@ -98,57 +102,81 @@ public:
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
/// @brief id of used BlockMaterial, may specify non-existing material
std::string material = DEFAULT_MATERIAL;
/// @brief Light emission R, G, B, S (sky lights: sun, moon, radioactive clouds)
uint8_t emission[4] {0, 0, 0, 0};
/// @brief Influences visible block sides for transparent blocks
uint8_t drawGroup = 0;
/// @brief Block model type
/// @brief Block model type
BlockModel model = BlockModel::block;
/// @brief Does the block passing lights into itself
/// @brief Does the block passing lights into itself
bool lightPassing = false;
/// @brief Does the block passing top-down sky lights into itself
/// @brief Does the block passing top-down sky lights into itself
bool skyLightPassing = false;
/// @brief Is the block a physical obstacle
/// @brief Is the block a physical obstacle
bool obstacle = true;
/// @brief Can the block be selected
/// @brief Can the block be selected
bool selectable = true;
/// @brief Can the block be replaced with other.
/// @brief Can the block be replaced with other.
/// Examples of replaceable blocks: air, flower, water
bool replaceable = false;
/// @brief Can player destroy the block
/// @brief Can player destroy the block
bool breakable = true;
/// @brief Can the block be oriented different ways
/// @brief Can the block be oriented different ways
bool rotatable = false;
/// @brief Can the block exist without physical support be a solid block below
bool grounded = false;
/// @brief Turns off block item generation
bool hidden = false;
/// @brief Set of block physical hitboxes
std::vector<AABB> hitboxes;
/// @brief Set of available block rotations (coord-systems)
/// @brief Set of available block rotations (coord-systems)
BlockRotProfile rotations;
/// @brief Item will be picked on MMB click on the block
std::string pickingItem = name+BLOCK_ITEM_SUFFIX;
/// @brief Block script name in blocks/ without extension
std::string scriptName = name.substr(name.find(':')+1);
/// @brief Default block layout will be used by hud.open_block(...)
/// @brief Default block layout will be used by hud.open_block(...)
std::string uiLayout = name;
/// @brief Block inventory size. 0 - no inventory
uint inventorySize = 0;
/// @brief Runtime indices (content indexing results)
struct {
/// @brief block runtime integer id
blockid_t id;
/// @brief is the block completely opaque for render and raycast
/// @brief is the block completely opaque for render and raycast
bool solid = true;
/// @brief does the block emit any lights
/// @brief does the block emit any lights
bool emissive = false;
/// @brief set of hitboxes sets with all coord-systems precalculated
std::vector<AABB> hitboxes[BlockRotProfile::MAX_COUNT];
/// @brief set of block callbacks flags
/// @brief set of block callbacks flags
block_funcs_set funcsset {};
/// @brief picking item integer id
itemid_t pickingItem = 0;
} rt;