RigsofRods
Soft-body Physics Simulation
TorqueCurve.h
Go to the documentation of this file.
1 /*
2  This source file is part of Rigs of Rods
3  Copyright 2005-2012 Pierre-Michel Ricordel
4  Copyright 2007-2012 Thomas Fischer
5 
6  For more information, see http://www.rigsofrods.org/
7 
8  Rigs of Rods is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License version 3, as
10  published by the Free Software Foundation.
11 
12  Rigs of Rods is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 #pragma once
22 
23 #include "Application.h"
24 
30 
31 namespace RoR {
32 
35 
38 
43 {
44 public:
45  const static Ogre::String customModel;
46 
47  TorqueCurve();
48  ~TorqueCurve();
49 
55  Ogre::Real getEngineTorque(Ogre::Real rpm);
56 
62  int setTorqueModel(Ogre::String name);
63 
68  bool CreateNewCurve(Ogre::String const& name = customModel);
69 
75  void AddCurveSample(float rpm, float progress, Ogre::String const& model = customModel);
76 
81  Ogre::SimpleSpline* getUsedSpline() { return usedSpline; };
82 
87  Ogre::String getTorqueModel() { return usedModel; };
88 
94  int spaceCurveEvenly(Ogre::SimpleSpline* spline);
95 
96 protected:
97 
103 
111  int processLine(Ogre::StringVector args, Ogre::String model);
112 
113  Ogre::SimpleSpline* usedSpline;
114  Ogre::String usedModel;
115  std::map<Ogre::String, Ogre::SimpleSpline> splines;
116 };
117 
120 
121 } // namespace RoR
RoR::TorqueCurve::loadDefaultTorqueModels
int loadDefaultTorqueModels()
Loads default torque models from the 'torque_models.cfg' file.
Definition: TorqueCurve.cpp:58
RoR::TorqueCurve::spaceCurveEvenly
int spaceCurveEvenly(Ogre::SimpleSpline *spline)
Spaces the points of a spline evenly; this is needed for the correct calculation of the Ogre simple s...
Definition: TorqueCurve.cpp:172
RoR::TorqueCurve::getUsedSpline
Ogre::SimpleSpline * getUsedSpline()
Returns the used spline.
Definition: TorqueCurve.h:81
RoR::TorqueCurve::AddCurveSample
void AddCurveSample(float rpm, float progress, Ogre::String const &model=customModel)
Adds a point to the torque curve graph.
Definition: TorqueCurve.cpp:151
RoR::TorqueCurve::usedModel
Ogre::String usedModel
name of the torque model used by the truck.
Definition: TorqueCurve.h:114
RoR::TorqueCurve
This class loads and processes a torque curve for a vehicle.
Definition: TorqueCurve.h:42
RoR::TorqueCurve::TorqueCurve
TorqueCurve()
Constructor.
Definition: TorqueCurve.cpp:33
RoR::TorqueCurve::usedSpline
Ogre::SimpleSpline * usedSpline
spline which is used for calculating the torque, set by setTorqueModel().
Definition: TorqueCurve.h:113
RoR::TorqueCurve::customModel
const static Ogre::String customModel
Definition: TorqueCurve.h:45
RoR::TorqueCurve::getTorqueModel
Ogre::String getTorqueModel()
Returns the name of the torque model used by the vehicle.
Definition: TorqueCurve.h:87
RoR::TorqueCurve::~TorqueCurve
~TorqueCurve()
Destructor.
Definition: TorqueCurve.cpp:39
RoR::TorqueCurve::setTorqueModel
int setTorqueModel(Ogre::String name)
Sets the torque model which is used for the vehicle.
Definition: TorqueCurve.cpp:157
RoR::TorqueCurve::processLine
int processLine(Ogre::StringVector args, Ogre::String model)
Processes the given vector.
Definition: TorqueCurve.cpp:105
Application.h
Central state/object manager and communications hub.
RoR::TorqueCurve::CreateNewCurve
bool CreateNewCurve(Ogre::String const &name=customModel)
Creates new torque curve.
Definition: TorqueCurve.cpp:135
RoR::TorqueCurve::getEngineTorque
Ogre::Real getEngineTorque(Ogre::Real rpm)
Returns the calculated engine torque based on the given RPM, interpolating the torque curve spline.
Definition: TorqueCurve.cpp:44
RoR::TorqueCurve::splines
std::map< Ogre::String, Ogre::SimpleSpline > splines
container were all torque curve splines are stored in.
Definition: TorqueCurve.h:115
RoR
Definition: AppContext.h:36