]> git.tdb.fi Git - r2c2.git/blob - source/3d/axle.cpp
Follow the same path until another is significantly better
[r2c2.git] / source / 3d / axle.cpp
1 #include "axle.h"
2 #include "vehicle.h"
3 #include "vehicletype.h"
4
5 using namespace Msp;
6
7 namespace R2C2 {
8
9 Axle3D::Axle3D(const Vehicle3D &v, unsigned a):
10         VehiclePart3D(v, *v.get_type().get_axle_object(a)),
11         bogie(0),
12         axle(vehicle.get_vehicle().get_axle(a))
13 {
14         if(axle.type->bogie)
15                 bogie = &vehicle.get_vehicle().get_bogie(axle.type->bogie->index);
16 }
17
18 void Axle3D::update_matrix()
19 {
20         matrix = vehicle.Object3D::get_matrix();
21
22         if(bogie)
23         {
24                 matrix.translate(bogie->type->position, 0, 0);
25                 matrix.rotate(bogie->direction, 0, 0, 1);
26         }
27
28         matrix.translate(axle.type->local_position, 0, axle.type->wheel_dia/2);
29         matrix.rotate(axle.angle, 0, 1, 0);
30 }
31
32 } // namespace R2C2