/* $Id$
This file is part of R²C²
-Copyright © 2010 Mikkosoft Productions, Mikko Rasa
+Copyright © 2010-2011 Mikkosoft Productions, Mikko Rasa
Distributed under the GPL
*/
VehicleType::VehicleType(const ArticleNumber &an):
art_nr(an),
locomotive(false),
+ swap_direction(false),
length(0),
width(0),
height(0)
return (--functions.end())->first;
}
+const VehicleType::Axle &VehicleType::get_fixed_axle(unsigned i) const
+{
+ if(i>=axles.size())
+ throw InvalidParameterValue("Axle index out of range");
+ return axles[i];
+}
+
+const VehicleType::Bogie &VehicleType::get_bogie(unsigned i) const
+{
+ if(i>=bogies.size())
+ throw InvalidParameterValue("Axle index out of range");
+ return bogies[i];
+}
+
+const VehicleType::Axle &VehicleType::get_bogie_axle(unsigned i, unsigned j) const
+{
+ if(i>=bogies.size())
+ throw InvalidParameterValue("Axle index out of range");
+ if(j>=bogies[i].axles.size())
+ throw InvalidParameterValue("Axle index out of range");
+ return bogies[i].axles[j];
+}
+
+const VehicleType::Rod &VehicleType::get_rod(unsigned i) const
+{
+ if(i>=rods.size())
+ throw InvalidParameterValue("Rod index out of range");
+ return rods[i];
+}
+
float VehicleType::get_front_axle_offset() const
{
float front = length/2;
add("name", &VehicleType::name);
add("object", &VehicleType::object);
add("rod", &Loader::rod);
+ add("swap_direction", &VehicleType::swap_direction);
add("width", &Loader::width);
}
if(i==tags.end())
throw KeyError("Unknown rod tag", t);
obj.connect_index = i->second;
- obj.connect_point = Point(px/1000, 0, pz/1000);
- obj.connect_offset = Point(ox/1000, 0, oz/1000);
+ obj.connect_point = Vector(px/1000, 0, pz/1000);
+ obj.connect_offset = Vector(ox/1000, 0, oz/1000);
}
void VehicleType::Rod::Loader::pivot_body()
void VehicleType::Rod::Loader::position(float x, float y, float z)
{
- obj.pivot_point = Point(x/1000, y/1000, z/1000);
+ obj.pivot_point = Vector(x/1000, y/1000, z/1000);
}
void VehicleType::Rod::Loader::set_tag(const string &t)