Add transparent ghost kart in STK

There is already define for soccer team too, so in the future,
if anyone is smart to make a shader to draw red/blue karts,
it should be easier.

TODO: wheels and speed weight objects. (They seem need to be copied to work)
This commit is contained in:
Benau 2016-04-02 15:53:21 +08:00
parent 5ac25db7f8
commit ccd6294699
13 changed files with 40 additions and 17 deletions

View File

@ -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 * \return Newly created skinned mesh. You should call drop() when you don't
* need it anymore. * 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; using namespace scene;
CSkinnedMesh *mesh = dynamic_cast<CSkinnedMesh*>(orig); CSkinnedMesh *mesh = dynamic_cast<CSkinnedMesh*>(orig);
@ -1022,7 +1023,10 @@ scene::IAnimatedMesh *IrrDriver::copyAnimatedMesh(scene::IAnimatedMesh *orig)
Log::error("copyAnimatedMesh", "Given mesh was not a skinned mesh."); Log::error("copyAnimatedMesh", "Given mesh was not a skinned mesh.");
return NULL; return NULL;
} }
return mesh->clone();
scene::IAnimatedMesh* out = mesh->clone();
out->setCustomMaterialType(cmt);
return out;
} // copyAnimatedMesh } // copyAnimatedMesh
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -353,7 +353,8 @@ public:
void setAllMaterialFlags(scene::IMesh *mesh) const; void setAllMaterialFlags(scene::IMesh *mesh) const;
scene::IAnimatedMesh *getAnimatedMesh(const std::string &name); scene::IAnimatedMesh *getAnimatedMesh(const std::string &name);
scene::IMesh *getMesh(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, video::ITexture *applyMask(video::ITexture* texture,
const std::string& mask_path); const std::string& mask_path);
void displayFPS(); void displayFPS();

View File

