Remove shadow blob
This commit is contained in:
parent
2206f8ad5c
commit
33c0dfe7c2
@ -1,87 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2013 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "graphics/shadow.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
|
||||
#include <IMesh.h>
|
||||
#include <IMeshSceneNode.h>
|
||||
#include <ISceneNode.h>
|
||||
|
||||
Shadow::Shadow(video::ITexture *texture, scene::ISceneNode *node,
|
||||
float scale = 1.0, float x_offset = 0.0, float y_offset = 0.0,
|
||||
float z_offset = 0.0)
|
||||
{
|
||||
video::SMaterial m;
|
||||
m.setTexture(0, texture);
|
||||
m.BackfaceCulling = false;
|
||||
m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
m.setFlag(video::EMF_ZWRITE_ENABLE , false);
|
||||
m_mesh = irr_driver->createQuadMesh(&m, /*create_one_quad*/true);
|
||||
scene::IMeshBuffer *buffer = m_mesh->getMeshBuffer(0);
|
||||
irr::video::S3DVertex* v=(video::S3DVertex*)buffer->getVertices();
|
||||
v[0].Pos.X = -scale+x_offset; v[0].Pos.Z = scale+z_offset; v[0].Pos.Y = 0.01f-y_offset;
|
||||
v[1].Pos.X = scale+x_offset; v[1].Pos.Z = scale+z_offset; v[1].Pos.Y = 0.01f-y_offset;
|
||||
v[2].Pos.X = scale+x_offset; v[2].Pos.Z = -scale+z_offset; v[2].Pos.Y = 0.01f-y_offset;
|
||||
v[3].Pos.X = -scale+x_offset; v[3].Pos.Z = -scale+z_offset; v[3].Pos.Y = 0.01f-y_offset;
|
||||
v[0].TCoords = core::vector2df(0,0);
|
||||
v[1].TCoords = core::vector2df(1,0);
|
||||
v[2].TCoords = core::vector2df(1,1);
|
||||
v[3].TCoords = core::vector2df(0,1);
|
||||
core::vector3df normal(0, 0, 1.0f);
|
||||
v[0].Normal = normal;
|
||||
v[1].Normal = normal;
|
||||
v[2].Normal = normal;
|
||||
v[3].Normal = normal;
|
||||
buffer->recalculateBoundingBox();
|
||||
|
||||
m_node = irr_driver->addMesh(m_mesh, "shadow");
|
||||
#ifdef DEBUG
|
||||
m_node->setName("shadow");
|
||||
#endif
|
||||
|
||||
m_mesh->drop(); // the node grabs the mesh, so we can drop this reference
|
||||
m_node->setAutomaticCulling(scene::EAC_OFF);
|
||||
m_parent_kart_node = node;
|
||||
m_parent_kart_node->addChild(m_node);
|
||||
} // Shadow
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
Shadow::~Shadow()
|
||||
{
|
||||
// Note: the mesh was not loaded from disk, so it is not cached,
|
||||
// and does not need to be removed. It's clean up when removing the node
|
||||
m_parent_kart_node->removeChild(m_node);
|
||||
} // ~Shadow
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Removes the shadow, used for the simplified shadow when the kart is in
|
||||
* the air.
|
||||
*/
|
||||
void Shadow::disableShadow()
|
||||
{
|
||||
m_node->setVisible(false);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Enables the shadow again, after it was disabled with disableShadow().
|
||||
*/
|
||||
void Shadow::enableShadow()
|
||||
{
|
||||
m_node->setVisible(true);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
@ -1,59 +0,0 @@
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2009-2013 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
// as published by the Free Software Foundation; either version 3
|
||||
// of the License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#ifndef HEADER_SHADOW_HPP
|
||||
#define HEADER_SHADOW_HPP
|
||||
|
||||
#include "utils/no_copy.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace irr
|
||||
{
|
||||
namespace scene { class ISceneNode; class IMesh; }
|
||||
namespace video { class ITexture; }
|
||||
}
|
||||
using namespace irr;
|
||||
|
||||
/**
|
||||
* \brief This class is used to enable a shadow for a kart.
|
||||
* For now it uses a simple texture to simulate the shadow, real time shadows might
|
||||
* be added later.
|
||||
* \ingroup graphics
|
||||
*/
|
||||
class Shadow : public NoCopy
|
||||
{
|
||||
private:
|
||||
/** The scene node for the shadow. */
|
||||
scene::ISceneNode *m_node;
|
||||
/** The mesh of the shadow. */
|
||||
scene::IMesh *m_mesh;
|
||||
/** The scene node of the kart to which this shadow belongs. */
|
||||
scene::ISceneNode *m_parent_kart_node;
|
||||
public:
|
||||
Shadow(video::ITexture *texture, scene::ISceneNode *node,
|
||||
float scale, float x_offset, float y_offset,float z_offset);
|
||||
~Shadow();
|
||||
void enableShadow();
|
||||
void disableShadow();
|
||||
}; // Shadow
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include "graphics/particle_emitter.hpp"
|
||||
#include "graphics/particle_kind.hpp"
|
||||
#include "graphics/particle_kind_manager.hpp"
|
||||
#include "graphics/shadow.hpp"
|
||||
#include "graphics/skid_marks.hpp"
|
||||
#include "graphics/slip_stream.hpp"
|
||||
#include "graphics/stk_text_billboard.hpp"
|
||||
@ -117,7 +116,6 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
|
||||
m_squash_time = 0.0f;
|
||||
m_shadow_enabled = false;
|
||||
|
||||
m_shadow = NULL;
|
||||
m_wheel_box = NULL;
|
||||
m_collision_particles = NULL;
|
||||
m_slipstream = NULL;
|
||||
@ -268,7 +266,6 @@ Kart::~Kart()
|
||||
if(m_attachment) delete m_attachment;
|
||||
if(m_stars_effect) delete m_stars_effect;
|
||||
|
||||
delete m_shadow;
|
||||
if (m_wheel_box) m_wheel_box->remove();
|
||||
if(m_skidmarks) delete m_skidmarks ;
|
||||
|
||||
@ -1407,11 +1404,9 @@ void Kart::update(float dt)
|
||||
if((!isOnGround() || emergency) && m_shadow_enabled)
|
||||
{
|
||||
m_shadow_enabled = false;
|
||||
m_shadow->disableShadow();
|
||||
}
|
||||
if(!m_shadow_enabled && isOnGround() && !emergency)
|
||||
{
|
||||
m_shadow->enableShadow();
|
||||
m_shadow_enabled = true;
|
||||
}
|
||||
} // update
|
||||
@ -2469,13 +2464,6 @@ void Kart::loadData(RaceManager::KartType type, bool is_animated_model)
|
||||
->isFogEnabled() );
|
||||
}
|
||||
|
||||
m_shadow = new Shadow(m_kart_properties->getShadowTexture(),
|
||||
m_node,
|
||||
m_kart_properties->getShadowScale(),
|
||||
m_kart_properties->getShadowXOffset(),
|
||||
m_kart_properties->getGraphicalYOffset(),
|
||||
m_kart_properties->getShadowZOffset());
|
||||
|
||||
World::getWorld()->kartAdded(this, m_node);
|
||||
} // loadData
|
||||
|
||||
|
@ -170,9 +170,6 @@ private:
|
||||
/** Is time flying activated */
|
||||
bool m_is_jumping;
|
||||
|
||||
/** The shadow of a kart. */
|
||||
Shadow *m_shadow;
|
||||
|
||||
/** If a kart is flying, the shadow is disabled (since it is
|
||||
* stuck to the kart, i.e. the shadow would be flying, too). */
|
||||
bool m_shadow_enabled;
|
||||
|
Loading…
Reference in New Issue
Block a user