--- /dev/null
+/* $Id$
+
+This file is part of the MSP Märklin suite
+Copyright © 2010 Mikkosoft Productions, Mikko Rasa
+Distributed under the GPL
+*/
+
+#include <msp/gl/meshbuilder.h>
+#include <msp/gl/vector.h>
+#include "vehicletype.h"
+
+using namespace Msp;
+
+namespace Marklin {
+
+VehicleType3D::VehicleType3D(Catalogue3D &, const VehicleType &vt):
+ body_mesh((GL::NORMAL3, GL::VERTEX3))
+{
+ GL::Vector3 corner(vt.get_length()/2, vt.get_width()/2, vt.get_height());
+
+ GL::MeshBuilder bld(body_mesh);
+ bld.begin(GL::QUADS);
+ bld.normal(1, 0, 0);
+ bld.vertex(corner.x, -corner.y, 0);
+ bld.vertex(corner.x, corner.y, 0);
+ bld.vertex(corner.x, corner.y, corner.z);
+ bld.vertex(corner.x, -corner.y, corner.z);
+ bld.normal(-1, 0, 0);
+ bld.vertex(-corner.x, corner.y, 0);
+ bld.vertex(-corner.x, -corner.y, 0);
+ bld.vertex(-corner.x, -corner.y, corner.z);
+ bld.vertex(-corner.x, corner.y, corner.z);
+ bld.normal(0, 1, 0);
+ bld.vertex(corner.x, corner.y, 0);
+ bld.vertex(-corner.x, corner.y, 0);
+ bld.vertex(-corner.x, corner.y, corner.z);
+ bld.vertex(corner.x, corner.y, corner.z);
+ bld.normal(0, -1, 0);
+ bld.vertex(-corner.x, -corner.y, 0);
+ bld.vertex(corner.x, -corner.y, 0);
+ bld.vertex(corner.x, -corner.y, corner.z);
+ bld.vertex(-corner.x, -corner.y, corner.z);
+ bld.normal(0, 0, 1);
+ bld.vertex(-corner.x, -corner.y, corner.z);
+ bld.vertex(corner.x, -corner.y, corner.z);
+ bld.vertex(corner.x, corner.y, corner.z);
+ bld.vertex(-corner.x, corner.y, corner.z);
+ bld.end();
+}
+
+} // namespace Marklin