1) Added graphical effect when 'nitro' is active
(texture and graphics still needs to be improved!) 2) Added new user_config setting for graphical effects. 3) Started to move graphics related file into separate subdirectory. git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2535 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
d2866bb42e
commit
1c0c2d0ffe
@ -55,7 +55,9 @@ supertuxkart_SOURCES = main.cpp \
|
||||
utils/random_generator.hpp utils/random_generator.cpp \
|
||||
utils/ssg_help.cpp utils/ssg_help.hpp \
|
||||
material_manager.cpp material_manager.hpp \
|
||||
grand_prix_manager.cpp grand_prix_manager.hpp \
|
||||
grand_prix_manager.cpp grand_prix_manager.hpp \
|
||||
graphics/nitro.cpp graphics/nitro.hpp \
|
||||
graphics/skid_mark.cpp graphics/skid_mark.hpp \
|
||||
items/attachment.cpp items/attachment.hpp \
|
||||
items/attachment_manager.cpp items/attachment_manager.hpp \
|
||||
items/powerup.cpp items/powerup.hpp \
|
||||
|
93
src/graphics/nitro.cpp
Executable file
93
src/graphics/nitro.cpp
Executable file
@ -0,0 +1,93 @@
|
||||
// $Id: nitro.cpp 1681 2008-04-09 13:52:48Z hikerstk $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 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/nitro.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "material_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
|
||||
Nitro::Nitro(Kart* kart)
|
||||
: ParticleSystem(200, 0.0f, true, 0.5f),
|
||||
m_kart(kart)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
setName("nitro");
|
||||
#endif
|
||||
bsphere.setCenter(0, 0, 0);
|
||||
bsphere.setRadius(1000.0f);
|
||||
dirtyBSphere();
|
||||
|
||||
m_nitro_fire = new ssgSimpleState ();
|
||||
m_nitro_fire->setTexture(material_manager->getMaterial("flames.rgb")->getState()->getTexture());
|
||||
m_nitro_fire -> setTranslucent () ;
|
||||
m_nitro_fire -> enable ( GL_TEXTURE_2D ) ;
|
||||
m_nitro_fire -> setShadeModel ( GL_SMOOTH ) ;
|
||||
m_nitro_fire -> disable ( GL_CULL_FACE ) ;
|
||||
m_nitro_fire -> enable ( GL_BLEND ) ;
|
||||
m_nitro_fire -> enable ( GL_LIGHTING ) ;
|
||||
m_nitro_fire -> setColourMaterial ( GL_EMISSION ) ;
|
||||
m_nitro_fire -> setMaterial ( GL_AMBIENT, 0, 0, 0, 1 ) ;
|
||||
m_nitro_fire -> setMaterial ( GL_DIFFUSE, 0, 0, 0, 1 ) ;
|
||||
m_nitro_fire -> setMaterial ( GL_SPECULAR, 0, 0, 0, 1 ) ;
|
||||
m_nitro_fire -> setShininess ( 0 ) ;
|
||||
m_nitro_fire->ref();
|
||||
|
||||
setState(m_nitro_fire);
|
||||
|
||||
} // KartParticleSystem
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
Nitro::~Nitro()
|
||||
{
|
||||
ssgDeRefDelete(m_nitro_fire);
|
||||
} // ~Nitro
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Nitro::update(float t)
|
||||
{
|
||||
ParticleSystem::update(t);
|
||||
} // update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Nitro::particle_create(int, Particle *p)
|
||||
{
|
||||
sgSetVec4(p->m_col, 1, 1, 1, 1 ); /* initially white */
|
||||
sgSetVec3(p->m_vel, 0, 0, 0 );
|
||||
sgSetVec3(p->m_acc, 0, 0, 2.0f ); /* Gravity */
|
||||
p->m_size = 0.5f;
|
||||
p->m_time_to_live = 0.8f;
|
||||
|
||||
Vec3 xyz = m_kart->getXYZ();
|
||||
const Vec3 vel = -m_kart->getVelocity()*0.2;
|
||||
sgCopyVec3(p->m_vel, vel.toFloat());
|
||||
sgCopyVec3(p->m_pos, xyz.toFloat());
|
||||
p->m_vel[0] += cos(DEGREE_TO_RAD(rand()% 10));
|
||||
p->m_vel[1] += sin(DEGREE_TO_RAD(rand()% 80));
|
||||
p->m_vel[2] = 0;
|
||||
} // particle_create
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Nitro::particle_update(float delta, int,
|
||||
Particle * particle)
|
||||
{
|
||||
particle->m_size -= delta*.2f;
|
||||
particle->m_col[3] -= delta * 2.0f;
|
||||
} // particle_update
|
||||
|
||||
|
45
src/graphics/nitro.hpp
Executable file
45
src/graphics/nitro.hpp
Executable file
@ -0,0 +1,45 @@
|
||||
// $Id: nitro.hpp 1681 2008-04-09 13:52:48Z hikerstk $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2008 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_NITRO_HPP
|
||||
#define HEADER_NITRO_HPP
|
||||
|
||||
#define _WINSOCKAPI_
|
||||
#include <plib/sg.h>
|
||||
#include "particle_system.hpp"
|
||||
|
||||
class Kart;
|
||||
|
||||
class Nitro: public ParticleSystem
|
||||
{
|
||||
private:
|
||||
/** The kart to which this smoke belongs. */
|
||||
Kart *m_kart;
|
||||
/** The texture to use. */
|
||||
ssgSimpleState *m_nitro_fire;
|
||||
|
||||
public:
|
||||
Nitro (Kart* kart);
|
||||
~Nitro ();
|
||||
virtual void update (float t );
|
||||
virtual void particle_create(int index, Particle* p );
|
||||
virtual void particle_update(float deltaTime, int index, Particle *p );
|
||||
};
|
||||
#endif
|
||||
|
@ -779,10 +779,6 @@
|
||||
RelativePath="../../../src\shadow.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\skid_mark.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\smoke.cpp"
|
||||
>
|
||||
@ -1187,6 +1183,18 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="graphics"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\graphics\nitro.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\graphics\skid_mark.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Headerdateien"
|
||||
@ -1341,10 +1349,6 @@
|
||||
RelativePath="../../../src\shadow.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="../../../src\skid_mark.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\smoke.hpp"
|
||||
>
|
||||
@ -1817,6 +1821,18 @@
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="graphics"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\graphics\nitro.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\graphics\skid_mark.hpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Ressourcendateien"
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "coord.hpp"
|
||||
#include "items/item_manager.hpp"
|
||||
#include "file_manager.hpp"
|
||||
#include "skid_mark.hpp"
|
||||
#include "user_config.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "shadow.hpp"
|
||||
@ -45,6 +44,8 @@
|
||||
#include "audio/sound_manager.hpp"
|
||||
#include "audio/sfx_manager.hpp"
|
||||
#include "audio/sfx_base.hpp"
|
||||
#include "graphics/nitro.hpp"
|
||||
#include "graphics/skid_mark.hpp"
|
||||
#include "gui/menu_manager.hpp"
|
||||
#include "gui/race_gui.hpp"
|
||||
#include "karts/kart_model.hpp"
|
||||
@ -77,6 +78,7 @@ Kart::Kart (const std::string& kart_name, int position,
|
||||
m_finish_time = 0.0f;
|
||||
m_wheelie_angle = 0.0f;
|
||||
m_smoke_system = NULL;
|
||||
m_nitro = NULL;
|
||||
m_skidmark_left = NULL;
|
||||
m_skidmark_right = NULL;
|
||||
|
||||
@ -242,6 +244,7 @@ Kart::~Kart()
|
||||
sfx_manager->deleteSFX(m_skid_sound );
|
||||
|
||||
if(m_smoke_system) ssgDeRefDelete(m_smoke_system);
|
||||
if(m_nitro) ssgDeRefDelete(m_nitro);
|
||||
|
||||
ssgDeRefDelete(m_shadow);
|
||||
|
||||
@ -527,11 +530,11 @@ void Kart::update(float dt)
|
||||
m_attachment.update(dt);
|
||||
|
||||
//smoke drawing control point
|
||||
if ( user_config->m_smoke )
|
||||
if ( user_config->m_graphical_effects )
|
||||
{
|
||||
if (m_smoke_system != NULL)
|
||||
m_smoke_system->update (dt);
|
||||
} // user_config->smoke
|
||||
m_smoke_system->update(dt);
|
||||
m_nitro->update(dt);
|
||||
} // user_config->m_graphical_effects
|
||||
updatePhysics(dt);
|
||||
|
||||
//kart_info.m_last_track_coords = kart_info.m_curr_track_coords;
|
||||
@ -898,11 +901,7 @@ void Kart::processSkidMarks()
|
||||
const float threshold = 0.3f;
|
||||
//FIXME const float ANGLE = 43.0f;
|
||||
//FIXME const float LENGTH = 0.57f;
|
||||
bool skid_front = m_vehicle->getWheelInfo(0).m_skidInfo < threshold ||
|
||||
m_vehicle->getWheelInfo(1).m_skidInfo < threshold;
|
||||
bool skid_rear = m_vehicle->getWheelInfo(2).m_skidInfo < threshold ||
|
||||
m_vehicle->getWheelInfo(3).m_skidInfo < threshold;
|
||||
if(skid_rear || skid_front)
|
||||
if(m_controls.jump)
|
||||
{
|
||||
if(isOnGround())
|
||||
{
|
||||
@ -947,7 +946,9 @@ void Kart::loadData()
|
||||
|
||||
m_smoke_system = new Smoke(this);
|
||||
m_smoke_system->ref();
|
||||
scene->add(m_smoke_system);
|
||||
|
||||
m_nitro = new Nitro(this);
|
||||
m_nitro->ref();
|
||||
|
||||
m_skidmark_left = new SkidMark(/* angle sign */ -1);
|
||||
m_skidmark_right = new SkidMark(/* angle sign */ 1);
|
||||
@ -999,6 +1000,9 @@ void Kart::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
|
||||
|
||||
if(m_smoke_system)
|
||||
m_smoke_system->setCreationRate((m_skidding-1)*100.0f);
|
||||
if(m_nitro)
|
||||
m_nitro->setCreationRate(m_controls.wheelie && m_collected_energy>0
|
||||
? getSpeed() : 0);
|
||||
|
||||
float speed_ratio = getSpeed()/getMaxSpeed();
|
||||
float offset_heading = getSteerPercent()*0.05f*3.1415926f * speed_ratio * m_skidding*m_skidding;
|
||||
|
@ -36,6 +36,7 @@
|
||||
class SkidMark;
|
||||
class Item;
|
||||
class Smoke;
|
||||
class Nitro;
|
||||
class SFXBase;
|
||||
|
||||
class Kart : public TerrainInfo, public Moveable
|
||||
@ -72,9 +73,12 @@ private:
|
||||
/** The amount of energy collected bu hitting coins. */
|
||||
float m_collected_energy;
|
||||
|
||||
// don't delete the following 2 vars (they're kids in the hirarchy)
|
||||
/** Smoke from skidding. */
|
||||
Smoke *m_smoke_system;
|
||||
|
||||
/** Fire when using a nitro. */
|
||||
Nitro *m_nitro;
|
||||
|
||||
float m_wheel_rotation;
|
||||
/** For each wheel it stores the suspension length after the karts are at
|
||||
* the start position, i.e. the suspension will be somewhat compressed.
|
||||
|
@ -24,6 +24,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include "vec3.hpp"
|
||||
#include "scene.hpp"
|
||||
|
||||
ParticleSystem::ParticleSystem ( int num, float create_rate, int ttf, float sz)
|
||||
: ssgVtxTable(GL_QUADS,
|
||||
@ -67,6 +68,7 @@ ParticleSystem::ParticleSystem ( int num, float create_rate, int ttf, float sz)
|
||||
}
|
||||
|
||||
m_num_active = 0 ;
|
||||
scene->add(this);
|
||||
} // ParticleSystem
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -18,6 +18,8 @@
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
For further information visit http://plib.sourceforge.net */
|
||||
#ifndef PARTICLE_SYSTEM_HPP
|
||||
#define PARTICLE_SYSTEM_HPP
|
||||
|
||||
#include <plib/ssg.h>
|
||||
|
||||
@ -87,7 +89,7 @@ public:
|
||||
|
||||
virtual void particle_create( int index, Particle *p ) = 0;
|
||||
virtual void particle_update( float deltaTime, int index, Particle *p ) = 0;
|
||||
virtual void particle_delete( int index, Particle* p ) = 0;
|
||||
virtual void particle_delete( int index, Particle* p ) {};
|
||||
|
||||
void init(int initial_num);
|
||||
void recalcBSphere();
|
||||
@ -103,5 +105,5 @@ public:
|
||||
int getNumParticles () const { return m_num_particles ; }
|
||||
int getNumActiveParticles () const { return m_num_active ; }
|
||||
} ;
|
||||
|
||||
#endif
|
||||
/* EOF */
|
||||
|
@ -61,7 +61,6 @@ Smoke::~Smoke()
|
||||
//-----------------------------------------------------------------------------
|
||||
void Smoke::update(float t)
|
||||
{
|
||||
bsphere.setRadius(1000.0f);
|
||||
ParticleSystem::update(t);
|
||||
} // update
|
||||
|
||||
@ -95,8 +94,3 @@ void Smoke::particle_update(float delta, int,
|
||||
particle->m_col[3] -= delta * 2.0f;
|
||||
} // particle_update
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
void Smoke::particle_delete (int , Particle* )
|
||||
{
|
||||
} // particle_delete
|
||||
|
||||
|
@ -39,7 +39,6 @@ public:
|
||||
virtual void update (float t );
|
||||
virtual void particle_create(int index, Particle* p );
|
||||
virtual void particle_update(float deltaTime, int index, Particle *p );
|
||||
virtual void particle_delete(int index, Particle* p );
|
||||
};
|
||||
#endif
|
||||
|
||||
|
@ -89,37 +89,37 @@ void UserConfig::setFilename()
|
||||
void UserConfig::setDefaults()
|
||||
{
|
||||
setFilename();
|
||||
m_warning = "";
|
||||
m_keyboard_debug = false;
|
||||
m_track_debug = 0;
|
||||
m_bullet_debug = false;
|
||||
m_fullscreen = false;
|
||||
m_no_start_screen = false;
|
||||
m_sfx = UC_ENABLE;
|
||||
m_music = UC_ENABLE;
|
||||
m_smoke = false;
|
||||
m_display_fps = false;
|
||||
m_item_style = "items";
|
||||
m_background_music = "";
|
||||
m_profile = 0;
|
||||
m_print_kart_sizes = false;
|
||||
m_max_fps = 120;
|
||||
m_sfx_volume = 1.0f;
|
||||
m_use_kph = false;
|
||||
m_width = 800;
|
||||
m_height = 600;
|
||||
m_prev_width = m_width;
|
||||
m_prev_height = m_height;
|
||||
m_prev_windowed = false;
|
||||
m_crashed = false;
|
||||
m_warning = "";
|
||||
m_keyboard_debug = false;
|
||||
m_track_debug = 0;
|
||||
m_bullet_debug = false;
|
||||
m_fullscreen = false;
|
||||
m_no_start_screen = false;
|
||||
m_sfx = UC_ENABLE;
|
||||
m_music = UC_ENABLE;
|
||||
m_graphical_effects = true;
|
||||
m_display_fps = false;
|
||||
m_item_style = "items";
|
||||
m_background_music = "";
|
||||
m_profile = 0;
|
||||
m_print_kart_sizes = false;
|
||||
m_max_fps = 120;
|
||||
m_sfx_volume = 1.0f;
|
||||
m_use_kph = false;
|
||||
m_width = 800;
|
||||
m_height = 600;
|
||||
m_prev_width = m_width;
|
||||
m_prev_height = m_height;
|
||||
m_prev_windowed = false;
|
||||
m_crashed = false;
|
||||
m_blacklist_res.clear();
|
||||
m_karts = 4;
|
||||
m_log_errors = false;
|
||||
m_kart_group = "standard";
|
||||
m_track_group = "standard";
|
||||
m_last_track = "jungle";
|
||||
m_server_address = "localhost";
|
||||
m_server_port = 2305;
|
||||
m_karts = 4;
|
||||
m_log_errors = false;
|
||||
m_kart_group = "standard";
|
||||
m_track_group = "standard";
|
||||
m_last_track = "jungle";
|
||||
m_server_address = "localhost";
|
||||
m_server_port = 2305;
|
||||
|
||||
if(getenv("USERNAME")!=NULL) // for windows
|
||||
m_username=getenv("USERNAME");
|
||||
@ -417,7 +417,7 @@ void UserConfig::loadConfig(const std::string& filename)
|
||||
bool doMusic=false; // avoid warning
|
||||
lisp->get("music", doMusic);
|
||||
m_music = doMusic ? UC_ENABLE : UC_DISABLE;
|
||||
lisp->get("smoke", m_smoke);
|
||||
lisp->get("graphical-effects",m_graphical_effects);
|
||||
lisp->get("displayFPS", m_display_fps);
|
||||
lisp->get("itemStyle", m_item_style);
|
||||
lisp->get("background-music", m_background_music);
|
||||
@ -657,7 +657,7 @@ void UserConfig::saveConfig(const std::string& filename)
|
||||
writer->writeComment("the following options can be set to #t or #f:");
|
||||
writer->write("sfx\t", !(m_sfx==UC_DISABLE));
|
||||
writer->write("music\t", !(m_music==UC_DISABLE));
|
||||
writer->write("smoke\t", m_smoke);
|
||||
writer->write("graphical-effects\t", m_graphical_effects);
|
||||
writer->writeComment("Display frame per seconds");
|
||||
writer->write("displayFPS\t", m_display_fps);
|
||||
writer->writeComment("Name of the .items file to use.");
|
||||
|
@ -163,7 +163,7 @@ public:
|
||||
bool m_bullet_debug;
|
||||
bool m_fullscreen;
|
||||
bool m_no_start_screen;
|
||||
bool m_smoke;
|
||||
bool m_graphical_effects;
|
||||
bool m_display_fps;
|
||||
int m_profile; // Positive number: time in seconds, neg: # laps. (used to profile AI)
|
||||
bool m_print_kart_sizes; // print all kart sizes
|
||||
|
Loading…
Reference in New Issue
Block a user