Added some slip stream graphical effects (which are disabled by default) - pretty much work in progress.
git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@4493 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
parent
3d7c364eaa
commit
81d074a694
@ -120,8 +120,9 @@ skid-decrease: multiplicative decrease of skidding factor in each frame.
|
||||
skid-max: maximum skidding factor = maximum increase of steering angle.
|
||||
time-till-max-skid: Time till maximum skidding is reached.
|
||||
skid-visual: Additional graphical rotation of kart.
|
||||
slipstrea slipstream-length: How far behind a kart slipstream works
|
||||
slipstream-time: How many seconds of sstream give maximum benefit
|
||||
slipstream slipstream-length: How far behind a kart slipstream works
|
||||
slipstream-collect-time: How many seconds of sstream give maximum benefit
|
||||
slipstream-use-time: How long the benefit will last.
|
||||
slipstream-add-power: Additional power due to sstreaming. 1 = +100%
|
||||
slipstream-min-speed: Minimum speed necessary for slipstream to take effect.
|
||||
|
||||
@ -195,10 +196,11 @@ rubber-band-duration is the duration a rubber band acts.
|
||||
skid-max="2.5"
|
||||
time-till-max-skid="0.4"
|
||||
skid-visual="0.16"
|
||||
slipstream-length="5"
|
||||
slipstream-time="5"
|
||||
slipstream-length="10"
|
||||
slipstream-collect-time="2"
|
||||
slipstream-use-time="5"
|
||||
slipstream-add-power="3"
|
||||
slipstream-min-speed="15"
|
||||
slipstream-min-speed="10"
|
||||
|
||||
brake-factor="11.0"
|
||||
min-speed-radius="0 3"
|
||||
|
@ -68,6 +68,8 @@ supertuxkart_SOURCES = \
|
||||
graphics/shadow.hpp \
|
||||
graphics/skid_marks.cpp \
|
||||
graphics/skid_marks.hpp \
|
||||
graphics/slip_stream.cpp \
|
||||
graphics/slip_stream.hpp \
|
||||
graphics/smoke.cpp \
|
||||
graphics/smoke.hpp \
|
||||
graphics/stars.cpp \
|
||||
|
@ -53,7 +53,17 @@ MovingTexture::MovingTexture(core::matrix4 *matrix, float dx, float dy)
|
||||
core::vector3df v = m_matrix->getTranslation();
|
||||
m_x = v.X;
|
||||
m_y = v.Y;
|
||||
} // Moving Texture
|
||||
} // MovingTexture
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
MovingTexture::MovingTexture(float dx, float dy)
|
||||
{
|
||||
m_dx = dx;
|
||||
m_dy = dy;
|
||||
m_x = 0;
|
||||
m_y = 0;
|
||||
m_matrix = NULL;
|
||||
} // MovingTexture
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Destructor for an animated texture.
|
||||
@ -62,6 +72,15 @@ MovingTexture::~MovingTexture()
|
||||
{
|
||||
} // ~MovingTexture
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Resets at (re)start of a race.
|
||||
*/
|
||||
void MovingTexture::reset()
|
||||
{
|
||||
m_x = m_y = 0;
|
||||
m_matrix->setTextureTranslate(m_x, m_y);
|
||||
} // reset
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Updates the transform of an animated texture.
|
||||
* \param dt Time step size.
|
||||
|
@ -39,9 +39,15 @@ private:
|
||||
public:
|
||||
MovingTexture(core::matrix4 *matrix, const XMLNode &node);
|
||||
MovingTexture(core::matrix4 *matrix, float dx, float dy);
|
||||
MovingTexture(float dx, float dy);
|
||||
~MovingTexture();
|
||||
void update (float dt);
|
||||
void init () {};
|
||||
|
||||
/** Sets the speed of the animation. */
|
||||
void setSpeed(float dx, float dy) {m_dx = dx; m_dy = dy;}
|
||||
/** Sets the texture matrix. */
|
||||
void setTextureMatrix(core::matrix4 *matrix) {m_matrix=matrix;}
|
||||
virtual void update (float dt);
|
||||
virtual void reset ();
|
||||
}
|
||||
; // MovingTexture
|
||||
|
||||
|
149
src/graphics/slip_stream.cpp
Normal file
149
src/graphics/slip_stream.cpp
Normal file
@ -0,0 +1,149 @@
|
||||
// $Id: slip_stream.cpp 1681 2008-04-09 13:52:48Z hikerstk $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 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/slip_stream.hpp"
|
||||
|
||||
#include "graphics/material_manager.hpp"
|
||||
#include "graphics/irr_driver.hpp"
|
||||
#include "io/file_manager.hpp"
|
||||
#include "karts/kart.hpp"
|
||||
#include "utils/constants.hpp"
|
||||
|
||||
/** Creates the slip stream object using a moving texture.
|
||||
* \param kart Pointer to the kart to which the slip stream
|
||||
* belongs to.
|
||||
*/
|
||||
SlipStream::SlipStream(Kart* kart) : m_kart(kart), MovingTexture(0, 0)
|
||||
{
|
||||
video::SMaterial m;
|
||||
Material *material = material_manager->getMaterial("slipstream.png");
|
||||
m.setTexture(0, material->getTexture());
|
||||
m.setFlag(video::EMF_BACK_FACE_CULLING, false);
|
||||
m.MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA;
|
||||
createMesh(m);
|
||||
m_node = irr_driver->addMesh(m_mesh);
|
||||
m_node->setParent(m_kart->getNode());
|
||||
m_node->setPosition(core::vector3df(0,
|
||||
0*0.25f,
|
||||
m_kart->getKartLength()) );
|
||||
setTextureMatrix(&(m_node->getMaterial(0).getTextureMatrix(0)));
|
||||
} // SlipStream
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Removes the node from the scene graph.
|
||||
*/
|
||||
SlipStream::~SlipStream()
|
||||
{
|
||||
irr_driver->removeNode(m_node);
|
||||
} // ~SlipStream
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Creates the mesh for the slipstream effect. This function creates a
|
||||
* first a series of circles (with a certain number of vertices each and
|
||||
* distance from each other. Then it will create the triangles and add
|
||||
* texture coordniates.
|
||||
* \param material The material to use.
|
||||
*/
|
||||
void SlipStream::createMesh(const video::SMaterial &material)
|
||||
{
|
||||
// All radius, starting with the one closest to the kart (and
|
||||
// widest) to the one furthest away. A 0 indicates the end of the list
|
||||
float radius[] = {3.0f, 2.0f, 1.0f, 0.0f};
|
||||
|
||||
// The distance of each of the circle from the kart. The number of
|
||||
// entries in this array must be the same as the number of non-zero
|
||||
// entries in the radius[] array above. No 'end of list' entry required.
|
||||
float distance[] = {0.0f, 2.0f, 4.0f };
|
||||
|
||||
// The alpha values for the rings, no 'end of list' entry required.
|
||||
int alphas[] = {0, 255, 0};
|
||||
|
||||
// Loop through all given radius to determine the number
|
||||
// of segments to create.
|
||||
unsigned int num_circles;
|
||||
for(num_circles=0; radius[num_circles]!=0; num_circles++) ;
|
||||
|
||||
// Length is distance of last circle to distance of first circle:
|
||||
float length = distance[num_circles-1] - distance[0];
|
||||
|
||||
// The number of points for each circle.
|
||||
const int num_segments = 15;
|
||||
const float f = 2*M_PI/float(num_segments);
|
||||
scene::SMeshBuffer *buffer = new scene::SMeshBuffer();
|
||||
buffer->Material = material;
|
||||
for(unsigned int j=0; j<num_circles; j++)
|
||||
{
|
||||
float curr_distance = distance[j]-distance[0];
|
||||
// Create the vertices for each of the circle
|
||||
for(unsigned int i=0; i<num_segments; i++)
|
||||
{
|
||||
video::S3DVertex v;
|
||||
v.Pos.X = sin(i*f)*radius[j];
|
||||
v.Pos.Y = -cos(i*f)*radius[j];
|
||||
v.Pos.Z = distance[j];
|
||||
v.Color = video::SColor(alphas[j], 255, 0, 0);
|
||||
v.TCoords.X = curr_distance/length;
|
||||
v.TCoords.Y = (float)i/(num_segments-1);
|
||||
buffer->Vertices.push_back(v);
|
||||
} // for i<num_segments
|
||||
} // while radius[num_circles]!=0
|
||||
|
||||
// Now create the triangles.
|
||||
for(unsigned int j=0; j<num_circles-1; j++)
|
||||
{
|
||||
for(unsigned int i=0; i<num_segments-1; i++)
|
||||
{
|
||||
buffer->Indices.push_back( j *num_segments+i );
|
||||
buffer->Indices.push_back((j+1)*num_segments+i );
|
||||
buffer->Indices.push_back( j *num_segments+i+1);
|
||||
buffer->Indices.push_back( j *num_segments+i+1);
|
||||
buffer->Indices.push_back((j+1)*num_segments+i );
|
||||
buffer->Indices.push_back((j+1)*num_segments+i+1);
|
||||
}
|
||||
} // for j<num_circles-1
|
||||
|
||||
scene::SMesh *mesh = new scene::SMesh();
|
||||
mesh->addMeshBuffer(buffer);
|
||||
mesh->recalculateBoundingBox();
|
||||
|
||||
buffer->drop();
|
||||
m_mesh = mesh;
|
||||
} // createMesh
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** Sets the animation intensity (or speed).
|
||||
* \param f Intensity: 0 = no slip stream,
|
||||
* 1 = collecting
|
||||
* 2 = using slip stream bonus
|
||||
*/
|
||||
void SlipStream::setIntensity(float f)
|
||||
{
|
||||
// For now: disable them permanently
|
||||
m_node->setVisible(false);
|
||||
return;
|
||||
|
||||
// For real testing in game: this needs some tuning!
|
||||
//m_node->setVisible(f!=0);
|
||||
//MovingTexture::setSpeed(f*0.1f, 0);
|
||||
|
||||
// For debugging: make the slip stream effect visible all the time
|
||||
m_node->setVisible(true);
|
||||
MovingTexture::setSpeed(1.0f, 0.0f);
|
||||
} // setIntensity
|
||||
|
51
src/graphics/slip_stream.hpp
Normal file
51
src/graphics/slip_stream.hpp
Normal file
@ -0,0 +1,51 @@
|
||||
// $Id: slip_stream.hpp 1681 2008-04-09 13:52:48Z hikerstk $
|
||||
//
|
||||
// SuperTuxKart - a fun racing game with go-kart
|
||||
// Copyright (C) 2010 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_SLIP_STREAM_HPP
|
||||
#define HEADER_SLIP_STREAM_HPP
|
||||
|
||||
#include "irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
#include "graphics/moving_texture.hpp"
|
||||
class Kart;
|
||||
|
||||
class SlipStream : public MovingTexture
|
||||
{
|
||||
private:
|
||||
/** The kart to which this smoke belongs. */
|
||||
Kart *m_kart;
|
||||
|
||||
/** The scene node. */
|
||||
scene::ISceneNode *m_node;
|
||||
|
||||
/** The actual mesh. */
|
||||
scene::IMesh *m_mesh;
|
||||
|
||||
/** The texture matrix for the slipstream effect. */
|
||||
core::matrix4 *m_matrix;
|
||||
|
||||
void createMesh(const video::SMaterial &m);
|
||||
public:
|
||||
SlipStream (Kart* kart);
|
||||
virtual ~SlipStream ();
|
||||
void setIntensity(float f);
|
||||
}; // SlipStream
|
||||
#endif
|
||||
|
@ -130,7 +130,7 @@
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
WholeProgramOptimization="true"
|
||||
AdditionalIncludeDirectories="../../../src;../../../src/bullet/src;"$(STK_INCLUDE)";../../../src/enet/include;"$(IRR_INCLUDE)""
|
||||
AdditionalIncludeDirectories="../../../src;../../../src/bullet/src;"$(STK_INCLUDE)";../../../src/enet/include;"C:\cygwin\home\jh235117\local\irrlicht-1.7\include""
|
||||
PreprocessorDefinitions="HAVE_OPENAL;HAVE_OGGVORBIS;NDEBUG;_CONSOLE;WIN32;NOMINMAX;VERSION=\"SVN\";_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;BT_NO_PROFILE;PACKAGE=\"supertuxkart\";HAVE_GETTEXT;ENABLE_NLS;HAVE_GLUT;HAVE_IRRLICHT;IRR_SVN"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
@ -152,7 +152,7 @@
|
||||
AdditionalDependencies="opengl32.lib user32.lib gdi32.lib winmm.lib advapi32.lib SDL.lib SDLmain.lib OpenAL32.lib libogg.lib libvorbis.lib libvorbisfile.lib intl.lib Irrlicht.lib ws2_32.lib"
|
||||
OutputFile="./../../../$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""$(STK_LIB)";"$(IRR_LIB)""
|
||||
AdditionalLibraryDirectories=""$(STK_LIB)";"C:\cygwin\home\jh235117\local\irrlicht-1.7\lib\Win32-visualstudio""
|
||||
IgnoreDefaultLibraryNames="libcmt.lib"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
@ -740,6 +740,10 @@
|
||||
RelativePath="..\..\graphics\skid_marks.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\graphics\slip_stream.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\graphics\smoke.cpp"
|
||||
>
|
||||
@ -1570,6 +1574,10 @@
|
||||
RelativePath="..\..\graphics\skid_marks.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\graphics\slip_stream.hpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\graphics\smoke.hpp"
|
||||
>
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "graphics/nitro.hpp"
|
||||
#include "graphics/shadow.hpp"
|
||||
#include "graphics/skid_marks.hpp"
|
||||
#include "graphics/slip_stream.hpp"
|
||||
#include "graphics/smoke.hpp"
|
||||
#include "graphics/stars.hpp"
|
||||
#include "graphics/water_splash.hpp"
|
||||
@ -79,6 +80,7 @@ Kart::Kart (const std::string& kart_name, int position,
|
||||
m_stars_effect = NULL;
|
||||
m_water_splash_system = NULL;
|
||||
m_nitro = NULL;
|
||||
m_slip_stream = NULL;
|
||||
m_skidmarks = NULL;
|
||||
m_animated_node = NULL;
|
||||
|
||||
@ -133,8 +135,8 @@ Kart::Kart (const std::string& kart_name, int position,
|
||||
Vec3 p1(-getKartWidth()*0.5f, -getKartLength()*0.5f-l, 0);
|
||||
Vec3 p2( getKartWidth()*0.5f, -getKartLength()*0.5f-l, 0);
|
||||
Vec3 p3( getKartWidth()*0.5f, -getKartLength()*0.5f, 0);
|
||||
m_slipstream_original_area = new Quad(p0, p1, p2, p3);
|
||||
m_slipstream_area = new Quad(p0, p1, p2, p3);
|
||||
m_slipstream_original_quad = new Quad(p0, p1, p2, p3);
|
||||
m_slipstream_quad = new Quad(p0, p1, p2, p3);
|
||||
|
||||
reset();
|
||||
} // Kart
|
||||
@ -278,6 +280,7 @@ Kart::~Kart()
|
||||
if(m_smoke_system) delete m_smoke_system;
|
||||
if(m_water_splash_system) delete m_water_splash_system;
|
||||
if(m_nitro) delete m_nitro;
|
||||
if(m_slip_stream) delete m_slip_stream;
|
||||
|
||||
delete m_shadow;
|
||||
delete m_stars_effect;
|
||||
@ -293,8 +296,8 @@ Kart::~Kart()
|
||||
{
|
||||
delete m_kart_chassis.getChildShape(i);
|
||||
}
|
||||
delete m_slipstream_original_area;
|
||||
delete m_slipstream_area;
|
||||
delete m_slipstream_original_quad;
|
||||
delete m_slipstream_quad;
|
||||
} // ~Kart
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -372,6 +375,7 @@ void Kart::reset()
|
||||
m_time_last_crash = 0.0f;
|
||||
m_max_speed_reduction = 0.0f;
|
||||
m_power_reduction = 50.0f;
|
||||
m_slipstream_mode = SS_NONE;
|
||||
|
||||
m_controls.m_steer = 0.0f;
|
||||
m_controls.m_accel = 0.0f;
|
||||
@ -382,6 +386,7 @@ void Kart::reset()
|
||||
m_controls.m_look_back = false;
|
||||
// Reset star effect in case that it is currently being shown.
|
||||
m_stars_effect->reset();
|
||||
m_slip_stream->reset();
|
||||
m_vehicle->deactivateZipper();
|
||||
|
||||
// Set the brakes so that karts don't slide downhill
|
||||
@ -613,6 +618,7 @@ void Kart::update(float dt)
|
||||
m_smoke_system->update(dt);
|
||||
m_water_splash_system->update(dt);
|
||||
m_nitro->update(dt);
|
||||
m_slip_stream->update(dt);
|
||||
} // UserConfigParams::m_graphical_effects
|
||||
|
||||
updatePhysics(dt);
|
||||
@ -782,24 +788,29 @@ float Kart::handleNitro(float dt)
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
/** This function manages slipstreaming. It adds up the time a kart was
|
||||
* slipstreaming, and returns the potential power boost due to coming
|
||||
* out of slipstream.
|
||||
* slipstreaming, and if a kart was slipstreaming long enough, it will
|
||||
* add power to the kart for a certain amount of time.
|
||||
*/
|
||||
float Kart::handleSlipstream(float dt)
|
||||
{
|
||||
// First see if we are currently using accumulated slipstream credits:
|
||||
// -------------------------------------------------------------------
|
||||
if(m_slipstream_mode==SS_USE)
|
||||
{
|
||||
printf("Using slipstream\n");
|
||||
m_slipstream_time -= dt;
|
||||
if(m_slipstream_time<0) m_slipstream_mode=SS_NONE;
|
||||
return m_kart_properties->getSlipstreamAddPower();
|
||||
}
|
||||
|
||||
// If this kart is too slow for slipstreaming taking effect, do nothing
|
||||
// --------------------------------------------------------------------
|
||||
if(getSpeed()<m_kart_properties->getSlipstreamMinSpeed()) return 0;
|
||||
|
||||
m_slipstream_original_area->transform(getTrans(), m_slipstream_area);
|
||||
// Then test if this kart is in the slipstream range of another kart:
|
||||
// ------------------------------------------------------------------
|
||||
m_slipstream_original_quad->transform(getTrans(), m_slipstream_quad);
|
||||
|
||||
// Note: there is a slight inconsistency here: Karts are updated one
|
||||
// after another. So if the position of this kart is compared with the
|
||||
// slipstream area of a kart already updated, it will use the new
|
||||
// slipstream area of that kart, but for karts not yet updated the
|
||||
// old position will be used. The differences should not be noticable,
|
||||
// and simplifies the update process (which would otherwise have to be
|
||||
// done in two stages). Besides, the same problem exists everywhere
|
||||
// in the kart update process.
|
||||
unsigned int n = race_manager->getNumKarts();
|
||||
bool is_sstreaming = false;
|
||||
for(unsigned int i=0; i<n; i++)
|
||||
@ -810,41 +821,43 @@ float Kart::handleSlipstream(float dt)
|
||||
|
||||
// If the kart we are testing against is too slow, no need to test
|
||||
// slipstreaming. Note: We compare the speed of the other kart
|
||||
// against the minimum slipstream kart of this kart - not entirely
|
||||
// sure if this makes sense, but it makes it easier to give karts
|
||||
// different slipstream properties.
|
||||
// against the minimum slipstream speed kart of this kart - not
|
||||
// entirely sure if this makes sense, but it makes it easier to
|
||||
// give karts different slipstream properties.
|
||||
if(kart->getSpeed()<m_kart_properties->getSlipstreamMinSpeed())
|
||||
continue;
|
||||
// Quick test: the kart must be not more than
|
||||
// slipstream length+kart_length() away from the other kart
|
||||
Vec3 delta = getXYZ() - kart->getXYZ();
|
||||
float l = kart->m_kart_properties->getSlipstreamLength() + kart->getKartLength()*0.5f;
|
||||
float l = kart->m_kart_properties->getSlipstreamLength()
|
||||
+ kart->getKartLength()*0.5f;
|
||||
if(delta.length2_2d() > l*l) continue;
|
||||
|
||||
if(kart->m_slipstream_area->pointInQuad(getXYZ()))
|
||||
if(kart->m_slipstream_quad->pointInQuad(getXYZ()))
|
||||
{
|
||||
is_sstreaming = true;
|
||||
is_sstreaming = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
float add_power = 0;
|
||||
|
||||
if(m_slipstream_time >0 && !is_sstreaming)
|
||||
if(!is_sstreaming)
|
||||
{
|
||||
// Kart is using slipstream advantage
|
||||
add_power = getMaxPower() * m_kart_properties->getSlipstreamAddPower();
|
||||
m_slipstream_time = std::max(m_slipstream_time - dt, 0.0f);
|
||||
}
|
||||
else if(is_sstreaming)
|
||||
{
|
||||
// Kart is collecting sliptstream advantage
|
||||
m_slipstream_time = std::min(m_slipstream_time + dt,
|
||||
m_kart_properties->getSlipstreamTime());
|
||||
|
||||
m_slipstream_time -=dt;
|
||||
if(m_slipstream_time<0) m_slipstream_mode = SS_NONE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return add_power;
|
||||
// Accumulate slipstream credits now
|
||||
m_slipstream_time = m_slipstream_mode==SS_NONE ? dt
|
||||
: m_slipstream_time+dt;
|
||||
printf("Collecting slipstream %f\n", m_slipstream_time);
|
||||
m_slipstream_mode = SS_COLLECT;
|
||||
if(m_slipstream_time>m_kart_properties->getSlipstreamCollectTime())
|
||||
{
|
||||
m_slipstream_mode = SS_USE;
|
||||
return m_kart_properties->getSlipstreamAddPower();
|
||||
}
|
||||
return 0;
|
||||
} // handleSlipstream
|
||||
|
||||
|
||||
@ -1207,6 +1220,7 @@ void Kart::loadData()
|
||||
m_smoke_system = new Smoke(this);
|
||||
m_water_splash_system = new WaterSplash(this);
|
||||
m_nitro = new Nitro(this);
|
||||
m_slip_stream = new SlipStream(this);
|
||||
|
||||
if(m_kart_properties->hasSkidmarks())
|
||||
m_skidmarks = new SkidMarks(*this);
|
||||
@ -1282,6 +1296,12 @@ void Kart::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
|
||||
// become a huge unsigned number in the particle scene node!
|
||||
m_nitro->setCreationRate(m_controls.m_nitro && m_collected_energy>0
|
||||
? (10.0f + fabsf(getSpeed())*20.0f) : 0);
|
||||
float f=0;
|
||||
if(m_slipstream_mode==SS_COLLECT)
|
||||
f=1.0f;
|
||||
else if(m_slipstream_mode==SS_USE)
|
||||
f=2.0f;
|
||||
m_slip_stream->setIntensity(f);
|
||||
|
||||
float speed_ratio = getSpeed()/getMaxSpeed();
|
||||
float offset_heading = getSteerPercent()*m_kart_properties->getSkidVisual()
|
||||
|
@ -37,6 +37,7 @@ class Item;
|
||||
class Smoke;
|
||||
class WaterSplash;
|
||||
class Nitro;
|
||||
class SlipStream;
|
||||
class SFXBase;
|
||||
class btUprightConstraint;
|
||||
class btKart;
|
||||
@ -101,6 +102,10 @@ private:
|
||||
|
||||
/** Graphical effect when using a nitro. */
|
||||
Nitro *m_nitro;
|
||||
|
||||
/** Graphical effect when slipstreaming. */
|
||||
SlipStream *m_slip_stream;
|
||||
|
||||
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.
|
||||
@ -115,13 +120,19 @@ private:
|
||||
// ---------------------------
|
||||
/** The quad inside which another kart is considered to be slipstreaming.
|
||||
* This value is current area, i.e. takes the kart position into account. */
|
||||
Quad *m_slipstream_area;
|
||||
Quad *m_slipstream_quad;
|
||||
|
||||
/** This is slipstream area if the kart is at 0,0,0 without rotation. From
|
||||
* this value m_slipstream_area is computed by applying the kart transform. */
|
||||
Quad *m_slipstream_original_area;
|
||||
Quad *m_slipstream_original_quad;
|
||||
|
||||
/** The time a kart was in slipstream. */
|
||||
float m_slipstream_time;
|
||||
|
||||
/** Slipstream mode: either nothing happening, or the kart is collecting
|
||||
* 'slipstream credits', or the kart is using accumulated credits. */
|
||||
enum {SS_NONE, SS_COLLECT, SS_USE} m_slipstream_mode;
|
||||
|
||||
float m_finish_time;
|
||||
bool m_finished_race;
|
||||
|
||||
|
@ -72,7 +72,8 @@ KartProperties::KartProperties(const std::string &filename) : m_icon_material(0)
|
||||
m_rubber_band_duration = m_time_till_max_skid =
|
||||
m_skid_decrease = m_skid_increase = m_skid_visual = m_skid_max =
|
||||
m_camera_max_accel = m_camera_max_brake =
|
||||
m_slipstream_length = m_slipstream_time = m_slipstream_add_power =
|
||||
m_slipstream_length = m_slipstream_collect_time =
|
||||
m_slipstream_use_time = m_slipstream_add_power =
|
||||
m_slipstream_min_speed = m_camera_distance = UNDEFINED;
|
||||
m_gravity_center_shift = Vec3(UNDEFINED);
|
||||
m_has_skidmarks = true;
|
||||
@ -242,7 +243,8 @@ void KartProperties::getAllData(const XMLNode * root)
|
||||
root->get("time-till-max-skid", &m_time_till_max_skid);
|
||||
root->get("skid-visual", &m_skid_visual);
|
||||
root->get("slipstream-length", &m_slipstream_length);
|
||||
root->get("slipstream-time", &m_slipstream_time);
|
||||
root->get("slipstream-collect-time", &m_slipstream_collect_time);
|
||||
root->get("slipstream-use-time", &m_slipstream_use_time);
|
||||
root->get("slipstream-add-power", &m_slipstream_add_power);
|
||||
root->get("slipstream-min-speed", &m_slipstream_min_speed);
|
||||
root->get("brake-factor", &m_brake_factor);
|
||||
@ -453,7 +455,8 @@ void KartProperties::getAllData(const lisp::Lisp* lisp)
|
||||
lisp->get("skid-max", m_skid_max );
|
||||
lisp->get("skid-visual", m_skid_visual );
|
||||
lisp->get("slipstream-length", m_slipstream_length );
|
||||
lisp->get("slipstream-time", m_slipstream_time );
|
||||
lisp->get("slipstream-collect-time", m_slipstream_collect_time );
|
||||
lisp->get("slipstream-use-time", m_slipstream_use_time );
|
||||
lisp->get("slipstream-add-power", m_slipstream_add_power );
|
||||
lisp->get("slipstream-min-speed", m_slipstream_min_speed );
|
||||
|
||||
@ -547,7 +550,8 @@ void KartProperties::checkAllSet(const std::string &filename)
|
||||
CHECK_NEG(m_skid_max, "skid-max" );
|
||||
CHECK_NEG(m_skid_visual, "skid-visual" );
|
||||
CHECK_NEG(m_slipstream_length, "slipstream-length" );
|
||||
CHECK_NEG(m_slipstream_time, "slipstream-time" );
|
||||
CHECK_NEG(m_slipstream_collect_time, "slipstream-collect-time" );
|
||||
CHECK_NEG(m_slipstream_use_time, "slipstream-use-time" );
|
||||
CHECK_NEG(m_slipstream_add_power, "slipstream-add-power" );
|
||||
CHECK_NEG(m_slipstream_min_speed, "slipstream-min-speed" );
|
||||
|
||||
|
@ -140,8 +140,9 @@ private:
|
||||
* when skidding. */
|
||||
float m_slipstream_length; /**< How far behind a kart slipstreaming
|
||||
* is effective. */
|
||||
float m_slipstream_time; /**< Time after which sstream has maxium
|
||||
* benefit. */
|
||||
float m_slipstream_collect_time; /**< Time after which sstream gives a
|
||||
* bonus. */
|
||||
float m_slipstream_use_time; /**< Time sstream bonus is effective. */
|
||||
float m_slipstream_add_power; /**< Additional power due to sstreaming. */
|
||||
float m_slipstream_min_speed; /**< Minimum speed for slipstream to take
|
||||
* effect. */
|
||||
@ -246,7 +247,9 @@ public:
|
||||
/** Returns how far behind a kart slipstreaming works. */
|
||||
float getSlipstreamLength () const {return m_slipstream_length; }
|
||||
/** Returns time after which slipstream has maximum effect. */
|
||||
float getSlipstreamTime () const {return m_slipstream_time; }
|
||||
float getSlipstreamCollectTime () const {return m_slipstream_collect_time; }
|
||||
/** Returns time after which slipstream has maximum effect. */
|
||||
float getSlipstreamUseTime () const {return m_slipstream_use_time; }
|
||||
/** Returns additional power due to slipstreaming. */
|
||||
float getSlipstreamAddPower () const {return m_slipstream_add_power; }
|
||||
/** Returns the minimum slipstream speed. */
|
||||
|
Loading…
Reference in New Issue
Block a user