Back to index

supertuxkart  0.5+dfsg1
kart_properties.hpp
Go to the documentation of this file.
00001 //  $Id: kart_properties.hpp 2111 2008-05-31 07:04:30Z cosmosninja $
00002 //
00003 //  SuperTuxKart - a fun racing game with go-kart
00004 //  Copyright (C) 2006 SuperTuxKart-Team
00005 //
00006 //  This program is free software; you can redistribute it and/or
00007 //  modify it under the terms of the GNU General Public License
00008 //  as published by the Free Software Foundation; either version 2
00009 //  of the License, or (at your option) any later version.
00010 //
00011 //  This program is distributed in the hope that it will be useful,
00012 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //  GNU General Public License for more details.
00015 //
00016 //  You should have received a copy of the GNU General Public License
00017 //  along with this program; if not, write to the Free Software
00018 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 
00020 #ifndef HEADER_KARTPROPERTIES_H
00021 #define HEADER_KARTPROPERTIES_H
00022 
00023 #include <string>
00024 #include <vector>
00025 #include "lisp/lisp.hpp"
00026 #include "no_copy.hpp"
00027 
00028 class Material;
00029 class ssgEntity;
00030 
00031 class KartProperties : public NoCopy
00032 {
00033 private:
00034 
00035     Material* m_icon_material;
00036     ssgEntity* m_model;
00037 
00038 protected:
00039     // Display and gui
00040     // --------------- 
00041     std::string m_name;         // The human readable Name of the karts driver
00042     std::string m_ident;        // The computer readable-name of the karts driver
00043     std::string m_model_file;   // Filename of 3d model that is used for kart
00044     std::string m_icon_file;    // Filename of icon that represents the kart in
00045                                 // the statusbar and the character select screen
00046     std::string m_shadow_file;  // Filename of the image file that contains the
00047                                 // shadow for this kart
00048     float m_color[3];           // Color the represents the kart in the status
00049                                 // bar and on the track-view
00050 
00051     // Physic properties
00052     // -----------------
00053     float m_kart_width;               // width of kart
00054     float m_kart_length;              // length of kart
00055     float m_kart_height;              // height of kart
00056     float m_mass;                     // weight of kart
00057     float m_wheel_base;               // distance between front and read wheels
00058     float m_height_cog;               // height of center of gravity
00059     float m_engine_power;             // maximum force from engine
00060     float m_brake_factor;             // braking factor * engine_power = braking force
00061     float m_max_steer_angle;          // maximum steering angle
00062     float m_time_full_steer;          // time for player karts to reach full steer angle
00063     float m_wheelie_max_speed_ratio;  // percentage of maximum speed for wheelies
00064     float m_wheelie_max_pitch;        // maximum pitch for wheelies
00065     float m_wheelie_pitch_rate;       // rate/sec with which kart goes up
00066     float m_wheelie_restore_rate;     // rate/sec with which kart does down
00067     float m_wheelie_speed_boost;      // speed boost while doing a wheelie
00068     float m_wheelie_lean_recovery;
00069     float m_wheelie_balance_recovery;
00070     float m_wheelie_step;
00071     float m_wheelie_power_boost;      // increase in engine power
00072 
00073     // bullet physics data 
00074     // -------------------
00075     float m_suspension_stiffness;
00076     float m_wheel_damping_relaxation;
00077     float m_wheel_damping_compression;
00078     float m_friction_slip;
00079     float m_roll_influence;
00080     float m_wheel_radius;
00081     float m_wheel_width;
00082     float m_chassis_linear_damping;
00083     float m_chassis_angular_damping;
00084     float m_maximum_speed;
00085     float m_max_speed_reverse_ratio;
00086     float m_gravity_center_shift;
00087     float m_suspension_rest;
00088     float m_jump_velocity;            // z velocity set when jumping
00089     float m_upright_tolerance;
00090     float m_upright_max_force;
00091 
00092     // Camera related setting
00093     // ----------------------
00094     float m_camera_max_accel;         // maximum acceleration of camera
00095     float m_camera_max_brake;         // maximum braking of camera
00096     float m_camera_distance;          // distance of normal camera from kart
00097     //
00098     // The following two vectors define at what ratio of the maximum speed what
00099     // gear is selected, e.g. 0.25 means: if speed <=0.25*maxSpeed --> gear 1,
00100     //                        0.5  means: if speed <=0.5 *maxSpeed --> gear 2
00101     // The next vector contains the increase in max power (to simulate different
00102     // gears), e.g. 2.5 as first entry means: 2.5*maxPower in gear 1
00103     std::vector<float> m_gear_switch_ratio;
00104     std::vector<float> m_gear_power_increase;
00105 
00106 
00107 public:
00108     KartProperties   ();
00109     virtual      ~KartProperties   ();
00110 
00111     virtual void  init_defaults    ();
00112     virtual void  getAllData       (const lisp::Lisp* lisp);
00113     virtual void  load             (const std::string filename,
00114                                     const std::string node="tuxkart-kart",
00115                                     bool dont_load_models=false,
00116                                     bool dont_load_materials=false);
00117 
00118     Material*     getIconMaterial        () const {return m_icon_material;          }
00119     ssgEntity*    getModel               () const {return m_model;                  }
00120     const std::string& getName           () const {return m_name;                   }
00121     const char*   getIdent               () const {return m_ident.c_str();          }
00122     const char*   getShadowFile          () const {return m_shadow_file.c_str();    }
00123     const char*   getIconFile            () const {return m_icon_file.c_str();      }
00124     const sgVec3* getColor               () const {return &m_color;                 }
00125     float         getMass                () const {return m_mass;                   }
00126     float         getKartLength          () const {return m_kart_length;            }
00127     float         getKartWidth           () const {return m_kart_width;             }
00128     float         getKartHeight          () const {return m_kart_height;            }
00129     float         getMaxPower            () const {return m_engine_power;           }
00130     float         getTimeFullSteer       () const {return m_time_full_steer;        }
00131     float         getBrakeFactor         () const {return m_brake_factor;           }
00132     float         getWheelBase           () const {return m_wheel_base;             }
00133     float         getHeightCOG           () const {return m_height_cog;             }
00134     float         getMaxSteerAngle       () const {return m_max_steer_angle;        }
00135     float         getMaxSpeedReverseRatio() const {return m_max_speed_reverse_ratio;}
00136     float         getWheelieMaxSpeedRatio() const {return m_wheelie_max_speed_ratio;}
00137     float         getWheelieMaxPitch     () const {return m_wheelie_max_pitch;      }
00138     float         getWheeliePitchRate    () const {return m_wheelie_pitch_rate;     }
00139     float         getWheelieRestoreRate  () const {return m_wheelie_restore_rate;   }
00140     float         getWheelieSpeedBoost   () const {return m_wheelie_speed_boost;    }
00141     float         getWheelieLeanRecovery () const {return m_wheelie_lean_recovery;  }
00142     float         getWheelieBalanceRecovery()const{return m_wheelie_balance_recovery;}
00143     float         getWheelieStep         () const {return m_wheelie_step;           }
00144     float         getWheeliePowerBoost   () const {return m_wheelie_power_boost;    }
00145 
00146     //bullet physics get functions
00147     float getSuspensionStiffness    () const {return m_suspension_stiffness;     }
00148     float getWheelDampingRelaxation () const {return m_wheel_damping_relaxation; }
00149     float getWheelDampingCompression() const {return m_wheel_damping_compression;}
00150     float getFrictionSlip           () const {return m_friction_slip;            }
00151     float getRollInfluence          () const {return m_roll_influence;           }
00152     float getWheelRadius            () const {return m_wheel_radius;             }
00153     float getWheelWidth             () const {return m_wheel_width;              }
00154     float getChassisLinearDamping   () const {return m_chassis_linear_damping;   }
00155     float getChassisAngularDamping  () const {return m_chassis_angular_damping;  }
00156     float getMaximumSpeed           () const {return m_maximum_speed;            }
00157     float getGravityCenterShift     () const {return m_gravity_center_shift;     }
00158     float getSuspensionRest         () const {return m_suspension_rest;          }
00159     float getJumpVelocity           () const {return m_jump_velocity;            }
00160     float getUprightTolerance       () const {return m_upright_tolerance;        }
00161     float getUprightMaxForce        () const {return m_upright_max_force;        }
00162     const std::vector<float>& 
00163           getGearSwitchRatio        () const {return m_gear_switch_ratio;        }
00164     const std::vector<float>& 
00165           getGearPowerIncrease      () const {return m_gear_power_increase;      }
00166     float getCameraMaxAccel         () const {return m_camera_max_accel;         }
00167     float getCameraMaxBrake         () const {return m_camera_max_brake;         }
00168     float getCameraDistance         () const {return m_camera_distance;          }
00169 };
00170 
00171 #endif
00172 
00173 /* EOF */