First try to support colorization texture mask

This commit is contained in:
Benau 2016-07-15 00:53:22 +08:00
parent 1463cf9344
commit 53374176ad
20 changed files with 122 additions and 65 deletions

View File

@ -1,6 +1,7 @@
#ifndef Use_Bindless_Texture
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
#ifdef Use_Bindless_Texture
@ -31,13 +32,15 @@ void main(void)
vec4 col = texture(Albedo, uv);
float specmap = texture(SpecMap, uv).g;
float emitmap = texture(SpecMap, uv).b;
float mask = texture(colorization_mask, uv).a;
#endif
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(col.rgb);
old_hsv.y = max(old_hsv.y, color_change.y);
vec3 new_color = hsvToRgb(vec3(color_change.x, old_hsv.y, old_hsv.z));
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
}

View File

@ -4,6 +4,7 @@ layout(bindless_sampler) uniform sampler2D SpecMap;
#else
uniform sampler2D Albedo;
uniform sampler2D SpecMap;
uniform sampler2D colorization_mask;
#endif
uniform vec2 color_change;
@ -25,13 +26,15 @@ void main(void)
#endif
#else
vec4 col = texture(Albedo, uv);
float mask = texture(colorization_mask, uv).a;
#endif
if (color_change.x > 0.0)
{
vec3 old_hsv = rgbToHsv(col.rgb);
old_hsv.y = max(old_hsv.y, color_change.y);
vec3 new_color = hsvToRgb(vec3(color_change.x, old_hsv.y, old_hsv.z));
float mask_step = step(mask, 0.5);
vec2 new_xy = mix(vec2(old_hsv.x, old_hsv.y), vec2(color_change.x, max(old_hsv.y, color_change.y)), vec2(mask_step, mask_step));
vec3 new_color = hsvToRgb(vec3(new_xy.x, new_xy.y, old_hsv.z));
col = vec4(new_color.r, new_color.g, new_color.b, col.a);
}

View File

