This commit is contained in:
vlj 2014-04-07 01:03:27 +02:00
commit 3c3b076458
4 changed files with 36 additions and 6 deletions

View File

@ -8,8 +8,11 @@ STKInstancedSceneNode::STKInstancedSceneNode(irr::scene::IMesh* mesh, ISceneNode
const irr::core::vector3df& scale) :
CMeshSceneNode(mesh, parent, mgr, id, position, rotation, scale)
{
createGLMeshes();
setAutomaticCulling(0);
if (irr_driver->isGLSL())
{
createGLMeshes();
setAutomaticCulling(0);
}
}
void STKInstancedSceneNode::cleanGL()
@ -39,7 +42,8 @@ void STKInstancedSceneNode::cleanGL()
STKInstancedSceneNode::~STKInstancedSceneNode()
{
cleanGL();
if (irr_driver->isGLSL())
cleanGL();
}
void STKInstancedSceneNode::createGLMeshes()
@ -306,6 +310,12 @@ static void drawSMGrass(GLMesh &mesh, const core::matrix4 &ModelViewProjectionMa
void STKInstancedSceneNode::render()
{
if (!irr_driver->isGLSL())
{
CMeshSceneNode::render();
return;
}
setFirstTimeMaterial();
if (irr_driver->getPhase() == SOLID_NORMAL_AND_DEPTH_PASS)

View File

@ -145,3 +145,10 @@ void ModelDefinitionLoader::clear()
{
m_lod_groups.clear();
}
// ----------------------------------------------------------------------------
scene::IMesh* ModelDefinitionLoader::getFirstMeshFor(const std::string& name)
{
return irr_driver->getMesh(m_lod_groups[name][0].m_model_file);
}

View File

@ -90,6 +90,8 @@ public:
void clear();
scene::IMesh* getFirstMeshFor(const std::string& name);
}; // ModelDefinitionLoader
#endif // HEADER_LOD_NODE_LOADER_HPP

View File

@ -26,6 +26,7 @@
#include "graphics/material_manager.hpp"
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/stkinstancedscenenode.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "input/device_manager.hpp"
@ -160,6 +161,8 @@ TrackObjectPresentationInstancing::TrackObjectPresentationInstancing(const XMLNo
scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader) : TrackObjectPresentationSceneNode(xml_node)
{
m_instancing_group = NULL;
std::string instancing_model;
xml_node.get("instancing_model", &instancing_model);
@ -168,9 +171,17 @@ TrackObjectPresentationInstancing::TrackObjectPresentationInstancing(const XMLNo
m_node->setRotation(m_init_hpr);
m_node->setScale(m_init_scale);
m_node->updateAbsolutePosition();
m_instancing_group = model_def_loader.instanciate(m_node->getAbsolutePosition(),
m_node->getAbsoluteTransformation().getRotationDegrees(), m_node->getAbsoluteTransformation().getScale(),
instancing_model);
if (irr_driver->isGLSL())
{
m_instancing_group = model_def_loader.instanciate(m_node->getAbsolutePosition(),
m_node->getAbsoluteTransformation().getRotationDegrees(), m_node->getAbsoluteTransformation().getScale(),
instancing_model);
}
else
{
m_instancing_group = new STKInstancedSceneNode(model_def_loader.getFirstMeshFor(instancing_model),
m_node, irr_driver->getSceneManager(), -1);
}
}
TrackObjectPresentationInstancing::~TrackObjectPresentationInstancing()