18#ifndef HEADER_SP_MESH_NODE_HPP
19#define HEADER_SP_MESH_NODE_HPP
21#include "../../../lib/irrlicht/source/Irrlicht/CAnimatedMeshSceneNode.h"
27#include <unordered_map>
31namespace GE {
class GERenderInfo; }
38class SPMeshNode :
public irr::scene::CAnimatedMeshSceneNode
41 std::vector<std::shared_ptr<GE::GERenderInfo> > m_render_info;
43 std::shared_ptr<GE::GERenderInfo> m_first_render_info;
45 std::unordered_map<std::string, IBoneSceneNode*> m_joint_nodes;
49 int m_skinning_offset;
53 bool m_is_in_shadowpass;
55 float m_saved_transition_frame;
57 std::vector<core::matrix4> m_skinning_matrices;
59 video::SColorf m_glow_color;
61 std::vector<std::array<float, 2> > m_texture_matrices;
64 void cleanRenderInfo();
68 for (
auto& p : m_joint_nodes)
70 removeChild(p.second);
72 m_joint_nodes.clear();
73 m_skinning_matrices.clear();
78 SPMeshNode(IAnimatedMesh* mesh, ISceneNode* parent, ISceneManager* mgr,
79 s32
id,
const std::string& debug_name,
80 const core::vector3df& position = core::vector3df(),
81 const core::vector3df& rotation = core::vector3df(),
82 const core::vector3df& scale = core::vector3df(1, 1, 1),
83 std::shared_ptr<GE::GERenderInfo> render_info =
nullptr);
87 virtual void render() {}
89 virtual void setMesh(irr::scene::IAnimatedMesh* mesh);
91 virtual void OnAnimate(u32 time_ms);
93 virtual void animateJoints(
bool calculate_absolute_positions =
true) {}
95 virtual irr::scene::IMesh* getMeshForCurrentFrame();
97 virtual IBoneSceneNode* getJointNode(
const c8* joint_name);
99 virtual IBoneSceneNode* getJointNode(u32 joint_id)
106 virtual void setJointMode(E_JOINT_UPDATE_ON_RENDER mode) {}
108 virtual void checkJoints() {}
110 SPMesh* getSPM()
const {
return m_mesh; }
112 int getTotalJoints()
const;
114 void setSkinningOffset(
int offset) { m_skinning_offset = offset; }
116 int getSkinningOffset()
const {
return m_skinning_offset; }
118 void setAnimationState(
bool val);
120 bool getAnimationState()
const {
return m_animated; }
122 bool isInShadowPass()
const {
return m_is_in_shadowpass; }
124 void setInShadowPass(
const bool is_in_shadowpass)
126 m_is_in_shadowpass = is_in_shadowpass;
129 SPShader* getShader(
unsigned mesh_buffer_id)
const;
131 const core::matrix4* getSkinningMatrices()
const
132 {
return m_skinning_matrices.data(); }
134 GE::GERenderInfo* getRenderInfo(
unsigned mb_id)
const
136 if (m_render_info.size() > mb_id && m_render_info[mb_id].get())
138 return m_render_info[mb_id].get();
143 virtual void resetFirstRenderInfo(std::shared_ptr<GE::GERenderInfo> ri)
145 m_render_info.clear();
146 m_first_render_info = ri;
147 m_render_info.resize(getMesh()->getMeshBufferCount(),
148 m_first_render_info);
151 void setGlowColor(
const video::SColorf& color) { m_glow_color = color; }
153 const video::SColorf& getGlowColor()
const {
return m_glow_color; }
155 bool hasGlowColor()
const
157 return !(m_glow_color.r == 0.0f && m_glow_color.g == 0.0f &&
158 m_glow_color.b == 0.0f);
161 std::array<float, 2>& getTextureMatrix(
unsigned mb_id)
163 assert(mb_id < m_texture_matrices.size());
164 return m_texture_matrices[mb_id];
167 void setTextureMatrix(
unsigned mb_id,
const std::array<float, 2>& tm)
169 assert(mb_id < m_texture_matrices.size());
170 m_texture_matrices[mb_id] = tm;
173 virtual void setTransitionTime(f32 Time);
Definition: sp_mesh_node.hpp:39
Definition: sp_mesh.hpp:44
Definition: sp_shader.hpp:81