@ -145,6 +145,7 @@ Material::Material(const XMLNode *node, bool deprecated)
node->get("fog", &m_fog );
node->get("mask", &m_mask );
node->get("colorization-mask", &m_colorization_mask );
node->get("gloss-map", &m_gloss_map );
node->get("water-splash", &m_water_splash );
node->get("jump", &m_is_jump_texture );
@ -438,6 +439,7 @@ void Material::init()
m_disable_z_write = false;
m_colorizable = false;
m_colorization_factor = 0.0f;
m_colorization_mask = "";
m_water_shader_speed_1 = 6.6667f;
m_water_shader_speed_2 = 4.0f;
m_fog = true;
@ -724,6 +726,18 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
{
glossytex = getUnicolorTexture(SColor(0, 0, 0, 0));
}
if (!m->getTexture(7))
{
// Only set colorization mask if not set
ITexture *colorization_mask_tex = getUnicolorTexture(SColor(0, 0, 0, 0));
if (m_colorization_mask.size() > 0)
{
colorization_mask_tex = irr_driver->getTexture(m_colorization_mask);
}
m->setTexture(7, colorization_mask_tex);
}
switch (m_shader_type)
{
case SHADERTYPE_SOLID_UNLIT:
@ -974,7 +988,7 @@ void Material::setMaterialProperties(video::SMaterial *m, scene::IMeshBuffer* m
if (race_manager->getReverseTrack() &&
m_mirror_axis_when_reverse != ' ')
{
irr::video::S3DVertex* mbVertices = (video::S3DVertex*)mb->getVertices();
//irr::video::S3DVertex* mbVertices = (video::S3DVertex*)mb->getVertices();
for (unsigned int i = 0; i < mb->getVertexCount(); i++)
{
core::vector2df &tc = mb->getTCoords(i);

View File

@ -233,6 +233,8 @@ private:
std::string m_mask;
std::string m_colorization_mask;
/** If m_splatting is true, indicates the first splatting texture */
std::string m_splatting_texture_1;

View File

@ -132,7 +132,7 @@ public:
}; // ObjectRefPass2Shader
// ============================================================================
class InstancedObjectPass2Shader : public TextureShader<InstancedObjectPass2Shader, 5>
class InstancedObjectPass2Shader : public TextureShader<InstancedObjectPass2Shader, 6>
{
private:
GLint m_color_change_location;
@ -151,7 +151,8 @@ public:
1, "SpecularMap", ST_NEAREST_FILTERED,
2, "SSAO", ST_BILINEAR_FILTERED,
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
5, "colorization_mask", ST_TRILINEAR_ANISOTROPIC_FILTERED);
} // InstancedObjectPass2Shader
virtual bool changeableColor(float hue = 0.0f, float min_sat = 0.0f) const OVERRIDE
@ -542,15 +543,15 @@ struct DefaultMaterial
= Material::SHADERTYPE_SOLID;
static const enum InstanceType Instance = InstanceTypeDualTex;
static const STK::Tuple<size_t> FirstPassTextures;
static const STK::Tuple<size_t, size_t> SecondPassTextures;
static const STK::Tuple<size_t, size_t, size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; // struct DefaultMaterial
const STK::Tuple<size_t> DefaultMaterial::FirstPassTextures
= STK::Tuple<size_t>(1);
const STK::Tuple<size_t, size_t> DefaultMaterial::SecondPassTextures
= STK::Tuple<size_t, size_t>(0, 1);
const STK::Tuple<size_t, size_t, size_t> DefaultMaterial::SecondPassTextures
= STK::Tuple<size_t, size_t, size_t>(0, 1, 7);
const STK::Tuple<> DefaultMaterial::ShadowTextures;
const STK::Tuple<size_t> DefaultMaterial::RSMTextures = STK::Tuple<size_t>(0);
@ -866,7 +867,7 @@ struct NormalMat
= Material::SHADERTYPE_NORMAL_MAP;
static const enum InstanceType Instance = InstanceTypeThreeTex;
static const STK::Tuple<size_t, size_t> FirstPassTextures;
static const STK::Tuple<size_t, size_t> SecondPassTextures;
static const STK::Tuple<size_t, size_t, size_t> SecondPassTextures;
static const STK::Tuple<> ShadowTextures;
static const STK::Tuple<size_t> RSMTextures;
}; // NormalMat
@ -874,8 +875,8 @@ struct NormalMat
// ----------------------------------------------------------------------------
const STK::Tuple<size_t, size_t> NormalMat::FirstPassTextures
= STK::Tuple<size_t, size_t>(2, 1);
const STK::Tuple<size_t, size_t> NormalMat::SecondPassTextures
= STK::Tuple<size_t, size_t>(0, 1);
const STK::Tuple<size_t, size_t, size_t> NormalMat::SecondPassTextures
= STK::Tuple<size_t, size_t, size_t>(0, 1, 7);
const STK::Tuple<> NormalMat::ShadowTextures;
const STK::Tuple<size_t> NormalMat::RSMTextures = STK::Tuple<size_t>(0);

View File

@ -19,6 +19,8 @@
#ifndef HEADER_RENDER_INFO_HPP
#define HEADER_RENDER_INFO_HPP
#include "utils/leak_check.hpp"
#include <algorithm>
#include <vector>
@ -49,6 +51,8 @@ private:
std::vector<int> m_colorizable_parts;
public:
LEAK_CHECK();
// ------------------------------------------------------------------------
RenderInfo(float hue = 0.0f, bool transparent = false);
// ------------------------------------------------------------------------
~RenderInfo() {}

View File

@ -348,7 +348,8 @@ Shaders::ObjectPass2Shader::ObjectPass2Shader()
1, "SpecularMap", ST_NEAREST_FILTERED,
2, "SSAO", ST_BILINEAR_FILTERED,
3, "Albedo", ST_TRILINEAR_ANISOTROPIC_FILTERED,
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED);
4, "SpecMap", ST_TRILINEAR_ANISOTROPIC_FILTERED,
5, "colorization_mask", ST_TRILINEAR_ANISOTROPIC_FILTERED);
} // ObjectPass2Shader
// ============================================================================

View File