@ -126,6 +126,10 @@ void STKAnimatedMesh::updateNoGL()
TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material); TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material);
TransparentMesh[TranspMat].push_back(&mesh); TransparentMesh[TranspMat].push_back(&mesh);
} }
else if (m->getCustomMaterialType() == video::ECMT_TRANSPARENT)
{
TransparentMesh[TM_ADDITIVE].push_back(&mesh);
}
else else
{ {
Material::ShaderType MatType = material->getShaderType();// getMeshMaterialFromType(type, mb->getVertexType(), material); Material::ShaderType MatType = material->getShaderType();// getMeshMaterialFromType(type, mb->getVertexType(), material);

View File

@ -173,7 +173,14 @@ void STKMeshSceneNode::updateNoGL()
GLMesh &mesh = GLmeshes[i]; GLMesh &mesh = GLmeshes[i];
Material* material = material_manager->getMaterialFor(mb->getMaterial().getTexture(0), mb); 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); TransparentMaterial TranspMat = getTransparentMaterialFromType(type, MaterialTypeParam, material);
if (!immediate_draw) if (!immediate_draw)

View File

@ -35,7 +35,8 @@
AbstractKart::AbstractKart(const std::string& ident, AbstractKart::AbstractKart(const std::string& ident,
int world_kart_id, int position, int world_kart_id, int position,
const btTransform& init_transform, const btTransform& init_transform,
PerPlayerDifficulty difficulty) PerPlayerDifficulty difficulty,
video::E_CUSTOM_MATERIAL_TYPE cmt)
: Moveable() : Moveable()
{ {
m_world_kart_id = world_kart_id; 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 // released when the kart is deleted, but since the original
// kart_model is stored in the kart_properties all the time, // kart_model is stored in the kart_properties all the time,
// there is no risk of a mesh being deleted to early. // 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_width = m_kart_model->getWidth();
m_kart_height = m_kart_model->getHeight(); m_kart_height = m_kart_model->getHeight();
m_kart_length = m_kart_model->getLength(); m_kart_length = m_kart_model->getLength();

View File

@ -19,6 +19,7 @@
#ifndef HEADER_ABSTRACT_KART_HPP #ifndef HEADER_ABSTRACT_KART_HPP
#define HEADER_ABSTRACT_KART_HPP #define HEADER_ABSTRACT_KART_HPP
#include <EMaterialTypes.h>
#include <memory> #include <memory>
#include "items/powerup_manager.hpp" #include "items/powerup_manager.hpp"
@ -98,7 +99,8 @@ public:
AbstractKart(const std::string& ident, AbstractKart(const std::string& ident,
int world_kart_id, int world_kart_id,
int position, const btTransform& init_transform, int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty); PerPlayerDifficulty difficulty,
video::E_CUSTOM_MATERIAL_TYPE cmt);
virtual ~AbstractKart(); virtual ~AbstractKart();
virtual core::stringw getName() const; virtual core::stringw getName() const;
virtual void reset(); virtual void reset();

View File

@ -28,7 +28,7 @@ GhostKart::GhostKart(const std::string& ident, unsigned int world_kart_id,
int position) int position)
: Kart(ident, world_kart_id, : Kart(ident, world_kart_id,
position, btTransform(btQuaternion(0, 0, 0, 1)), position, btTransform(btQuaternion(0, 0, 0, 1)),
PLAYER_DIFFICULTY_NORMAL) PLAYER_DIFFICULTY_NORMAL, video::ECMT_TRANSPARENT)
{ {
} // GhostKart } // GhostKart

View File

@ -92,9 +92,10 @@
*/ */
Kart::Kart (const std::string& ident, unsigned int world_kart_id, Kart::Kart (const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform, int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty) PerPlayerDifficulty difficulty,
video::E_CUSTOM_MATERIAL_TYPE cmt)
: AbstractKart(ident, world_kart_id, position, init_transform, : AbstractKart(ident, world_kart_id, position, init_transform,
difficulty) difficulty, cmt)
#if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) #if defined(WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
# pragma warning(1:4355) # pragma warning(1:4355)

View File

@ -231,7 +231,8 @@ private:
public: public:
Kart(const std::string& ident, unsigned int world_kart_id, Kart(const std::string& ident, unsigned int world_kart_id,
int position, const btTransform& init_transform, int position, const btTransform& init_transform,
PerPlayerDifficulty difficulty); PerPlayerDifficulty difficulty,
video::E_CUSTOM_MATERIAL_TYPE cmt = video::ECMT_DEFAULT);
virtual ~Kart(); virtual ~Kart();
virtual void init(RaceManager::KartType type); virtual void init(RaceManager::KartType type);
virtual void kartIsInRestNow(); virtual void kartIsInRestNow();

View File

@ -281,7 +281,7 @@ KartModel::~KartModel()
* It is also marked not to be a master copy, so attachModel can be called * It is also marked not to be a master copy, so attachModel can be called
* for this instance. * 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 // Make sure that we are copying from a master objects, and
// that there is indeed no animated node defined here ... // 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_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, cmt);
km->m_model_filename = m_model_filename; km->m_model_filename = m_model_filename;
km->m_animation_speed = m_animation_speed; km->m_animation_speed = m_animation_speed;
km->m_current_animation = AF_DEFAULT; km->m_current_animation = AF_DEFAULT;

View File

@ -232,7 +232,7 @@ private:
public: public:
KartModel(bool is_master); KartModel(bool is_master);
~KartModel(); ~KartModel();
KartModel* makeCopy(); KartModel* makeCopy(video::E_CUSTOM_MATERIAL_TYPE cmt);
void reset(); void reset();
void loadInfo(const XMLNode &node); void loadInfo(const XMLNode &node);
bool loadModels(const KartProperties &kart_properties); bool loadModels(const KartProperties &kart_properties);

View File

@ -243,8 +243,9 @@ public:
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
/** Returns a pointer to the KartModel object. */ /** Returns a pointer to the KartModel object. */
KartModel* getKartModelCopy () const KartModel* getKartModelCopy
{return m_kart_model->makeCopy(); } (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 /** Returns a pointer to the main KartModel object. This copy

View File

@ -398,7 +398,8 @@ AbstractKart *SoccerWorld::createKart(const std::string &kart_ident, int index,
m_kart_position_map[index] = (unsigned)(pos_index - 1); m_kart_position_map[index] = (unsigned)(pos_index - 1);
AbstractKart *new_kart = new Kart(kart_ident, index, position, init_pos, 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)); new_kart->init(race_manager->getKartType(index));
Controller *controller = NULL; Controller *controller = NULL;