1
// $Id: physics_parameters.cpp 714 2006-09-01 06:59:39Z hiker $
3
// SuperTuxKart - a fun racing game with go-kart
4
// Copyright (C) 2006 Joerg Henrichs
6
// This program is free software; you can redistribute it and/or
7
// modify it under the terms of the GNU General Public License
8
// as published by the Free Software Foundation; either version 2
9
// of the License, or (at your option) any later version.
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
16
// You should have received a copy of the GNU General Public License
17
// along with this program; if not, write to the Free Software
18
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include "physics_parameters.hpp"
22
PhysicsParameters* physicsParameters=0;
24
// -----------------------------------------------------------------------------
25
void PhysicsParameters::load(const char* filename, char *node) {
27
KartProperties::load(filename, node);
29
// Check that all necessary values are indeed set physics.data file
32
#define CHECK_NEG( a,strA) if(a<-99) { \
33
fprintf(stderr,"Missing default value for '%s' in '%s'.\n", \
34
strA,filename);exit(-1); \
37
CHECK_NEG(corn_r, "corn_r" );CHECK_NEG(wheel_base, "wheel-base" );
38
CHECK_NEG(heightCOG,"heightCOG");CHECK_NEG(engine_power, "engine-power" );
39
CHECK_NEG(mass, "mass" );CHECK_NEG(air_resistance, "air-resistance" );
40
CHECK_NEG(tire_grip,"tire-grip");CHECK_NEG(max_steer_angle,"max-steer-angle");
41
CHECK_NEG(corn_f, "corn_f" );CHECK_NEG(roll_resistance,"roll-resistance");
42
CHECK_NEG(inertia, "inertia" );CHECK_NEG(magnetRangeSQ, "magnet-range" );
43
CHECK_NEG(brake_factor, "brake-factor" );
44
CHECK_NEG(jumpImpulse, "jump-impulse" );
45
CHECK_NEG(airResReduce[1], "reduce-air-resistance-driver");
46
CHECK_NEG(airResReduce[2], "reduce-air-resistance-racer" );
47
CHECK_NEG(wheelieMaxSpeedRatio,"wheelie-max-speed-ratio");
48
CHECK_NEG(wheelieMaxPitch, "wheelie-max-pitch" );
49
CHECK_NEG(wheeliePitchRate, "wheelie-pitch-rate" );
50
CHECK_NEG(wheelieRestoreRate, "wheelie-restore-rate" );
51
CHECK_NEG(wheelieSpeedBoost, "wheelie-speed-boost" );
52
CHECK_NEG(magnetMinRangeSQ, "magnet-min-range" );
53
CHECK_NEG(parachuteFriction, "parachute-friction" );
54
CHECK_NEG(time_full_steer, "time-full-steer" );
56
// Precompute some handy values to reduce work later
57
magnetRangeSQ = magnetRangeSQ *magnetRangeSQ;
58
magnetMinRangeSQ = magnetMinRangeSQ*magnetMinRangeSQ;
61
// -----------------------------------------------------------------------------
62
// Init all values with invalid defaults, which are tested later. This
63
// guarantees that all parameters will indeed be initialised, and helps
65
void PhysicsParameters::init_defaults() {
66
wheel_base = heightCOG = magnetMinRangeSQ = roll_resistance =
68
air_resistance = tire_grip = max_steer_angle = corn_f =
69
inertia = anvilWeight = parachuteFriction = engine_power =
70
magnetRangeSQ = jumpImpulse = brake_factor = anvilSpeedFactor=
71
time_full_steer = wheelieMaxPitch = wheelieMaxSpeedRatio =
72
wheeliePitchRate = wheelieRestoreRate= wheelieSpeedBoost = airResReduce[2] =
73
airResReduce[1] = -99.9;
74
airResReduce[0] = 1.0;
77
// -----------------------------------------------------------------------------
78
void PhysicsParameters::getAllData(const lisp::Lisp* lisp) {
80
// Get the values which are not part of the default KartProperties
81
// ---------------------------------------------------------------
82
lisp->get("anvil-weight", anvilWeight );
83
lisp->get("anvil-speed-factor", anvilSpeedFactor );
84
lisp->get("parachute-friction", parachuteFriction );
85
lisp->get("magnet-range", magnetRangeSQ );
86
lisp->get("magnet-min-range", magnetMinRangeSQ );
87
lisp->get("jump-impulse", jumpImpulse );
88
lisp->get("reduce-air-resistance-racer", airResReduce[2] );
89
lisp->get("reduce-air-resistance-driver", airResReduce[1] );
91
// Get the default KartProperties
92
// ------------------------------
93
KartProperties::getAllData(lisp->getLisp("kart-defaults"));