]> git.tdb.fi Git - r2c2.git/blob - source/3d/overlay.h
eac51bef810687807ade2e4784108e5d161bf961
[r2c2.git] / source / 3d / overlay.h
1 /* $Id$
2
3 This file is part of the MSP Märklin suite
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef MARKLIN3D_OVERLAY_H_
9 #define MARKLIN3D_OVERLAY_H_
10
11 #include <msp/gbase/window.h>
12 #include <msp/gl/camera.h>
13 #include <msp/gl/font.h>
14 #include <msp/gl/mesh.h>
15 #include <msp/gl/renderable.h>
16
17 namespace Marklin {
18
19 class Object3D;
20
21 class Overlay3D: public Msp::GL::Renderable
22 {
23 private:        
24         struct Icon
25         {
26                 std::vector<const Msp::GL::Mesh *> graphics;
27                 std::string label;
28                 float width;
29                 Msp::GL::Mesh background;
30
31                 Icon();
32         };
33
34         const Msp::Graphics::Window &window;
35         const Msp::GL::Camera &camera;
36         const Msp::GL::Font &font;
37         std::map<std::string, Msp::GL::Mesh *> graphics;
38         std::map<const Object3D *, Icon *> icons;
39
40 public:
41         Overlay3D(const Msp::Graphics::Window &, const Msp::GL::Camera &, const Msp::GL::Font &);
42         ~Overlay3D();
43
44         void set_label(const Object3D &, const std::string &);
45         void add_graphic(const Object3D &, const std::string &);
46         void remove_graphic(const Object3D &, const std::string &);
47         void clear_graphics(const Object3D &);
48         void clear(const Object3D &);
49
50         virtual void render(const Msp::GL::Tag &) const;
51
52 private:
53         Icon &get_icon(const Object3D &);
54         const Msp::GL::Mesh *get_graphic(const std::string &);
55         void update_icon(Icon &);
56 };
57
58 } // namespace Marklin
59
60 #endif