Factorise a common interface to stkmeshscenenode/animatedmesh
This commit is contained in:
parent
47b46558f2
commit
5c1b24b4e4
@ -7,7 +7,7 @@
|
||||
#include "graphics/stkmesh.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode
|
||||
class STKAnimatedMesh : public irr::scene::CAnimatedMeshSceneNode, public STKMeshCommon
|
||||
{
|
||||
protected:
|
||||
bool firstTime;
|
||||
@ -17,7 +17,7 @@ protected:
|
||||
core::matrix4 ModelViewProjectionMatrix;
|
||||
void cleanGLMeshes();
|
||||
public:
|
||||
void update();
|
||||
virtual void update();
|
||||
STKAnimatedMesh(irr::scene::IAnimatedMesh* mesh, irr::scene::ISceneNode* parent,
|
||||
irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position = irr::core::vector3df(0,0,0),
|
||||
|
@ -60,6 +60,18 @@ bool isObject(video::E_MATERIAL_TYPE type);
|
||||
|
||||
core::vector3df getWind();
|
||||
|
||||
|
||||
class STKMeshCommon
|
||||
{
|
||||
protected:
|
||||
PtrVector<GLMesh, REF> MeshSolidMaterial[MAT_COUNT];
|
||||
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
|
||||
public:
|
||||
virtual void update() = 0;
|
||||
virtual bool isImmediateDraw() const { return false; }
|
||||
};
|
||||
|
||||
|
||||
template<typename T, typename... Args>
|
||||
class MeshList : public Singleton<T>, public std::vector<STK::Tuple<Args...> >
|
||||
{};
|
||||
|
@ -80,7 +80,7 @@ void STKMeshSceneNode::setFirstTimeMaterial()
|
||||
if (!immediate_draw)
|
||||
{
|
||||
InitTextures(mesh, MatType);
|
||||
MeshSolidMaterials[MatType].push_back(&mesh);
|
||||
MeshSolidMaterial[MatType].push_back(&mesh);
|
||||
}
|
||||
}
|
||||
|
||||
@ -125,7 +125,7 @@ void STKMeshSceneNode::cleanGLMeshes()
|
||||
}
|
||||
GLmeshes.clear();
|
||||
for (unsigned i = 0; i < MAT_COUNT; i++)
|
||||
MeshSolidMaterials[i].clearWithoutDeleting();
|
||||
MeshSolidMaterial[i].clearWithoutDeleting();
|
||||
}
|
||||
|
||||
void STKMeshSceneNode::setMesh(irr::scene::IMesh* mesh)
|
||||
@ -241,29 +241,29 @@ void STKMeshSceneNode::render()
|
||||
AbsoluteTransformation.getInverse(invmodel);
|
||||
|
||||
GLMesh* mesh;
|
||||
for_in(mesh, MeshSolidMaterials[MAT_DEFAULT])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_DEFAULT])
|
||||
pushVector(ListMatDefault::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_ALPHA_REF])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_ALPHA_REF])
|
||||
pushVector(ListMatAlphaRef::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_SPHEREMAP])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_SPHEREMAP])
|
||||
pushVector(ListMatSphereMap::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_DETAIL])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_DETAIL])
|
||||
pushVector(ListMatDetails::getInstance(), mesh, AbsoluteTransformation, invmodel, mesh->TextureMatrix);
|
||||
|
||||
windDir = getWind();
|
||||
for_in(mesh, MeshSolidMaterials[MAT_GRASS])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_GRASS])
|
||||
pushVector(ListMatGrass::getInstance(), mesh, AbsoluteTransformation, invmodel, windDir);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_UNLIT])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_UNLIT])
|
||||
pushVector(ListMatUnlit::getInstance(), mesh, AbsoluteTransformation, core::matrix4::EM4CONST_IDENTITY, mesh->TextureMatrix);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_SPLATTING])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_SPLATTING])
|
||||
pushVector(ListMatSplatting::getInstance(), mesh, AbsoluteTransformation, invmodel);
|
||||
|
||||
for_in(mesh, MeshSolidMaterials[MAT_NORMAL_MAP])
|
||||
for_in(mesh, MeshSolidMaterial[MAT_NORMAL_MAP])
|
||||
pushVector(ListMatNormalMap::getInstance(), mesh, AbsoluteTransformation, invmodel, core::matrix4::EM4CONST_IDENTITY);
|
||||
|
||||
return;
|
||||
|
@ -4,11 +4,9 @@
|
||||
#include "stkmesh.hpp"
|
||||
#include "utils/ptr_vector.hpp"
|
||||
|
||||
class STKMeshSceneNode : public irr::scene::CMeshSceneNode
|
||||
class STKMeshSceneNode : public irr::scene::CMeshSceneNode, public STKMeshCommon
|
||||
{
|
||||
protected:
|
||||
PtrVector<GLMesh, REF> MeshSolidMaterials[MAT_COUNT];
|
||||
PtrVector<GLMesh, REF> TransparentMesh[TM_COUNT];
|
||||
std::vector<GLMesh> GLmeshes;
|
||||
core::matrix4 ModelViewProjectionMatrix;
|
||||
core::vector3df windDir;
|
||||
@ -25,6 +23,7 @@ protected:
|
||||
bool update_each_frame;
|
||||
bool isDisplacement;
|
||||
public:
|
||||
virtual void update();
|
||||
void setReloadEachFrame(bool);
|
||||
STKMeshSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
|
||||
@ -32,10 +31,10 @@ public:
|
||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f),
|
||||
bool createGLMeshes = true);
|
||||
virtual void render();
|
||||
void update();
|
||||
virtual void setMesh(irr::scene::IMesh* mesh);
|
||||
virtual void OnRegisterSceneNode();
|
||||
virtual ~STKMeshSceneNode();
|
||||
virtual bool isImmediateDraw() const { return immediate_draw; }
|
||||
void setIsDisplacement(bool v) {
|
||||
isDisplacement = v;
|
||||
for (u32 i = 0; i < Mesh->getMeshBufferCount(); ++i)
|
||||
|
Loading…
x
Reference in New Issue
Block a user