Added 'old style'/simplified shadows back in - to be used for lower
end hardware. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/irrlicht@3551 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d6a325b879
commit
7926d5fe97
@ -1,8 +1,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
|
||||
// Copyright (C) 2006 SuperTuxKart-Team, Steve Baker
|
||||
// Copyright (C) 2009 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -18,45 +17,59 @@
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
#include "material_manager.hpp"
|
||||
#include "material.hpp"
|
||||
#include "shadow.hpp"
|
||||
|
||||
#ifndef HAVE_IRRLICHT
|
||||
ssgTransform* createShadow( const std::string& name,
|
||||
float x1, float x2, float y1, float y2 )
|
||||
#include "irrlicht.h"
|
||||
|
||||
#include "graphics/irr_driver.hpp"
|
||||
|
||||
Shadow::Shadow(const std::string &name)
|
||||
{
|
||||
ssgVertexArray *va = new ssgVertexArray () ; sgVec3 v ;
|
||||
ssgNormalArray *na = new ssgNormalArray () ; sgVec3 n ;
|
||||
ssgColourArray *ca = new ssgColourArray () ; sgVec4 c ;
|
||||
ssgTexCoordArray *ta = new ssgTexCoordArray () ; sgVec2 t ;
|
||||
video::ITexture *texture = irr_driver->getTexture(name);
|
||||
video::SMaterial m;
|
||||
m.setTexture(0, texture);
|
||||
m.BackfaceCulling = false;
|
||||
m.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
|
||||
m_mesh = irr_driver->createQuadMesh(&m);
|
||||
m_buffer = m_mesh->getMeshBuffer(0);
|
||||
irr::video::S3DVertex* v=(video::S3DVertex*)m_buffer->getVertices();
|
||||
v[0].Pos.X = -1.0f; v[0].Pos.Z = -1.0f; v[0].Pos.Y = 0.05f;
|
||||
v[1].Pos.X = 1.0f; v[1].Pos.Z = -1.0f; v[1].Pos.Y = 0.05f;
|
||||
v[2].Pos.X = 1.0f; v[2].Pos.Z = 1.0f; v[2].Pos.Y = 0.05f;
|
||||
v[3].Pos.X = -1.0f; v[3].Pos.Z = 1.0f; v[3].Pos.Y = 0.05f;
|
||||
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;
|
||||
m_buffer->recalculateBoundingBox();
|
||||
|
||||
m_node = irr_driver->addMesh(m_mesh);
|
||||
|
||||
m_node->setAutomaticCulling(scene::EAC_OFF);
|
||||
} // Shadow
|
||||
|
||||
sgSetVec4 ( c, 0.0f, 0.0f, 0.0f, 1.0f ) ; ca->add(c) ;
|
||||
sgSetVec3 ( n, 0.0f, 0.0f, 1.0f ) ; na->add(n) ;
|
||||
|
||||
sgSetVec3 ( v, x1, y1, 0.05f ) ; va->add(v) ;
|
||||
sgSetVec3 ( v, x2, y1, 0.05f ) ; va->add(v) ;
|
||||
sgSetVec3 ( v, x1, y2, 0.05f ) ; va->add(v) ;
|
||||
sgSetVec3 ( v, x2, y2, 0.05f ) ; va->add(v) ;
|
||||
|
||||
sgSetVec2 ( t, 0.0f, 0.0f ) ; ta->add(t) ;
|
||||
sgSetVec2 ( t, 1.0f, 0.0f ) ; ta->add(t) ;
|
||||
sgSetVec2 ( t, 0.0f, 1.0f ) ; ta->add(t) ;
|
||||
sgSetVec2 ( t, 1.0f, 1.0f ) ; ta->add(t) ;
|
||||
|
||||
ssgTransform* result = new ssgTransform ;
|
||||
result -> clrTraversalMaskBits ( SSGTRAV_ISECT|SSGTRAV_HOT ) ;
|
||||
|
||||
result -> setName ( "Shadow" ) ;
|
||||
|
||||
ssgVtxTable *gs = new ssgVtxTable ( GL_TRIANGLE_STRIP, va, na, ta, ca ) ;
|
||||
// FIXME LEAK: va, na, ta, and ca are most likely leaked, since plib
|
||||
// will mark them as 'not owned' and therefore not free them!
|
||||
gs -> clrTraversalMaskBits ( SSGTRAV_ISECT|SSGTRAV_HOT ) ;
|
||||
gs -> setState ( material_manager->getMaterial ( name.c_str() ) -> getState () ) ;
|
||||
result -> addKid ( gs ) ;
|
||||
|
||||
return result;
|
||||
// ----------------------------------------------------------------------------
|
||||
Shadow::~Shadow()
|
||||
{
|
||||
} // ~Shadow
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Removes the shadow, used for the simplified shadow when the kart is in
|
||||
* the air.
|
||||
*/
|
||||
void Shadow::disableShadow()
|
||||
{
|
||||
m_node->setVisible(false);
|
||||
}
|
||||
#endif
|
||||
/* EOF */
|
||||
// ----------------------------------------------------------------------------
|
||||
/** Enables the shadow again, after it was disabled with disableShadow().
|
||||
*/
|
||||
void Shadow::enableShadow()
|
||||
{
|
||||
m_node->setVisible(true);
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -1,8 +1,7 @@
|
||||
// $Id$
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2004-2005 Steve Baker <sjbaker1@airmail.net>
|
||||
// Copyright (C) 2006 SuperTuxKart-Team, Steve Baker
|
||||
// Copyright (C) 2009 Joerg Henrichs
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU General Public License
|
||||
@ -18,16 +17,35 @@
|
||||
// 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_H
|
||||
#define HEADER_SHADOW_H
|
||||
#ifndef HEADER_SHADOW_HPP
|
||||
#define HEADER_SHADOW_HPP
|
||||
|
||||
#include <string>
|
||||
|
||||
class ssgTransform;
|
||||
|
||||
ssgTransform* createShadow(const std::string& name,
|
||||
float x1, float x2, float y1, float y2 );
|
||||
#include "irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
/** 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 will be
|
||||
* added later.
|
||||
*/
|
||||
class Shadow
|
||||
{
|
||||
private:
|
||||
/** The scene node for the shadow. */
|
||||
scene::ISceneNode *m_node;
|
||||
/** The mesh of the shadow. */
|
||||
scene::IMesh *m_mesh;
|
||||
/** The mesh buffer containing the actual vertices of the shadow. */
|
||||
scene::IMeshBuffer *m_buffer;
|
||||
public:
|
||||
Shadow(const std::string &name);
|
||||
~Shadow();
|
||||
void enableShadow();
|
||||
void disableShadow();
|
||||
/** Returns the scene node of the shadow. */
|
||||
scene::ISceneNode* getSceneNode() const {return m_node; }
|
||||
}; // Shadow
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
|
@ -245,7 +245,8 @@ Kart::~Kart()
|
||||
//if(m_smoke_system) ssgDeRefDelete(m_smoke_system);
|
||||
//if(m_nitro) ssgDeRefDelete(m_nitro);
|
||||
|
||||
//ssgDeRefDelete(m_shadow);
|
||||
m_animated_node->removeChild(m_shadow->getSceneNode());
|
||||
delete m_shadow;
|
||||
|
||||
if(m_skidmarks) delete m_skidmarks ;
|
||||
|
||||
@ -650,18 +651,12 @@ void Kart::update(float dt)
|
||||
if( (!isOnGround() || m_rescue) && m_shadow_enabled)
|
||||
{
|
||||
m_shadow_enabled = false;
|
||||
#ifdef HAVE_IRRLICHT
|
||||
#else
|
||||
m_model_transform->removeKid(m_shadow);
|
||||
#endif
|
||||
m_shadow->disableShadow();
|
||||
}
|
||||
if(!m_shadow_enabled && isOnGround() && !m_rescue)
|
||||
{
|
||||
m_shadow->enableShadow();
|
||||
m_shadow_enabled = true;
|
||||
#ifdef HAVE_IRRLICHT
|
||||
#else
|
||||
m_model_transform->addKid(m_shadow);
|
||||
#endif
|
||||
}
|
||||
} // update
|
||||
|
||||
@ -1015,13 +1010,10 @@ void Kart::loadData()
|
||||
|
||||
if(m_kart_properties->hasSkidmarks())
|
||||
m_skidmarks = new SkidMarks(*this);
|
||||
#ifdef HAVE_IRRLICHT
|
||||
#else
|
||||
m_shadow = createShadow(m_kart_properties->getShadowFile(), -1, 1, -1, 1);
|
||||
m_shadow->ref();
|
||||
m_model_transform->addKid ( m_shadow );
|
||||
m_shadow_enabled = true;
|
||||
#endif
|
||||
|
||||
m_shadow = new Shadow(file_manager->getKartFile(m_kart_properties->getShadowFile(),
|
||||
getIdent() ));
|
||||
m_animated_node->addChild(m_shadow->getSceneNode());
|
||||
} // loadData
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include "tracks/terrain_info.hpp"
|
||||
|
||||
class SkidMarks;
|
||||
class Shadow;
|
||||
class Item;
|
||||
class Smoke;
|
||||
class ssgTransform;
|
||||
class Nitro;
|
||||
class SFXBase;
|
||||
class btUprightConstraint;
|
||||
@ -78,7 +78,7 @@ protected:
|
||||
private:
|
||||
/** The amount of energy collected by hitting coins. */
|
||||
float m_collected_energy;
|
||||
ssgTransform *m_shadow; /**<The shadow of the kart. */
|
||||
Shadow *m_shadow; /**<The shadow of the kart. */
|
||||
/** 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