1 #include <msp/gl/box.h>
2 #include <msp/gl/meshbuilder.h>
3 #include <msp/gl/renderer.h>
4 #include <msp/gl/technique.h>
5 #include "libr2c2/vehicletype.h"
6 #include "placementghost.h"
11 PlacementGhost::PlacementGhost(Layout3D &a, const VehicleType &t):
15 mesh(new GL::Mesh((GL::VERTEX3, GL::NORMAL3))),
16 object(new GL::Object(mesh, &layout.get_catalogue().get<GL::Technique>("ghost.technique")))
18 GL::MeshBuilder bld(*mesh);
19 float l = type.get_length();
20 float w = type.get_width();
21 float h = type.get_height();
22 GL::BoxBuilder(GL::Vector3(-l/2, -w/2, 0), GL::Vector3(l, w, h)).build(bld);
24 layout.get_scene().add(*this);
27 PlacementGhost::~PlacementGhost()
29 layout.get_scene().remove(*this);
35 void PlacementGhost::place(const TrackOffsetIter &track)
37 placement.place(track, VehiclePlacement::BACK_BUFFER);
40 void PlacementGhost::place_before(const PlacementGhost &other)
42 placement.place_before(other.placement);
45 void PlacementGhost::render(GL::Renderer &renderer, const GL::Tag &tag) const
47 if(!object->get_technique()->has_pass(tag))
50 GL::Renderer::Push push(renderer);
52 OrientedPoint point = placement.get_point();
54 matrix.translate(point.position);
55 matrix.rotate(point.rotation, 0, 0, 1);
56 renderer.matrix_stack() *= matrix;
58 object->render(renderer, tag);