1) The number of drivelines per kart is now limited (stk_config.data setting)

2) Reduced smoke effect somewhat (and made it dependent on actually turning
   the wheel)
3) Removed skid marks when restarting a race.


git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2576 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-12-08 01:07:16 +00:00
parent bf18cd156b
commit e76c1dc87c
7 changed files with 67 additions and 40 deletions

View File

@ -13,6 +13,7 @@
(menu-background "st_title_screen.rgb")
(game-style "nitro") ;; "wheelie" or "nitro"
(max-history 10000) ;; maximum number of history frames.
(max-skidmarks 100) ;; max. number of skidmarks per kart.
(delay-finish-time 10) ;; delay till race results are displayed.
(music-credit-time 10) ;; time for which the music credits are displayed.

View File

@ -27,33 +27,42 @@
/** Initialises empty skid marks. */
SkidMarks::SkidMarks(const Kart& kart, float width) : m_kart(kart)
{
m_width = width;
m_skid_state = new ssgSimpleState();
m_width = width;
m_skid_state = new ssgSimpleState();
m_skid_state->ref();
m_skid_state->enable(GL_BLEND);
//This is just for the skidmarks, so the ones drawn when the kart is in
//reverse get drawn
// m_skid_state -> disable (GL_CULL_FACE);
m_skid_marking = false;
m_current = -1;
} // SkidMark
//-----------------------------------------------------------------------------
/** Removes all skid marks from the scene graph and frees the state. */
SkidMarks::~SkidMarks()
{
#ifdef NOTYET
if(!m_skid_marks.empty())
{
const unsigned int SIZE = (unsigned int)m_skid_marks.size() -1;
for(unsigned int i = 0; i < SIZE; ++i)
{
ssgDeRefDelete(m_skid_marks[i]);
} // for
} // if !empty
reset(); // remove all skid marks
ssgDeRefDelete(m_skid_state);
#endif
} // ~SkidMarks
//-----------------------------------------------------------------------------
/** Removes all skid marks, called when a race is restarted.
*/
void SkidMarks::reset()
{
for(unsigned int i=0; i<m_left.size(); i++)
{
scene->remove(m_left[i]);
scene->remove(m_right[i]);
}
m_left.clear();
m_right.clear();
m_skid_marking = false;
} // reset
//-----------------------------------------------------------------------------
/** Either adds to an existing skid mark quad, or (if the kart is skidding)
* starts a new skid mark quad.
* \param dt Time step.
*/
void SkidMarks::update(float dt)
{
if(m_skid_marking)
@ -66,8 +75,6 @@ void SkidMarks::update(float dt)
m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo;
Vec3 delta = raycast_right.m_contactPointWS - raycast_left.m_contactPointWS;
int current=m_left.size()-1;
// We were skid marking, but not anymore (either because the
// wheels don't touch the ground, or the kart has stopped
// skidding). One special case: the physics force both wheels
@ -80,8 +87,8 @@ void SkidMarks::update(float dt)
delta.length2()<0.0001)
{
m_skid_marking = false;
m_left[current]->makeDList();
m_right[current]->makeDList();
m_left[m_current]->makeDList();
m_right[m_current]->makeDList();
return;
}
@ -91,10 +98,10 @@ void SkidMarks::update(float dt)
delta.normalize();
delta *= m_width;
m_left [current]->add(raycast_left.m_contactPointWS,
raycast_left.m_contactPointWS + delta);
m_right[current]->add(raycast_right.m_contactPointWS-delta,
raycast_right.m_contactPointWS);
m_left [m_current]->add(raycast_left.m_contactPointWS,
raycast_left.m_contactPointWS + delta);
m_right[m_current]->add(raycast_right.m_contactPointWS-delta,
raycast_right.m_contactPointWS);
return;
}
@ -108,6 +115,7 @@ void SkidMarks::update(float dt)
m_kart.getVehicle()->getWheelInfo(2).m_raycastInfo;
// No skidmarking if wheels don't have contact
if(!raycast_right.m_isInContact) return;
const btWheelInfo::RaycastInfo raycast_left =
m_kart.getVehicle()->getWheelInfo(3).m_raycastInfo;
@ -123,13 +131,28 @@ void SkidMarks::update(float dt)
raycast_left.m_contactPointWS + delta,
m_skid_state);
scene->add(smq_left);
m_left.push_back(smq_left);
SkidMarkQuads *smq_right = new SkidMarkQuads(raycast_right.m_contactPointWS
- delta,
raycast_right.m_contactPointWS,
m_skid_state);
scene->add(smq_right);
m_right.push_back(smq_right);
m_current++;
if(m_current>=stk_config->m_max_skidmarks)
m_current = 0;
if(m_current>=(int)m_left.size())
{
m_left. push_back(smq_left );
m_right.push_back(smq_right);
}
else
{
scene->remove(m_left [m_current]);
scene->remove(m_right[m_current]);
m_left [m_current] = smq_left;
m_right[m_current] = smq_right;
}
m_skid_marking = true;
} // update
@ -148,10 +171,6 @@ SkidMarks::SkidMarkQuads::SkidMarkQuads(const Vec3 &left, const Vec3 &right,
} // SkidMarkQuads
//-----------------------------------------------------------------------------
SkidMarks::SkidMarkQuads::~SkidMarkQuads()
{} // ~SkidMarkPos
//-----------------------------------------------------------------------------
void SkidMarks::SkidMarkQuads::recalcBSphere()
{

View File

@ -39,30 +39,29 @@ private:
bool m_skid_marking;
/** Reduce effect of Z-fighting. */
float m_width;
/** Index of current (last added) skid mark quad. */
int m_current;
class SkidMarkQuads : public ssgVtxTable
{
public:
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
ssgSimpleState *state);
~SkidMarkQuads();
SkidMarkQuads (const Vec3 &left, const Vec3 &right,
ssgSimpleState *state);
void recalcBSphere();
void add (const Vec3 &left,
const Vec3 &right);
private:
float m_track_offset; // Amount of which the skidmark is lifted
// above the track to avoid z-buffer errors
}; // SkidMarkQuads
/** Two skidmark objects for the left and right wheel. */
std::vector <SkidMarkQuads *> m_left, m_right;
ssgSimpleState *m_skid_state;
/** The state for colour etc. */
ssgSimpleState *m_skid_state;
public:
SkidMarks(const Kart& kart, float width=0.2f);
~SkidMarks();
void update (float dt);
void reset();
}; // SkidMarks
#endif

View File

@ -71,7 +71,7 @@ void Smoke::particle_create(int, Particle *p)
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;
p->m_time_to_live = 0.4f;
// Change from left to right wheel and back for each new particle
static int wheel_number = 2;

View File

@ -342,6 +342,7 @@ void Kart::reset()
m_vehicle->applyEngineForce (0.0f, 3);
Moveable::reset();
m_skidmarks->reset();
for(int j=0; j<m_vehicle->getNumWheels(); j++)
{
m_vehicle->updateWheelTransform(j, true);
@ -887,7 +888,7 @@ void Kart::endRescue()
} // endRescue
//-----------------------------------------------------------------------------
#include <scene.hpp>
void Kart::loadData()
{
float r [ 2 ] = { -10.0f, 100.0f } ;
@ -959,7 +960,10 @@ void Kart::updateGraphics(const Vec3& off_xyz, const Vec3& off_hpr)
const float offset_pitch = DEGREE_TO_RAD(m_wheelie_angle);
if(m_smoke_system)
m_smoke_system->setCreationRate((m_skidding-1)*100.0f);
{
float f = fabsf(m_controls.lr) > 0.8 ? 50.0f : 0.0f;
m_smoke_system->setCreationRate((m_skidding-1)*f);
}
if(m_nitro)
m_nitro->setCreationRate(m_controls.wheelie && m_collected_energy>0
? getSpeed()*5.0f : 0);

View File

@ -106,6 +106,7 @@ void STKConfig::load(const std::string &filename)
CHECK_NEG(m_explosion_impulse, "explosion-impulse" );
CHECK_NEG(m_explosion_impulse_objects, "explosion-impulse-objects" );
CHECK_NEG(m_max_history, "max-history" );
CHECK_NEG(m_max_skidmarks, "max-skidmarks" );
CHECK_NEG(m_delay_finish_time, "delay-finish-time" );
CHECK_NEG(m_music_credit_time, "music-credit-time" );
m_kart_properties.checkAllSet(filename);
@ -131,6 +132,7 @@ void STKConfig::init_defaults()
m_max_karts = -100;
m_grid_order = -100;
m_max_history = -100;
m_max_skidmarks = -100;
m_title_music = NULL;
m_game_style = GS_WHEELIE;
m_scores.clear();
@ -166,6 +168,7 @@ void STKConfig::getAllData(const lisp::Lisp* lisp)
lisp->get("grid-order", m_grid_order );
lisp->getVector("scores", m_scores );
lisp->get("max-history", m_max_history );
lisp->get("max-skidmarks", m_max_skidmarks );
lisp->get("delay-finish-time", m_delay_finish_time );
lisp->get("music-credit-time", m_music_credit_time );
lisp->get("menu-background", m_menu_background );

View File

@ -67,6 +67,7 @@ public:
or reverse point order. */
int m_max_history; /**<Maximum number of frames to save in
a history files. */
int m_max_skidmarks; /**<Maximum number of skid marks/kart. */
/** Gaming style: in wheelie, karts can do wheelies, collected coins
* increase the number of items you get. With nitro, collected coins
* can be used as a speed boost (nitro), but no wheelies are possible.