diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 578e2ea7e..5c909a3b7 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -1013,7 +1013,8 @@ scene::IMesh *IrrDriver::getMesh(const std::string &filename) * \return Newly created skinned mesh. You should call drop() when you don't * need it anymore. */ -scene::IAnimatedMesh *IrrDriver::copyAnimatedMesh(scene::IAnimatedMesh *orig) +scene::IAnimatedMesh *IrrDriver::copyAnimatedMesh(scene::IAnimatedMesh *orig, + video::E_CUSTOM_MATERIAL_TYPE cmt) { using namespace scene; CSkinnedMesh *mesh = dynamic_cast(orig); @@ -1022,7 +1023,10 @@ scene::IAnimatedMesh *IrrDriver::copyAnimatedMesh(scene::IAnimatedMesh *orig) Log::error("copyAnimatedMesh", "Given mesh was not a skinned mesh."); return NULL; } - return mesh->clone(); + + scene::IAnimatedMesh* out = mesh->clone(); + out->setCustomMaterialType(cmt); + return out; } // copyAnimatedMesh // ---------------------------------------------------------------------------- diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index 707aba625..339e163f6 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -353,7 +353,8 @@ public: void setAllMaterialFlags(scene::IMesh *mesh) const; scene::IAnimatedMesh *getAnimatedMesh(const std::string &name); scene::IMesh *getMesh(const std::string &name); - scene::IAnimatedMesh *copyAnimatedMesh(scene::IAnimatedMesh *orig); + scene::IAnimatedMesh *copyAnimatedMesh(scene::IAnimatedMesh *orig, + video::E_CUSTOM_MATERIAL_TYPE cmt); video::ITexture *applyMask(video::ITexture* texture, const std::string& mask_path); void displayFPS(); diff --git a/src/graphics/stk_animated_mesh.cpp b/src/graphics/stk_animated_mesh.cpp index a251803f1..94484f966 100644 --- a/src/graphics/stk_animated_mesh.cpp +++ b/src/graphics/stk_animated_mesh.cpp @@ -126,6 +126,10 @@ void STKAnimatedMesh::updateNoGL() TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material); TransparentMesh[TranspMat].push_back(&mesh); } + else if (m->getCustomMaterialType() == video::ECMT_TRANSPARENT) + { + TransparentMesh[TM_ADDITIVE].push_back(&mesh); + } else { Material::ShaderType MatType = material->getShaderType();// getMeshMaterialFromType(type, mb->getVertexType(), material); diff --git a/src/graphics/stk_mesh_scene_node.cpp b/src/graphics/stk_mesh_scene_node.cpp index d2bd3c864..066687ff2 100644 --- a/src/graphics/stk_mesh_scene_node.cpp +++ b/src/graphics/stk_mesh_scene_node.cpp @@ -173,7 +173,14 @@ void STKMeshSceneNode::updateNoGL() GLMesh &mesh = GLmeshes[i]; Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); - if (rnd->isTransparent()) + if (Mesh->getCustomMaterialType() == video::ECMT_TRANSPARENT) + { + if (!immediate_draw) + TransparentMesh[TM_ADDITIVE].push_back(&mesh); + else + additive = true; + } + else if (rnd->isTransparent()) { TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material); if (!immediate_draw) diff --git a/src/karts/abstract_kart.cpp b/src/karts/abstract_kart.cpp index 796e0e514..2ad7a6f5d 100644 --- a/src/karts/abstract_kart.cpp +++ b/src/karts/abstract_kart.cpp @@ -35,7 +35,8 @@ AbstractKart::AbstractKart(const std::string& ident, int world_kart_id, int position, const btTransform& init_transform, - PerPlayerDifficulty difficulty) + PerPlayerDifficulty difficulty, + video::E_CUSTOM_MATERIAL_TYPE cmt) : Moveable() { m_world_kart_id = world_kart_id; @@ -59,7 +60,7 @@ AbstractKart::AbstractKart(const std::string& ident, // released when the kart is deleted, but since the original // kart_model is stored in the kart_properties all the time, // there is no risk of a mesh being deleted to early. - m_kart_model = m_kart_properties->getKartModelCopy(); + m_kart_model = m_kart_properties->getKartModelCopy(cmt); m_kart_width = m_kart_model->getWidth(); m_kart_height = m_kart_model->getHeight(); m_kart_length = m_kart_model->getLength(); diff --git a/src/karts/abstract_kart.hpp b/src/karts/abstract_kart.hpp index 74abc824f..f94dfbc37 100644 --- a/src/karts/abstract_kart.hpp +++ b/src/karts/abstract_kart.hpp @@ -19,6 +19,7 @@ #ifndef HEADER_ABSTRACT_KART_HPP #define HEADER_ABSTRACT_KART_HPP +#include #include #include "items/powerup_manager.hpp" @@ -98,7 +99,8 @@ public: AbstractKart(const std::string& ident, int world_kart_id, int position, const btTransform& init_transform, - PerPlayerDifficulty difficulty); + PerPlayerDifficulty difficulty, + video::E_CUSTOM_MATERIAL_TYPE cmt); virtual ~AbstractKart(); virtual core::stringw getName() const; virtual void reset(); diff --git a/src/karts/ghost_kart.cpp b/src/karts/ghost_kart.cpp index 707229425..e8ece7022 100644 --- a/src/karts/ghost_kart.cpp +++ b/src/karts/ghost_kart.cpp @@ -28,7 +28,7 @@ GhostKart::GhostKart(const std::string& ident, unsigned int world_kart_id, int position) : Kart(ident, world_kart_id, position, btTransform(btQuaternion(0, 0, 0, 1)), - PLAYER_DIFFICULTY_NORMAL) + PLAYER_DIFFICULTY_NORMAL, video::ECMT_TRANSPARENT) { } // GhostKart diff --git a/src/karts/kart.cpp b/src/karts/kart.cpp index 17e8bac4a..e7b400e2f 100644 --- a/src/karts/kart.cpp +++ b/src/karts/kart.cpp @@ -92,9 +92,10 @@ */ Kart::Kart (const std::string& ident, unsigned int world_kart_id, int position, const btTransform& init_transform, - PerPlayerDifficulty difficulty) + PerPlayerDifficulty difficulty, + video::E_CUSTOM_MATERIAL_TYPE cmt) : AbstractKart(ident, world_kart_id, position, init_transform, - difficulty) + difficulty, cmt) #if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) # pragma warning(1:4355) diff --git a/src/karts/kart.hpp b/src/karts/kart.hpp index c822e1dc1..c751f72df 100644 --- a/src/karts/kart.hpp +++ b/src/karts/kart.hpp @@ -231,7 +231,8 @@ private: public: Kart(const std::string& ident, unsigned int world_kart_id, int position, const btTransform& init_transform, - PerPlayerDifficulty difficulty); + PerPlayerDifficulty difficulty, + video::E_CUSTOM_MATERIAL_TYPE cmt = video::ECMT_DEFAULT); virtual ~Kart(); virtual void init(RaceManager::KartType type); virtual void kartIsInRestNow(); diff --git a/src/karts/kart_model.cpp b/src/karts/kart_model.cpp index 12af928f7..2c2f67644 100644 --- a/src/karts/kart_model.cpp +++ b/src/karts/kart_model.cpp @@ -281,7 +281,7 @@ KartModel::~KartModel() * It is also marked not to be a master copy, so attachModel can be called * for this instance. */ -KartModel* KartModel::makeCopy() +KartModel* KartModel::makeCopy(video::E_CUSTOM_MATERIAL_TYPE cmt) { // Make sure that we are copying from a master objects, and // that there is indeed no animated node defined here ... @@ -294,7 +294,7 @@ KartModel* KartModel::makeCopy() km->m_kart_height = m_kart_height; km->m_kart_highest_point= m_kart_highest_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, cmt); km->m_model_filename = m_model_filename; km->m_animation_speed = m_animation_speed; km->m_current_animation = AF_DEFAULT; diff --git a/src/karts/kart_model.hpp b/src/karts/kart_model.hpp index 27be3190f..5a6a723e4 100644 --- a/src/karts/kart_model.hpp +++ b/src/karts/kart_model.hpp @@ -232,7 +232,7 @@ private: public: KartModel(bool is_master); ~KartModel(); - KartModel* makeCopy(); + KartModel* makeCopy(video::E_CUSTOM_MATERIAL_TYPE cmt); void reset(); void loadInfo(const XMLNode &node); bool loadModels(const KartProperties &kart_properties); diff --git a/src/karts/kart_properties.hpp b/src/karts/kart_properties.hpp index b8f81438a..d08c7207a 100644 --- a/src/karts/kart_properties.hpp +++ b/src/karts/kart_properties.hpp @@ -243,8 +243,9 @@ public: // ------------------------------------------------------------------------ /** Returns a pointer to the KartModel object. */ - KartModel* getKartModelCopy () const - {return m_kart_model->makeCopy(); } + KartModel* getKartModelCopy + (video::E_CUSTOM_MATERIAL_TYPE cmt = video::ECMT_DEFAULT) const + {return m_kart_model->makeCopy(cmt); } // ------------------------------------------------------------------------ /** Returns a pointer to the main KartModel object. This copy diff --git a/src/modes/soccer_world.cpp b/src/modes/soccer_world.cpp index 90814533f..fe108268e 100644 --- a/src/modes/soccer_world.cpp +++ b/src/modes/soccer_world.cpp @@ -398,7 +398,8 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index, m_kart_position_map[index] = (unsigned)(pos_index - 1); AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos, - difficulty); + difficulty, team == SOCCER_TEAM_BLUE ? + video::ECMT_BLUE : video::ECMT_RED); new_kart->init(race_manager->getKartType(index)); Controller *controller = NULL;