emissive items
This commit is contained in:
@@ -95,6 +95,7 @@ Content* ContentBuilder::build() {
|
|||||||
|
|
||||||
// Generating runtime info
|
// Generating runtime info
|
||||||
def->rt.id = itemDefsIndices.size();
|
def->rt.id = itemDefsIndices.size();
|
||||||
|
def->rt.emissive = *((uint32_t*)def->emission);
|
||||||
itemDefsIndices.push_back(def);
|
itemDefsIndices.push_back(def);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -234,6 +234,14 @@ void ContentLoader::loadItem(ItemDef* def, std::string name, fs::path file) {
|
|||||||
}
|
}
|
||||||
root->str("icon", def->icon);
|
root->str("icon", def->icon);
|
||||||
root->str("placing-block", def->placingBlock);
|
root->str("placing-block", def->placingBlock);
|
||||||
|
|
||||||
|
// item light emission [r, g, b] where r,g,b in range [0..15]
|
||||||
|
json::JArray* emissionobj = root->arr("emission");
|
||||||
|
if (emissionobj) {
|
||||||
|
def->emission[0] = emissionobj->num(0);
|
||||||
|
def->emission[1] = emissionobj->num(1);
|
||||||
|
def->emission[2] = emissionobj->num(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ContentLoader::loadBlock(Block* def, std::string full, std::string name) {
|
void ContentLoader::loadBlock(Block* def, std::string full, std::string name) {
|
||||||
@@ -281,6 +289,10 @@ void ContentLoader::load(ContentBuilder* builder) {
|
|||||||
item->iconType = item_icon_type::block;
|
item->iconType = item_icon_type::block;
|
||||||
item->icon = full;
|
item->icon = full;
|
||||||
item->placingBlock = full;
|
item->placingBlock = full;
|
||||||
|
|
||||||
|
for (uint j = 0; j < 4; j++) {
|
||||||
|
item->emission[j] = def->emission[j];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include "../maths/voxmaths.h"
|
#include "../maths/voxmaths.h"
|
||||||
#include "../settings.h"
|
#include "../settings.h"
|
||||||
#include "../engine.h"
|
#include "../engine.h"
|
||||||
|
#include "../items/ItemDef.h"
|
||||||
#include "LevelFrontend.h"
|
#include "LevelFrontend.h"
|
||||||
#include "graphics/Skybox.h"
|
#include "graphics/Skybox.h"
|
||||||
|
|
||||||
@@ -168,14 +169,14 @@ void WorldRenderer::draw(const GfxContext& pctx, Camera* camera){
|
|||||||
shader->uniform3f("u_cameraPos", camera->position);
|
shader->uniform3f("u_cameraPos", camera->position);
|
||||||
shader->uniform1i("u_cubemap", 1);
|
shader->uniform1i("u_cubemap", 1);
|
||||||
{
|
{
|
||||||
blockid_t id = level->player->getChosenItem();
|
itemid_t id = level->player->getChosenItem();
|
||||||
Block* block = contentIds->getBlockDef(id);
|
ItemDef* item = contentIds->getItemDef(id);
|
||||||
assert(block != nullptr);
|
assert(item != nullptr);
|
||||||
float multiplier = 0.5f;
|
float multiplier = 0.5f;
|
||||||
shader->uniform3f("u_torchlightColor",
|
shader->uniform3f("u_torchlightColor",
|
||||||
block->emission[0] / 15.0f * multiplier,
|
item->emission[0] / 15.0f * multiplier,
|
||||||
block->emission[1] / 15.0f * multiplier,
|
item->emission[1] / 15.0f * multiplier,
|
||||||
block->emission[2] / 15.0f * multiplier);
|
item->emission[2] / 15.0f * multiplier);
|
||||||
shader->uniform1f("u_torchlightDistance", 6.0f);
|
shader->uniform1f("u_torchlightDistance", 6.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ public:
|
|||||||
std::string const name;
|
std::string const name;
|
||||||
|
|
||||||
bool generated = false;
|
bool generated = false;
|
||||||
|
uint8_t emission[4] {0, 0, 0, 0};
|
||||||
|
|
||||||
item_icon_type iconType = item_icon_type::sprite;
|
item_icon_type iconType = item_icon_type::sprite;
|
||||||
std::string icon = "block:notfound";
|
std::string icon = "block:notfound";
|
||||||
@@ -31,6 +32,7 @@ public:
|
|||||||
itemid_t id;
|
itemid_t id;
|
||||||
item_funcs_set funcsset {};
|
item_funcs_set funcsset {};
|
||||||
blockid_t placingBlock;
|
blockid_t placingBlock;
|
||||||
|
bool emissive = false;
|
||||||
} rt;
|
} rt;
|
||||||
|
|
||||||
ItemDef(std::string name);
|
ItemDef(std::string name);
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ public:
|
|||||||
std::vector<BoxModel> modelBoxes = {};
|
std::vector<BoxModel> modelBoxes = {};
|
||||||
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
|
std::vector<glm::vec3> modelExtraPoints = {}; //initially made for tetragons
|
||||||
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
|
std::vector<UVRegion> modelUVs = {}; // boxes' tex-UVs also there
|
||||||
unsigned char emission[4] {0, 0, 0, 0};
|
uint8_t emission[4] {0, 0, 0, 0};
|
||||||
unsigned char drawGroup = 0;
|
unsigned char drawGroup = 0;
|
||||||
BlockModel model = BlockModel::block;
|
BlockModel model = BlockModel::block;
|
||||||
bool lightPassing = false;
|
bool lightPassing = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user