Having problems :s

Langhole

09-05-2007 18:06:29

Hi,

I originally posted this in the main forum, but was told to move it here. I'll just clarify now that this is a vector problem, not an OgreNewt specific problem, I apologize if i'm posting in the wrong area still.

I'm trying to implement a gearbox into my OgreNewt vehicle, using 2 vectors to hold the torque curve, and gear ratio.


struct TorquePoint {

Ogre::Real rpm;
Ogre::Real torque;

}

std::vector<Ogre::Real> mGears;
std::vector<TorquePoint> mTorqueCurve;


They are created fine, but when I loop through n gears, and push_back the rpm, torque, and ratio for that gear. The problem then is, they don't seem to want to store the values... I'm confused as to why, and I've been looking for possible ways to work around it, like:


Ogre::Real aRPM[5];
Ogre::Real aTorque[5];
Ogre::Real mGears[5];

// is this even possible for what I'm doing? instead of std::vector<_Ty>?? //


So far, all I get is a crash, and it breaks when trying to get a value for the current gear ratio.

I'm stuck, if there's any help out there, I'd appreciate a bit

Thx.

Game_Ender

09-05-2007 18:14:06

If you don't want it to change you can just do:
Ogre::Real aRPM[] = {1, 200.2, 2000.2, 40123.1};
Ogre::Real aTorque[] = {3.4, 5.6,10.0};
Ogre::Real mGears[] = {1.2, 3.4, 5.6};


I suggest you post a complete code example that crahes.

Langhole

09-05-2007 18:30:15

Ah,

Yeah, hard-coding the values was going to be my last resort solution, as I'd like to have dynamic gearbox settings, so I can load different vehicles, using an external config.

I will do that later, I suppose, as I only have one vehicle so far. If I run into more trouble, I will be sure to post the code.

Thanks for the help :)

pra

09-05-2007 21:40:14

They are created fine, but when I loop through n gears, and push_back the rpm, torque, and ratio for that gear. The problem then is, they don't seem to want to store the values...
could you post the code that does this?

perhaps this helps you:
http://www.codeguru.com/cpp/cpp/cpp_mfc ... php/c4027/
std::vector<double> a;
std::vector<double>::const_iterator i;
a.push_back(1);
a.push_back(2);
a.push_back(3);
a.push_back(4);
a.push_back(5);
for(i=a.begin(); i!=a.end(); ++i){
std::cout<<(*i)<<std::endl;
}