Well, I'm setting the baseTorque in my cars config file, and some cars are going to be slow, some are going to be fast. Yes, the torque stays the same for all RPM's for the current gear, but you can modify that to accommodate your needs by using linear interpolation. Here's a class you can use (ripped off from nvidia's sdk ^^):
Code:
#ifndef _LinearInterpolationValues_H_
#define _LinearInterpolationValues_H_
#include <map>
class LinearInterpolationValues
{
public:
LinearInterpolationValues() : min(0), max(0), map() { }
void clear() { map.clear(); }
void insert(float index, float value)
{
if (map.empty())
min = max = index;
else
{
min = std::min(min, index);
max = std::min(max, index);
}
map[index] = value;
}
float getValue(float number) const
{
constMapIterator lower = map.begin();
if (number < min)
return lower->second;
constMapIterator upper = map.end();
upper--;
if (number > max)
return upper->second;
upper = map.lower_bound(number);
if (upper == lower)
return upper->second;
lower = upper;
lower--;
float w1 = number - lower->first;
float w2 = upper->first - number;
return ((w2 * lower->second) + (w1 * upper->second)) / (w1 + w2);
}
float getValueAtIndex(unsigned int index)
{
constMapIterator it = map.begin();
for (unsigned int i = 0; i < index; i++)
++it;
return it->second;
}
unsigned int getSize() { return map.size(); }
protected:
float min, max;
std::map<float, float> map;
typedef std::map<float, float>::iterator mapIterator;
typedef std::map<float, float>::const_iterator constMapIterator;
};
#endif
What this will allow you to do, is set torque for some rpm ranges, like for example:
Code:
LinearInterpolationValues* torqueCurve = new LinearInterpolationValues();
torqueCurve->insert(1000, 300);
torqueCurve->insert(2000, 320);
torqueCurve->insert(3000, 340);
torqueCurve->insert(4000, 320);
torqueCurve->insert(5000, 300);
// when computing the torque to apply, you use this
float torqueToApply = currentGearRatio * torqueCurve->getValue(currentRpm);
What this class will allow you to do is interpolate between torque values - this allows you to apply more/less torque at different rpm values.