mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Hardware coloring for itemstacks
Adds the possibility to colorize item stacks based on their metadata. In the item/node definition you can specify palette (an image file) and color (fallback color if the item has no palette or metadata). Then you can add palette_index to the metadata. Dropped itemstacks with different colors do not merge.
This commit is contained in:
parent
d4e9dd4643
commit
58d83a7bb2
23 changed files with 308 additions and 139 deletions
20
src/hud.cpp
20
src/hud.cpp
|
@ -32,6 +32,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "fontengine.h"
|
||||
#include "guiscalingfilter.h"
|
||||
#include "mesh.h"
|
||||
#include "wieldmesh.h"
|
||||
#include <IGUIStaticText.h>
|
||||
|
||||
#ifdef HAVE_TOUCHSCREENGUI
|
||||
|
@ -642,9 +643,10 @@ void drawItemStack(video::IVideoDriver *driver,
|
|||
}
|
||||
|
||||
const ItemDefinition &def = item.getDefinition(client->idef());
|
||||
scene::IMesh* mesh = client->idef()->getWieldMesh(def.name, client);
|
||||
ItemMesh *imesh = client->idef()->getWieldMesh(def.name, client);
|
||||
|
||||
if (mesh) {
|
||||
if (imesh && imesh->mesh) {
|
||||
scene::IMesh *mesh = imesh->mesh;
|
||||
driver->clearZBuffer();
|
||||
s32 delta = 0;
|
||||
if (rotation_kind < IT_ROT_NONE) {
|
||||
|
@ -667,16 +669,28 @@ void drawItemStack(video::IVideoDriver *driver,
|
|||
matrix.makeIdentity();
|
||||
|
||||
if (enable_animations) {
|
||||
float timer_f = (float)delta / 5000.0;
|
||||
float timer_f = (float) delta / 5000.0;
|
||||
matrix.setRotationDegrees(core::vector3df(0, 360 * timer_f, 0));
|
||||
}
|
||||
|
||||
driver->setTransform(video::ETS_WORLD, matrix);
|
||||
driver->setViewPort(rect);
|
||||
|
||||
video::SColor basecolor =
|
||||
client->idef()->getItemstackColor(item, client);
|
||||
|
||||
u32 mc = mesh->getMeshBufferCount();
|
||||
for (u32 j = 0; j < mc; ++j) {
|
||||
scene::IMeshBuffer *buf = mesh->getMeshBuffer(j);
|
||||
// we can modify vertices relatively fast,
|
||||
// because these meshes are not buffered.
|
||||
assert(buf->getHardwareMappingHint_Vertex() == scene::EHM_NEVER);
|
||||
video::SColor c = basecolor;
|
||||
if (imesh->buffer_colors.size() > j) {
|
||||
std::pair<bool, video::SColor> p = imesh->buffer_colors[j];
|
||||
c = p.first ? p.second : basecolor;
|
||||
}
|
||||
colorizeMeshBuffer(buf, &c);
|
||||
video::SMaterial &material = buf->getMaterial();
|
||||
material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
|
||||
material.Lighting = false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue