Remove vector int in RenderInfo
This commit is contained in:
parent
8408a7c158
commit
1d6c7fa60f
@ -29,16 +29,3 @@ RenderInfo::RenderInfo(float hue, bool transparent)
|
|||||||
m_hue = hue;
|
m_hue = hue;
|
||||||
m_transparent = transparent;
|
m_transparent = transparent;
|
||||||
} // RenderInfo
|
} // RenderInfo
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
void RenderInfo::setColorizableParts(irr::scene::IMesh* m)
|
|
||||||
{
|
|
||||||
for (int i = 0; i < int(m->getMeshBufferCount()); i++)
|
|
||||||
{
|
|
||||||
scene::IMeshBuffer* mb = m->getMeshBuffer(i);
|
|
||||||
Material* material = material_manager->getMaterialFor(mb
|
|
||||||
->getMaterial().getTexture(0), mb);
|
|
||||||
if (material->isColorizable())
|
|
||||||
m_colorizable_parts.push_back(i);
|
|
||||||
}
|
|
||||||
} // setColorizableParts
|
|
||||||
|
@ -21,9 +21,6 @@
|
|||||||
|
|
||||||
#include "utils/leak_check.hpp"
|
#include "utils/leak_check.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace irr
|
namespace irr
|
||||||
{
|
{
|
||||||
namespace scene { class IMesh; }
|
namespace scene { class IMesh; }
|
||||||
@ -48,8 +45,6 @@ private:
|
|||||||
|
|
||||||
bool m_transparent;
|
bool m_transparent;
|
||||||
|
|
||||||
std::vector<int> m_colorizable_parts;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LEAK_CHECK();
|
LEAK_CHECK();
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
@ -57,8 +52,6 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
~RenderInfo() {}
|
~RenderInfo() {}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setColorizableParts(irr::scene::IMesh* m);
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
void setHue(float hue) { m_hue = hue; }
|
void setHue(float hue) { m_hue = hue; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
void setTransparent(bool transparent) { m_transparent = transparent; }
|
void setTransparent(bool transparent) { m_transparent = transparent; }
|
||||||
@ -67,13 +60,6 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool isTransparent() const { return m_transparent; }
|
bool isTransparent() const { return m_transparent; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
bool isColorizable(int mesh_buffer_index) const
|
|
||||||
{
|
|
||||||
return m_colorizable_parts.empty() ||
|
|
||||||
std::find(m_colorizable_parts.begin(), m_colorizable_parts.end(),
|
|
||||||
mesh_buffer_index) != m_colorizable_parts.end();
|
|
||||||
}
|
|
||||||
// ------------------------------------------------------------------------
|
|
||||||
void setKartModelRenderInfo(KartRenderType krt)
|
void setKartModelRenderInfo(KartRenderType krt)
|
||||||
{
|
{
|
||||||
setHue(krt == RenderInfo::KRT_BLUE ? 0.66f :
|
setHue(krt == RenderInfo::KRT_BLUE ? 0.66f :
|
||||||
|
@ -107,7 +107,10 @@ void STKAnimatedMesh::updateNoGL()
|
|||||||
if (!m_all_parts_colorized && mb && m_mesh_render_info)
|
if (!m_all_parts_colorized && mb && m_mesh_render_info)
|
||||||
{
|
{
|
||||||
// Test if material is affected by hue change
|
// Test if material is affected by hue change
|
||||||
affected = m_mesh_render_info->isColorizable(i);
|
Material* m = material_manager->getMaterialFor(mb
|
||||||
|
->getMaterial().getTexture(0), mb);
|
||||||
|
if (m->isColorizable())
|
||||||
|
affected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name,
|
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name,
|
||||||
|
@ -84,7 +84,10 @@ void STKMeshSceneNode::createGLMeshes(RenderInfo* render_info, bool all_parts_co
|
|||||||
if (!all_parts_colorized && mb && render_info)
|
if (!all_parts_colorized && mb && render_info)
|
||||||
{
|
{
|
||||||
// Test if material is affected by hue change
|
// Test if material is affected by hue change
|
||||||
affected = render_info->isColorizable(i);
|
Material* m = material_manager->getMaterialFor(mb
|
||||||
|
->getMaterial().getTexture(0), mb);
|
||||||
|
if (m->isColorizable())
|
||||||
|
affected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name,
|
GLmeshes.push_back(allocateMeshBuffer(mb, m_debug_name,
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
GLuint getTextureGLuint(irr::video::ITexture *tex)
|
GLuint getTextureGLuint(irr::video::ITexture *tex)
|
||||||
{
|
{
|
||||||
|
assert(tex != NULL);
|
||||||
#if defined(USE_GLES2)
|
#if defined(USE_GLES2)
|
||||||
return static_cast<irr::video::COGLES2Texture*>(tex)->getOpenGLTextureName();
|
return static_cast<irr::video::COGLES2Texture*>(tex)->getOpenGLTextureName();
|
||||||
#else
|
#else
|
||||||
|
@ -27,6 +27,8 @@
|
|||||||
#include "graphics/central_settings.hpp"
|
#include "graphics/central_settings.hpp"
|
||||||
#include "graphics/irr_driver.hpp"
|
#include "graphics/irr_driver.hpp"
|
||||||
#include "graphics/lod_node.hpp"
|
#include "graphics/lod_node.hpp"
|
||||||
|
#include "graphics/material.hpp"
|
||||||
|
#include "graphics/material_manager.hpp"
|
||||||
#include "graphics/mesh_tools.hpp"
|
#include "graphics/mesh_tools.hpp"
|
||||||
#include "io/file_manager.hpp"
|
#include "io/file_manager.hpp"
|
||||||
#include "io/xml_node.hpp"
|
#include "io/xml_node.hpp"
|
||||||
@ -140,7 +142,7 @@ KartModel::KartModel(bool is_master)
|
|||||||
m_current_animation = AF_DEFAULT;
|
m_current_animation = AF_DEFAULT;
|
||||||
m_play_non_loop = false;
|
m_play_non_loop = false;
|
||||||
m_krt = RenderInfo::KRT_DEFAULT;
|
m_krt = RenderInfo::KRT_DEFAULT;
|
||||||
m_render_info = RenderInfo();
|
m_support_colorization = false;
|
||||||
} // KartModel
|
} // KartModel
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@ -298,7 +300,7 @@ KartModel* KartModel::makeCopy(RenderInfo::KartRenderType krt)
|
|||||||
km->m_kart_width = m_kart_width;
|
km->m_kart_width = m_kart_width;
|
||||||
km->m_kart_length = m_kart_length;
|
km->m_kart_length = m_kart_length;
|
||||||
km->m_kart_height = m_kart_height;
|
km->m_kart_height = m_kart_height;
|
||||||
km->m_kart_highest_point= m_kart_highest_point;
|
km->m_kart_highest_point = m_kart_highest_point;
|
||||||
km->m_kart_lowest_point = m_kart_lowest_point;
|
km->m_kart_lowest_point = m_kart_lowest_point;
|
||||||
km->m_mesh = irr_driver->copyAnimatedMesh(m_mesh);
|
km->m_mesh = irr_driver->copyAnimatedMesh(m_mesh);
|
||||||
km->m_model_filename = m_model_filename;
|
km->m_model_filename = m_model_filename;
|
||||||
@ -308,7 +310,7 @@ KartModel* KartModel::makeCopy(RenderInfo::KartRenderType krt)
|
|||||||
km->m_hat_offset = m_hat_offset;
|
km->m_hat_offset = m_hat_offset;
|
||||||
km->m_hat_name = m_hat_name;
|
km->m_hat_name = m_hat_name;
|
||||||
km->m_krt = krt;
|
km->m_krt = krt;
|
||||||
km->m_render_info = m_render_info;
|
km->m_support_colorization = m_support_colorization;
|
||||||
|
|
||||||
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
km->m_nitro_emitter_position[0] = m_nitro_emitter_position[0];
|
||||||
km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1];
|
km->m_nitro_emitter_position[1] = m_nitro_emitter_position[1];
|
||||||
@ -520,8 +522,15 @@ bool KartModel::loadModels(const KartProperties &kart_properties)
|
|||||||
MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]),
|
MeshTools::minMax3D(m_mesh->getMesh(m_animation_frame[AF_STRAIGHT]),
|
||||||
&kart_min, &kart_max);
|
&kart_min, &kart_max);
|
||||||
|
|
||||||
// Enable colorization for karts later when attachModel
|
// Test if kart model support colorization
|
||||||
m_render_info.setColorizableParts(m_mesh);
|
for (int i = 0; i < int(m_mesh->getMeshBufferCount()); i++)
|
||||||
|
{
|
||||||
|
scene::IMeshBuffer* mb = m_mesh->getMeshBuffer(i);
|
||||||
|
Material* material = material_manager->getMaterialFor(mb
|
||||||
|
->getMaterial().getTexture(0), mb);
|
||||||
|
m_support_colorization =
|
||||||
|
m_support_colorization || material->isColorizable();
|
||||||
|
}
|
||||||
|
|
||||||
#undef MOVE_KART_MESHES
|
#undef MOVE_KART_MESHES
|
||||||
#ifdef MOVE_KART_MESHES
|
#ifdef MOVE_KART_MESHES
|
||||||
|
@ -235,6 +235,8 @@ private:
|
|||||||
|
|
||||||
RenderInfo m_render_info;
|
RenderInfo m_render_info;
|
||||||
|
|
||||||
|
bool m_support_colorization;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
KartModel(bool is_master);
|
KartModel(bool is_master);
|
||||||
~KartModel();
|
~KartModel();
|
||||||
@ -335,9 +337,19 @@ public:
|
|||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
core::vector3df getHatOffset() { return m_hat_offset; }
|
core::vector3df getHatOffset() { return m_hat_offset; }
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
RenderInfo* getRenderInfo() { return &m_render_info; }
|
RenderInfo* getRenderInfo()
|
||||||
|
{
|
||||||
|
return m_support_colorization || m_krt == RenderInfo::KRT_TRANSPARENT ?
|
||||||
|
&m_render_info : NULL;
|
||||||
|
}
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
const RenderInfo* getRenderInfo() const { return &m_render_info; }
|
const RenderInfo* getRenderInfo() const
|
||||||
|
{
|
||||||
|
return m_support_colorization || m_krt == RenderInfo::KRT_TRANSPARENT ?
|
||||||
|
&m_render_info : NULL;
|
||||||
|
}
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
bool supportColorization() const { return m_support_colorization; }
|
||||||
|
|
||||||
}; // KartModel
|
}; // KartModel
|
||||||
#endif
|
#endif
|
||||||
|
@ -305,9 +305,6 @@ void SoccerWorld::countdownReachedZero()
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
void SoccerWorld::initKartList()
|
void SoccerWorld::initKartList()
|
||||||
{
|
{
|
||||||
// Color of karts can be changed using shaders
|
|
||||||
if (CVS->isGLSL()) return;
|
|
||||||
|
|
||||||
const unsigned int kart_amount = (unsigned int)m_karts.size();
|
const unsigned int kart_amount = (unsigned int)m_karts.size();
|
||||||
|
|
||||||
//Loading the indicator textures
|
//Loading the indicator textures
|
||||||
@ -317,10 +314,15 @@ void SoccerWorld::initKartList()
|
|||||||
irr_driver->getTexture(FileManager::GUI, "soccer_player_blue.png");
|
irr_driver->getTexture(FileManager::GUI, "soccer_player_blue.png");
|
||||||
|
|
||||||
//Assigning indicators
|
//Assigning indicators
|
||||||
for(unsigned int i=0; i<kart_amount; i++)
|
for(unsigned int i = 0; i < kart_amount; i++)
|
||||||
{
|
{
|
||||||
scene::ISceneNode *arrow_node;
|
scene::ISceneNode *arrow_node = NULL;
|
||||||
float arrow_pos_height = m_karts[i]->getKartModel()->getHeight()+0.5f;
|
|
||||||
|
KartModel* km = m_karts[i]->getKartModel();
|
||||||
|
// Color of karts can be changed using shaders if the model supports
|
||||||
|
if (km->supportColorization() && CVS->isGLSL()) continue;
|
||||||
|
|
||||||
|
float arrow_pos_height = km->getHeight() + 0.5f;
|
||||||
SoccerTeam team = getKartTeam(i);
|
SoccerTeam team = getKartTeam(i);
|
||||||
|
|
||||||
arrow_node = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3f,
|
arrow_node = irr_driver->addBillboard(core::dimension2d<irr::f32>(0.3f,
|
||||||
|
@ -146,12 +146,13 @@ void SoccerSetupScreen::beforeAddingWidget()
|
|||||||
(i&1 ? SOCCER_TEAM_BLUE : SOCCER_TEAM_RED));
|
(i&1 ? SOCCER_TEAM_BLUE : SOCCER_TEAM_RED));
|
||||||
|
|
||||||
// addModel requires loading the RenderInfo first
|
// addModel requires loading the RenderInfo first
|
||||||
kart_view->getModelViewRenderInfo().setRenderInfo
|
info.support_colorization = kart_model.supportColorization();
|
||||||
(kart_model.getRenderInfo());
|
if (info.support_colorization)
|
||||||
|
{
|
||||||
kart_view->getModelViewRenderInfo().setKartModelRenderInfo
|
kart_view->getModelViewRenderInfo().setKartModelRenderInfo
|
||||||
(info.team == SOCCER_TEAM_BLUE ?
|
(info.team == SOCCER_TEAM_BLUE ?
|
||||||
RenderInfo::KRT_BLUE : RenderInfo::KRT_RED);
|
RenderInfo::KRT_BLUE : RenderInfo::KRT_RED);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the kart model (including wheels and speed weight objects)
|
// Add the kart model (including wheels and speed weight objects)
|
||||||
kart_view->addModel( kart_model.getModel(), Vec3(0,0,0),
|
kart_view->addModel( kart_model.getModel(), Vec3(0,0,0),
|
||||||
@ -291,8 +292,11 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
|||||||
team_switch = SOCCER_TEAM_RED;
|
team_switch = SOCCER_TEAM_RED;
|
||||||
|
|
||||||
// Change the kart color
|
// Change the kart color
|
||||||
|
if (m_kart_view_info[playerId].support_colorization)
|
||||||
|
{
|
||||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||||
.setKartModelRenderInfo(RenderInfo::KRT_RED);
|
.setKartModelRenderInfo(RenderInfo::KRT_RED);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0 ; i < nb_players ; i++)
|
for(int i=0 ; i < nb_players ; i++)
|
||||||
{
|
{
|
||||||
@ -308,8 +312,11 @@ GUIEngine::EventPropagation SoccerSetupScreen::filterActions(PlayerAction action
|
|||||||
team_switch = SOCCER_TEAM_BLUE;
|
team_switch = SOCCER_TEAM_BLUE;
|
||||||
|
|
||||||
// Change the kart color
|
// Change the kart color
|
||||||
|
if (m_kart_view_info[playerId].support_colorization)
|
||||||
|
{
|
||||||
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
m_kart_view_info[playerId].view->getModelViewRenderInfo()
|
||||||
.setKartModelRenderInfo(RenderInfo::KRT_BLUE);
|
.setKartModelRenderInfo(RenderInfo::KRT_BLUE);
|
||||||
|
}
|
||||||
|
|
||||||
for(int i=0 ; i < nb_players ; i++)
|
for(int i=0 ; i < nb_players ; i++)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,8 @@ namespace GUIEngine { class Widget; class LabelWidget; class ModelViewWidget; }
|
|||||||
* \brief Screen with soccer setup options
|
* \brief Screen with soccer setup options
|
||||||
* \ingroup states_screens
|
* \ingroup states_screens
|
||||||
*/
|
*/
|
||||||
class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSingleton<SoccerSetupScreen>
|
class SoccerSetupScreen : public GUIEngine::Screen,
|
||||||
|
public GUIEngine::ScreenSingleton<SoccerSetupScreen>
|
||||||
{
|
{
|
||||||
friend class GUIEngine::ScreenSingleton<SoccerSetupScreen>;
|
friend class GUIEngine::ScreenSingleton<SoccerSetupScreen>;
|
||||||
|
|
||||||
@ -38,10 +39,12 @@ class SoccerSetupScreen : public GUIEngine::Screen, public GUIEngine::ScreenSing
|
|||||||
{
|
{
|
||||||
GUIEngine::ModelViewWidget* view;
|
GUIEngine::ModelViewWidget* view;
|
||||||
bool confirmed;
|
bool confirmed;
|
||||||
|
bool support_colorization;
|
||||||
SoccerTeam team;
|
SoccerTeam team;
|
||||||
RenderInfo render_info;
|
RenderInfo render_info;
|
||||||
|
|
||||||
KartViewInfo() : view(), confirmed(false), team(SOCCER_TEAM_NONE) {}
|
KartViewInfo() : view(), confirmed(false), support_colorization(false),
|
||||||
|
team(SOCCER_TEAM_NONE) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
AlignedArray<KartViewInfo> m_kart_view_info;
|
AlignedArray<KartViewInfo> m_kart_view_info;
|
||||||
|
Loading…
Reference in New Issue
Block a user