@ -143,7 +143,7 @@ public:
}; // ObjectPass1Shader
// ========================================================================
class ObjectPass2Shader : public TextureShader < ObjectPass2Shader, 5,
class ObjectPass2Shader : public TextureShader < ObjectPass2Shader, 6,
core::matrix4, core::matrix4 >
{
private:

View File

@ -142,13 +142,6 @@ void STKAnimatedMesh::updateNoGL()
{
TransparentMesh[TM_ADDITIVE].push_back(&mesh);
}
else if (mesh.m_render_info != NULL)
{
// For now, put all meshes that support custom render info into
// solid (default) material first, this allowing changing fewer
// shaders
MeshSolidMaterial[Material::SHADERTYPE_SOLID].push_back(&mesh);
}
else
{
Material::ShaderType MatType = material->getShaderType();// getMeshMaterialFromType(type, mb->getVertexType(), material);

View File

@ -197,14 +197,6 @@ void STKMeshSceneNode::updateNoGL()
else
additive = (TranspMat == TM_ADDITIVE);
}
else if (mesh.m_render_info != NULL)
{
// For now, put all meshes that support custom render info into
// solid (default) material first, this allowing changing fewer
// shaders
if (!immediate_draw)
MeshSolidMaterial[Material::SHADERTYPE_SOLID].push_back(&mesh);
}
else
{
assert(!isDisplacement);
@ -397,15 +389,25 @@ void STKMeshSceneNode::render()
Shaders::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[0]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[0]);
if (!mesh.TextureHandles[1])
mesh.TextureHandles[1] =
glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[1]),
Shaders::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[1]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[1]);
if (!mesh.TextureHandles[2])
mesh.TextureHandles[2] =
glGetTextureSamplerHandleARB(getTextureGLuint(mesh.textures[7]),
Shaders::ObjectPass2Shader::getInstance()->m_sampler_ids[0]);
if (!glIsTextureHandleResidentARB(mesh.TextureHandles[2]))
glMakeTextureHandleResidentARB(mesh.TextureHandles[2]);
Shaders::ObjectPass2Shader::getInstance()
->setTextureHandles(DiffuseHandle, SpecularHandle, SSAOHandle,
mesh.TextureHandles[0], mesh.TextureHandles[1]);
mesh.TextureHandles[0], mesh.TextureHandles[1],
mesh.TextureHandles[2]);
}
else
Shaders::ObjectPass2Shader::getInstance()->setTextureUnits(
@ -413,7 +415,8 @@ void STKMeshSceneNode::render()
irr_driver->getRenderTargetTexture(RTT_SPECULAR),
irr_driver->getRenderTargetTexture(RTT_HALF1_R),
getTextureGLuint(mesh.textures[0]),
getTextureGLuint(mesh.textures[1]));
getTextureGLuint(mesh.textures[1]),
getTextureGLuint(mesh.textures[7]));
Shaders::ObjectPass2Shader::getInstance()->setUniforms(AbsoluteTransformation,
mesh.TextureMatrix);
assert(mesh.vao);

View File

@ -56,7 +56,7 @@ void ModelDefinitionLoader::addModelDefinition(const XMLNode* xml)
// ----------------------------------------------------------------------------
LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISceneNode* parent)
LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISceneNode* parent, RenderInfo* ri)
{
scene::ISceneManager* sm = irr_driver->getSceneManager();
@ -88,7 +88,8 @@ LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISc
//cache.push_back(a_mesh);
irr_driver->grabAllTextures(a_mesh);
m_track->addCachedMesh(a_mesh);
scene::IAnimatedMeshSceneNode* scene_node = irr_driver->addAnimatedMesh(a_mesh, group[m].m_model_file);
scene::IAnimatedMeshSceneNode* scene_node = irr_driver
->addAnimatedMesh(a_mesh, group[m].m_model_file, NULL, ri);
m_track->handleAnimatedTextures(scene_node, *group[m].m_xml);
@ -111,7 +112,8 @@ LODNode* ModelDefinitionLoader::instanciateAsLOD(const XMLNode* node, scene::ISc
//cache.push_back(a_mesh);
irr_driver->grabAllTextures(a_mesh);
m_track->addCachedMesh(a_mesh);
scene::IMeshSceneNode* scene_node = irr_driver->addMesh(a_mesh, group[m].m_model_file);
scene::IMeshSceneNode* scene_node = irr_driver
->addMesh(a_mesh, group[m].m_model_file, NULL, ri);
m_track->handleAnimatedTextures(scene_node, *group[m].m_xml);

View File

@ -20,8 +20,9 @@
#define HEADER_LOD_NODE_LOADER_HPP
class LODNode;
class Track;
class STKInstancedSceneNode;
class RenderInfo;
class Track;
#include <cassert>
#include <map>
@ -88,7 +89,9 @@ public:
ModelDefinitionLoader(Track* track);
void addModelDefinition(const XMLNode* xml);
LODNode* instanciateAsLOD(const XMLNode* xml_node, scene::ISceneNode* parent);
LODNode* instanciateAsLOD(const XMLNode* xml_node,
scene::ISceneNode* parent,
RenderInfo* ri);
void clear();

View File

@ -39,6 +39,7 @@
#include "graphics/particle_kind.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/stk_text_billboard.hpp"
#include "graphics/render_info.hpp"
#include "guiengine/scalable_font.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
@ -1220,7 +1221,7 @@ bool Track::loadMainTrack(const XMLNode &root)
if (lod_instance)
{
LODNode* node = lodLoader.instanciateAsLOD(n, NULL);
LODNode* node = lodLoader.instanciateAsLOD(n, NULL, NULL);
if (node != NULL)
{
node->setPosition(xyz);
@ -1737,7 +1738,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
}
}
loadObjects(root, path, model_def_loader, true, NULL, NULL);
loadObjects(root, path, model_def_loader, true, NULL, NULL, NULL);
model_def_loader.cleanLibraryNodesAfterLoad();
@ -1927,7 +1928,7 @@ void Track::loadTrackModel(bool reverse_track, unsigned int mode_id)
void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefinitionLoader& model_def_loader,
bool create_lod_definitions, scene::ISceneNode* parent,
TrackObject* parent_library)
TrackObject* parent_library, RenderInfo* ri)
{
unsigned int start_position_counter = 0;
@ -1941,7 +1942,7 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefin
if (name == "track" || name == "default-start") continue;
if (name == "object" || name == "library")
{
m_track_object_manager->add(*node, parent, model_def_loader, parent_library);
m_track_object_manager->add(*node, parent, model_def_loader, parent_library, ri);
}
else if (name == "water")
{
@ -1985,7 +1986,7 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefin
{
if (UserConfigParams::m_graphical_effects)
{
m_track_object_manager->add(*node, parent, model_def_loader, parent_library);
m_track_object_manager->add(*node, parent, model_def_loader, parent_library, NULL);
}
}
else if (name == "sky-dome" || name == "sky-box" || name == "sky-color")
@ -1998,7 +1999,7 @@ void Track::loadObjects(const XMLNode* root, const std::string& path, ModelDefin
}
else if (name == "light")
{
m_track_object_manager->add(*node, parent, model_def_loader, parent_library);
m_track_object_manager->add(*node, parent, model_def_loader, parent_library, NULL);
}
else if (name == "weather")
{

View File

@ -57,6 +57,7 @@ class MusicInformation;
class ParticleEmitter;
class ParticleKind;
class PhysicalObject;
class RenderInfo;
class TrackObject;
class TrackObjectManager;
class TriangleMesh;
@ -457,7 +458,8 @@ public:
// ------------------------------------------------------------------------
void loadObjects(const XMLNode* root, const std::string& path,
ModelDefinitionLoader& lod_loader, bool create_lod_definitions,
scene::ISceneNode* parent, TrackObject* parent_library);
scene::ISceneNode* parent, TrackObject* parent_library,
RenderInfo* ri);
// ------------------------------------------------------------------------
bool isSoccer () const { return m_is_soccer; }
// ------------------------------------------------------------------------

View File

@ -20,6 +20,7 @@
#include "animations/three_d_animation.hpp"
#include "graphics/irr_driver.hpp"
#include "graphics/render_info.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "input/device_manager.hpp"
@ -42,9 +43,9 @@
*/
TrackObject::TrackObject(const XMLNode &xml_node, scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader,
TrackObject* parent_library)
TrackObject* parent_library, RenderInfo* ri)
{
init(xml_node, parent, model_def_loader, parent_library);
init(xml_node, parent, model_def_loader, parent_library, ri);
} // TrackObject
// ----------------------------------------------------------------------------
@ -93,7 +94,7 @@ TrackObject::TrackObject(const core::vector3df& xyz, const core::vector3df& hpr,
*/
void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader,
TrackObject* parent_library)
TrackObject* parent_library, RenderInfo* ri)
{
m_init_xyz = core::vector3df(0,0,0);
m_init_hpr = core::vector3df(0,0,0);
@ -183,7 +184,7 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
{
m_type = "lod";
TrackObjectPresentationLOD* lod_node =
new TrackObjectPresentationLOD(xml_node, parent, model_def_loader);
new TrackObjectPresentationLOD(xml_node, parent, model_def_loader, ri);
m_presentation = lod_node;
LODNode* node = (LODNode*)lod_node->getNode();
@ -207,7 +208,8 @@ void TrackObject::init(const XMLNode &xml_node, scene::ISceneNode* parent,
m_type = "mesh";
m_presentation = new TrackObjectPresentationMesh(xml_node,
m_enabled,
parent);
parent,
ri);
scene::ISceneNode* node = ((TrackObjectPresentationMesh *)m_presentation)->getNode();
if (type == "movable" && parent != NULL)
{

View File

@ -34,6 +34,7 @@
class XMLNode;
class ThreeDAnimation;
class ModelDefinitionLoader;
class RenderInfo;
/**
* \ingroup tracks
@ -98,13 +99,14 @@ protected:
void init(const XMLNode &xml_node, scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader,
TrackObject* parent_library);
TrackObject* parent_library, RenderInfo* ri);
public:
TrackObject(const XMLNode &xml_node,
scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader,
TrackObject* parent_library);
TrackObject* parent_library,
RenderInfo* ri);
TrackObject(const core::vector3df& xyz,
const core::vector3df& hpr,

View File

@ -22,6 +22,7 @@
#include "animations/three_d_animation.hpp"
#include "graphics/lod_node.hpp"
#include "graphics/material_manager.hpp"
#include "graphics/render_info.hpp"
#include "io/xml_node.hpp"
#include "physics/physical_object.hpp"
#include "tracks/track_object.hpp"
@ -45,11 +46,11 @@ TrackObjectManager::~TrackObjectManager()
*/
void TrackObjectManager::add(const XMLNode &xml_node, scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader,
TrackObject* parent_library)
TrackObject* parent_library, RenderInfo* ri)
{
try
{
TrackObject *obj = new TrackObject(xml_node, parent, model_def_loader, parent_library);
TrackObject *obj = new TrackObject(xml_node, parent, model_def_loader, parent_library, ri);
m_all_objects.push_back(obj);
if(obj->isDriveable())
m_driveable_objects.push_back(obj);

View File

@ -23,10 +23,11 @@
#include "tracks/track_object.hpp"
#include "utils/ptr_vector.hpp"
class LODNode;
class RenderInfo;
class Track;
class Vec3;
class XMLNode;
class LODNode;
#include <map>
#include <vector>
@ -58,7 +59,7 @@ public:
void init();
void add(const XMLNode &xml_node, scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader,
TrackObject* parent_library);
TrackObject* parent_library, RenderInfo* ri);
void update(float dt);
void handleExplosion(const Vec3 &pos, const PhysicalObject *mp,
bool secondary_hits=true);

View File

@ -31,6 +31,7 @@
#include "graphics/particle_emitter.hpp"
#include "graphics/particle_kind_manager.hpp"
#include "graphics/stk_mesh_scene_node.hpp"
#include "graphics/render_info.hpp"
#include "io/file_manager.hpp"
#include "io/xml_node.hpp"
#include "input/device_manager.hpp"
@ -176,8 +177,13 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
ModelDefinitionLoader& model_def_loader)
: TrackObjectPresentationSceneNode(xml_node)
{
m_render_info = NULL;
std::string name;
xml_node.get("name", &name);
float custom_hue = 0.0f;
xml_node.get("hue", &custom_hue);
if (custom_hue > 0.0f)
m_render_info = new RenderInfo(custom_hue, false);
m_node = irr_driver->getSceneManager()->addEmptySceneNode();
#ifdef DEBUG
@ -267,7 +273,7 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
assert(libroot != NULL);
World::getWorld()->getTrack()->loadObjects(libroot, lib_path, model_def_loader,
create_lod_definitions, m_node, parent);
create_lod_definitions, m_node, parent, m_render_info);
m_parent = parent;
} // TrackObjectPresentationLibraryNode
@ -275,6 +281,8 @@ TrackObjectPresentationLibraryNode::TrackObjectPresentationLibraryNode(
TrackObjectPresentationLibraryNode::~TrackObjectPresentationLibraryNode()
{
irr_driver->removeNode(m_node);
delete m_render_info;
m_render_info = NULL;
} // TrackObjectPresentationLibraryNode
// ----------------------------------------------------------------------------
void TrackObjectPresentationLibraryNode::move(const core::vector3df& xyz, const core::vector3df& hpr,
@ -297,10 +305,11 @@ void TrackObjectPresentationLibraryNode::move(const core::vector3df& xyz, const
// ----------------------------------------------------------------------------
TrackObjectPresentationLOD::TrackObjectPresentationLOD(const XMLNode& xml_node,
scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader)
ModelDefinitionLoader& model_def_loader,
RenderInfo* ri)
: TrackObjectPresentationSceneNode(xml_node)
{
m_node = model_def_loader.instanciateAsLOD(&xml_node, parent);
m_node = model_def_loader.instanciateAsLOD(&xml_node, parent, ri);
if (m_node == NULL) throw std::runtime_error("Cannot load LOD node");
m_node->setPosition(m_init_xyz);
m_node->setRotation(m_init_hpr);
@ -318,7 +327,8 @@ TrackObjectPresentationLOD::~TrackObjectPresentationLOD()
TrackObjectPresentationMesh::TrackObjectPresentationMesh(
const XMLNode& xml_node,
bool enabled,
scene::ISceneNode* parent)
scene::ISceneNode* parent,
RenderInfo* render_info)
: TrackObjectPresentationSceneNode(xml_node)
{
m_is_looped = false;
@ -329,6 +339,7 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
std::string model_name;
xml_node.get("model", &model_name );
m_render_info = render_info;
m_model_file = model_name;
m_is_in_skybox = false;
std::string render_pass;
@ -380,6 +391,7 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
m_mesh = NULL;
m_node = NULL;
m_mesh = model;
m_render_info = NULL;
init(NULL, NULL, true);
} // TrackObjectPresentationMesh
@ -395,6 +407,7 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
m_mesh = NULL;
m_node = NULL;
m_is_in_skybox = false;
m_render_info = NULL;
bool animated = (UserConfigParams::m_graphical_effects ||
World::getWorld()->getIdent() == IDENT_CUTSCENE);
@ -447,7 +460,7 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
{
// Animated
//m_node = irr_driver->getSceneManager()->addEmptySceneNode();
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent);
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent, m_render_info);
enabled = false;
m_force_always_hidden = true;
m_frame_start = 0;
@ -456,7 +469,7 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
else
{
// Static
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent);
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent, m_render_info);
enabled = false;
m_force_always_hidden = true;
m_frame_start = 0;
@ -482,7 +495,7 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
{
scene::IAnimatedMeshSceneNode *node =
irr_driver->addAnimatedMesh((scene::IAnimatedMesh*)m_mesh,
m_model_file, parent);
m_model_file, parent, m_render_info);
m_node = node;
m_frame_start = node->getStartFrame();
@ -503,7 +516,7 @@ void TrackObjectPresentationMesh::init(const XMLNode* xml_node,
if (xml_node)
xml_node->get("displacing", &displacing);
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent);
m_node = irr_driver->addMesh(m_mesh, m_model_file, parent, m_render_info);
STKMeshSceneNode* stkmesh = dynamic_cast<STKMeshSceneNode*>(m_node);
if (displacing && stkmesh != NULL)

View File

@ -37,6 +37,7 @@ class ParticleEmitter;
class PhysicalObject;
class ThreeDAnimation;
class ModelDefinitionLoader;
class RenderInfo;
class STKInstancedSceneNode;
class XMLNode;
class TrackObject;
@ -184,6 +185,7 @@ public:
class TrackObjectPresentationLibraryNode : public TrackObjectPresentationSceneNode
{
TrackObject* m_parent;
RenderInfo* m_render_info;
public:
TrackObjectPresentationLibraryNode(TrackObject* parent,
const XMLNode& xml_node,
@ -203,7 +205,8 @@ public:
TrackObjectPresentationLOD(const XMLNode& xml_node,
scene::ISceneNode* parent,
ModelDefinitionLoader& model_def_loader);
ModelDefinitionLoader& model_def_loader,
RenderInfo* ri);
virtual ~TrackObjectPresentationLOD();
};
@ -232,11 +235,14 @@ private:
std::string m_model_file;
RenderInfo* m_render_info;
void init(const XMLNode* xml_node, scene::ISceneNode* parent, bool enabled);
public:
TrackObjectPresentationMesh(const XMLNode& xml_node, bool enabled,
scene::ISceneNode* parent);
scene::ISceneNode* parent,
RenderInfo* render_info);
TrackObjectPresentationMesh(const std::string& model_file,
const core::vector3df& xyz,