RigsofRods
Soft-body Physics Simulation
Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes
RoR::TorqueCurve Class Reference

This class loads and processes a torque curve for a vehicle. More...

#include <TorqueCurve.h>

Public Member Functions

 TorqueCurve ()
 Constructor. More...
 
 ~TorqueCurve ()
 Destructor. More...
 
Ogre::Real getEngineTorque (Ogre::Real rpm)
 Returns the calculated engine torque based on the given RPM, interpolating the torque curve spline. More...
 
int setTorqueModel (Ogre::String name)
 Sets the torque model which is used for the vehicle. More...
 
bool CreateNewCurve (Ogre::String const &name=customModel)
 Creates new torque curve. More...
 
void AddCurveSample (float rpm, float progress, Ogre::String const &model=customModel)
 Adds a point to the torque curve graph. More...
 
Ogre::SimpleSpline * getUsedSpline ()
 Returns the used spline. More...
 
Ogre::String getTorqueModel ()
 Returns the name of the torque model used by the vehicle. More...
 
int spaceCurveEvenly (Ogre::SimpleSpline *spline)
 Spaces the points of a spline evenly; this is needed for the correct calculation of the Ogre simple spline. More...
 

Static Public Attributes

const static Ogre::String customModel = "CustomModel"
 

Protected Member Functions

int loadDefaultTorqueModels ()
 Loads default torque models from the 'torque_models.cfg' file. More...
 
int processLine (Ogre::StringVector args, Ogre::String model)
 Processes the given vector. More...
 

Protected Attributes

Ogre::SimpleSpline * usedSpline
 spline which is used for calculating the torque, set by setTorqueModel(). More...
 
Ogre::String usedModel
 name of the torque model used by the truck. More...
 
std::map< Ogre::String, Ogre::SimpleSpline > splines
 container were all torque curve splines are stored in. More...
 

Detailed Description

This class loads and processes a torque curve for a vehicle.

Definition at line 42 of file TorqueCurve.h.

Constructor & Destructor Documentation

◆ TorqueCurve()

TorqueCurve::TorqueCurve ( )

Constructor.

Definition at line 33 of file TorqueCurve.cpp.

+ Here is the call graph for this function:

◆ ~TorqueCurve()

TorqueCurve::~TorqueCurve ( )

Destructor.

Definition at line 39 of file TorqueCurve.cpp.

Member Function Documentation

◆ AddCurveSample()

void TorqueCurve::AddCurveSample ( float  rpm,
float  progress,
Ogre::String const &  model = customModel 
)

Adds a point to the torque curve graph.

Parameters
progress0 - 1
modelTorque model name (i.e. 'turbodiesel').

Definition at line 151 of file TorqueCurve.cpp.

+ Here is the caller graph for this function:

◆ CreateNewCurve()

bool TorqueCurve::CreateNewCurve ( Ogre::String const &  name = customModel)

Creates new torque curve.

Returns
True if created, false if already existed.

Definition at line 135 of file TorqueCurve.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getEngineTorque()

Real TorqueCurve::getEngineTorque ( Ogre::Real  rpm)

Returns the calculated engine torque based on the given RPM, interpolating the torque curve spline.

Parameters
Thecurrent engine RPM.
Returns
Calculated engine torque.

Definition at line 44 of file TorqueCurve.cpp.

+ Here is the caller graph for this function:

◆ getTorqueModel()

Ogre::String RoR::TorqueCurve::getTorqueModel ( )
inline

Returns the name of the torque model used by the vehicle.

Returns
The name of the torque model used by the vehicle.

Definition at line 87 of file TorqueCurve.h.

◆ getUsedSpline()

Ogre::SimpleSpline* RoR::TorqueCurve::getUsedSpline ( )
inline

Returns the used spline.

Returns
The torque spline used by the vehicle.

Definition at line 81 of file TorqueCurve.h.

+ Here is the caller graph for this function:

◆ loadDefaultTorqueModels()

int TorqueCurve::loadDefaultTorqueModels ( )
protected

Loads default torque models from the 'torque_models.cfg' file.

Returns
0 on success, 1 if 'torque_model.cfg' file not found.

Definition at line 58 of file TorqueCurve.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processLine()

int TorqueCurve::processLine ( Ogre::StringVector  args,
Ogre::String  model 
)
protected

Processes the given vector.

Adds points to a torque curve spline; or if a new model is found, generating a new spline.

Parameters
argsVector of arguments of the line which should be processed.
modelTorque model name (i.e. 'turbodiesel')
Returns
setTorqueModel() called if one argument given, 1 on error, 0 on success

Definition at line 105 of file TorqueCurve.cpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setTorqueModel()

int TorqueCurve::setTorqueModel ( Ogre::String  name)

Sets the torque model which is used for the vehicle.

Parameters
namename of the torque model which should be used.
Returns
0 on success, 1 if torque model is not found.

Definition at line 157 of file TorqueCurve.cpp.

+ Here is the caller graph for this function:

◆ spaceCurveEvenly()

int TorqueCurve::spaceCurveEvenly ( Ogre::SimpleSpline *  spline)

Spaces the points of a spline evenly; this is needed for the correct calculation of the Ogre simple spline.

Parameters
splinePointer to the spline which should be processed.
Returns
0 on success, 1 on error

Definition at line 172 of file TorqueCurve.cpp.

+ Here is the caller graph for this function:

Field Documentation

◆ customModel

const String TorqueCurve::customModel = "CustomModel"
static

Definition at line 45 of file TorqueCurve.h.

◆ splines

std::map<Ogre::String, Ogre::SimpleSpline> RoR::TorqueCurve::splines
protected

container were all torque curve splines are stored in.

Definition at line 115 of file TorqueCurve.h.

◆ usedModel

Ogre::String RoR::TorqueCurve::usedModel
protected

name of the torque model used by the truck.

Definition at line 114 of file TorqueCurve.h.

◆ usedSpline

Ogre::SimpleSpline* RoR::TorqueCurve::usedSpline
protected

spline which is used for calculating the torque, set by setTorqueModel().

Definition at line 113 of file TorqueCurve.h.


The documentation for this class was generated from the following files: