mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-06 17:41:04 +00:00
Draw node animation for items (#15930)
This commit is contained in:
parent
1db5a2f950
commit
a6d4cd7c15
9 changed files with 117 additions and 74 deletions
|
@ -11,6 +11,8 @@
|
|||
#include <EMaterialTypes.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <SColor.h>
|
||||
#include <memory>
|
||||
#include "tile.h"
|
||||
|
||||
namespace irr::scene
|
||||
{
|
||||
|
@ -28,9 +30,10 @@ struct ContentFeatures;
|
|||
class ShadowRenderer;
|
||||
|
||||
/*
|
||||
* Holds color information of an item mesh's buffer.
|
||||
* Holds information of an item mesh's buffer.
|
||||
* Used for coloring and animation.
|
||||
*/
|
||||
class ItemPartColor
|
||||
class ItemMeshBufferInfo
|
||||
{
|
||||
/*
|
||||
* Optional color that overrides the global base color.
|
||||
|
@ -47,12 +50,14 @@ class ItemPartColor
|
|||
|
||||
public:
|
||||
|
||||
ItemPartColor() = default;
|
||||
ItemMeshBufferInfo() = default;
|
||||
|
||||
ItemPartColor(bool override, video::SColor color) :
|
||||
ItemMeshBufferInfo(bool override, video::SColor color) :
|
||||
override_color(color), override_color_set(override)
|
||||
{}
|
||||
|
||||
ItemMeshBufferInfo(const TileLayer &layer);
|
||||
|
||||
void applyOverride(video::SColor &dest) const {
|
||||
if (override_color_set)
|
||||
dest = override_color;
|
||||
|
@ -65,15 +70,18 @@ public:
|
|||
last_colorized = target;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Null for no animated parts
|
||||
std::unique_ptr<AnimationInfo> animation_info;
|
||||
};
|
||||
|
||||
struct ItemMesh
|
||||
{
|
||||
scene::IMesh *mesh = nullptr;
|
||||
/*
|
||||
* Stores the color of each mesh buffer.
|
||||
* Stores draw information of each mesh buffer.
|
||||
*/
|
||||
std::vector<ItemPartColor> buffer_colors;
|
||||
std::vector<ItemMeshBufferInfo> buffer_info;
|
||||
/*
|
||||
* If false, all faces of the item should have the same brightness.
|
||||
* Disables shading based on normal vectors.
|
||||
|
@ -101,7 +109,7 @@ public:
|
|||
// Must only be used if the constructor was called with lighting = false
|
||||
void setColor(video::SColor color);
|
||||
|
||||
void setNodeLightColor(video::SColor color);
|
||||
void setLightColorAndAnimation(video::SColor color, float animation_time);
|
||||
|
||||
scene::IMesh *getMesh() { return m_meshnode->getMesh(); }
|
||||
|
||||
|
@ -120,10 +128,10 @@ private:
|
|||
bool m_bilinear_filter;
|
||||
bool m_trilinear_filter;
|
||||
/*!
|
||||
* Stores the colors of the mesh's mesh buffers.
|
||||
* Stores the colors and animation data of the mesh's mesh buffers.
|
||||
* This does not include lighting.
|
||||
*/
|
||||
std::vector<ItemPartColor> m_colors;
|
||||
std::vector<ItemMeshBufferInfo> m_buffer_info;
|
||||
/*!
|
||||
* The base color of this mesh. This is the default
|
||||
* for all mesh buffers.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue