Added support for maximum steering angle to be dependent on

the current speed. I.e. on lower speed narrower turns are possible.



git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/trunk/supertuxkart@2157 178a84e3-b1eb-0310-8ba1-8eac791a3b58
This commit is contained in:
hikerstk 2008-07-11 15:19:07 +00:00
parent f59052157d
commit 5d10d28744
6 changed files with 72 additions and 19 deletions

View File

@ -52,7 +52,12 @@
;; Bullet physics attributes
(brake-factor 2.75 )
(max-steer-angle 6.4 )
;; Defines the (maximum) steering angle at a lowest speed (19 degrees at
;; speed 0) and at high speed (6.4 degrees at speed 12 m/s). Maximum
;; steering angles for speeds in between will be interpolated. This
;; allows for tighter turns at lower speeds
(min-speed-angle 0 19)
(max-speed-angle 12 6.4)
(engine-power 400 )
(mass 225 )
(suspension-stiffness 8.0 )

View File

@ -168,7 +168,8 @@ public:
float getWheelBase () const {return m_kart_properties->getWheelBase();}
float getHeightCOG () const {return m_kart_properties->getHeightCOG();}
float getFrictionSlip () const {return m_kart_properties->getFrictionSlip();}
float getMaxSteerAngle () const {return m_kart_properties->getMaxSteerAngle();}
float getMaxSteerAngle () const
{return m_kart_properties->getMaxSteerAngle(getSpeed());}
float getGravityCenterShift () const
{return m_kart_properties->getGravityCenterShift(); }
float getWheelieMaxSpeedRatio () const
@ -181,8 +182,6 @@ public:
{return m_kart_properties->getWheelieRestoreRate(); }
float getWheelieSpeedBoost() const
{return m_kart_properties->getWheelieSpeedBoost(); }
float getSteerAngle () const
{return m_controls.lr*m_kart_properties->getMaxSteerAngle(); }
float getSteerPercent () const {return m_controls.lr; }
float getMaxSpeed () const {return m_max_speed; }
void setTimeAtLap (float t){m_time_at_last_lap=t; }

View File

@ -151,7 +151,37 @@ void KartProperties::getAllData(const lisp::Lisp* lisp)
lisp->get("time-full-steer", m_time_full_steer);
lisp->get("brake-factor", m_brake_factor);
lisp->get("mass", m_mass);
lisp->get("max-steer-angle", m_max_steer_angle);
std::vector<float> v;
if(lisp->getVector("max-speed-angle", v))
{
if(v.size()!=2)
printf("Incorrect max-speed-angle specifications for kart %'s'\n",
getIdent());
else
{
m_max_speed_turn = v[0];
m_angle_at_max = v[1];
}
}
v.clear();
if(lisp->getVector("min-speed-angle", v))
{
if(v.size()!=2)
printf("Incorrect min-speed-angle specifications for kart %'s'\n",
getIdent());
else
{
m_min_speed_turn = v[0];
m_angle_at_min = v[1];
}
}
if(m_max_speed_turn == m_min_speed_turn)
m_speed_angle_increase = 0.0;
else
m_speed_angle_increase = (m_angle_at_min - m_angle_at_max)
/ (m_max_speed_turn - m_min_speed_turn);
lisp->get("wheelie-max-speed-ratio", m_wheelie_max_speed_ratio );
lisp->get("wheelie-max-pitch", m_wheelie_max_pitch );
lisp->get("wheelie-pitch-rate", m_wheelie_pitch_rate );
@ -217,7 +247,6 @@ void KartProperties::init_defaults()
m_time_full_steer = stk_config->m_time_full_steer;
m_brake_factor = stk_config->m_brake_factor;
m_mass = stk_config->m_mass;
m_max_steer_angle = stk_config->m_max_steer_angle;
m_wheelie_max_speed_ratio = stk_config->m_wheelie_max_speed_ratio;
m_wheelie_max_pitch = stk_config->m_wheelie_max_pitch;
m_wheelie_pitch_rate = stk_config->m_wheelie_pitch_rate;
@ -248,6 +277,19 @@ void KartProperties::init_defaults()
m_camera_max_accel = stk_config->getCameraMaxAccel();
m_camera_max_brake = stk_config->getCameraMaxBrake();
m_camera_distance = stk_config->getCameraDistance();
m_min_speed_turn = stk_config->m_min_speed_turn;
m_angle_at_min = stk_config->m_angle_at_min;
m_max_speed_turn = stk_config->m_max_speed_turn;
m_angle_at_max = stk_config->m_angle_at_max;
} // init_defaults
// ----------------------------------------------------------------------------
float KartProperties::getMaxSteerAngle(float speed) const
{
if(speed<=m_min_speed_turn) return m_angle_at_min;
if(speed>=m_max_speed_turn) return m_angle_at_max;
return m_angle_at_min - speed*m_speed_angle_increase;
} // getMaxSteerAngle
/* EOF */

View File

@ -60,7 +60,6 @@ protected:
float m_height_cog; // height of center of gravity
float m_engine_power; // maximum force from engine
float m_brake_factor; // braking factor * engine_power = braking force
float m_max_steer_angle; // maximum steering angle
float m_time_full_steer; // time for player karts to reach full steer angle
float m_wheelie_max_speed_ratio; // percentage of maximum speed for wheelies
float m_wheelie_max_pitch; // maximum pitch for wheelies
@ -69,6 +68,10 @@ protected:
float m_wheelie_speed_boost; // speed boost while doing a wheelie
float m_wheelie_power_boost; // increase in engine power
float m_min_speed_turn, m_angle_at_min; // speed dependent steering: max
float m_max_speed_turn, m_angle_at_max; // turn angle at lowest speed etc
float m_speed_angle_increase;
// bullet physics data
// -------------------
float m_suspension_stiffness;
@ -114,6 +117,7 @@ public:
const std::string node="tuxkart-kart",
bool dont_load_models=false,
bool dont_load_materials=false);
float getMaxSteerAngle (float speed) const;
Material* getIconMaterial () const {return m_icon_material; }
ssgEntity* getModel () const {return m_model; }
@ -133,7 +137,6 @@ public:
float getBrakeFactor () const {return m_brake_factor; }
float getWheelBase () const {return m_wheel_base; }
float getHeightCOG () const {return m_height_cog; }
float getMaxSteerAngle () const {return m_max_steer_angle; }
float getMaxSpeedReverseRatio () const {return m_max_speed_reverse_ratio; }
float getWheelieMaxSpeedRatio () const {return m_wheelie_max_speed_ratio; }
float getWheelieMaxPitch () const {return m_wheelie_max_pitch; }

View File

@ -85,9 +85,9 @@ void KartPropertiesManager::loadKartData(bool dont_load_models)
KartProperties* kp = new KartProperties();
kp->load(kart_file, "tuxkart-kart", dont_load_models);
m_karts_properties.push_back(kp);
if(kp->getMaxSteerAngle() > m_max_steer_angle)
if(kp->getMaxSteerAngle(0) > m_max_steer_angle)
{
m_max_steer_angle = kp->getMaxSteerAngle();
m_max_steer_angle = kp->getMaxSteerAngle(0);
}
const std::vector<std::string>& groups=kp->getGroups();
for(unsigned int g=0; g<groups.size(); g++)

View File

@ -74,7 +74,10 @@ void STKConfig::load(const std::string filename)
CHECK_NEG(m_height_cog, "heightCOG" );
CHECK_NEG(m_wheel_base, "wheel-base" );
CHECK_NEG(m_engine_power, "engine-power" );
CHECK_NEG(m_max_steer_angle, "max-steer-angle" );
CHECK_NEG(m_min_speed_turn, "min-speed-angle" );
CHECK_NEG(m_angle_at_min, "min-speed-angle" );
CHECK_NEG(m_max_speed_turn, "max-speed-angle" );
CHECK_NEG(m_angle_at_max, "max-speed-angle" );
CHECK_NEG(m_brake_factor, "brake-factor" );
CHECK_NEG(m_wheelie_max_speed_ratio, "wheelie-max-speed-ratio" );
@ -132,7 +135,8 @@ void STKConfig::load(const std::string filename)
*/
void STKConfig::init_defaults()
{
m_wheel_base = m_height_cog = m_mass = m_max_steer_angle =
m_wheel_base = m_height_cog = m_mass =
m_min_speed_turn = m_angle_at_min = m_max_speed_turn = m_angle_at_max =
m_anvil_weight = m_parachute_friction =
m_parachute_time = m_parachute_done_fraction = m_parachute_time_other =
m_engine_power = m_brake_factor =