ExhibitSlots and exhibit placement (initial)
[laserbrain_demo] / src / exman.h
1 #ifndef EXMAN_H_
2 #define EXMAN_H_
3
4 #include <vector>
5 #include "exhibit.h"
6 #include "metascene.h"
7
8 //! argument to ExhibitSlot::attach
9 enum ExSlotAttachMode {
10         EXSLOT_ATTACH_PERMANENT,
11         EXSLOT_ATTACH_TRANSIENT
12 };
13
14 //! slot which can hold a single exhibit
15 class ExhibitSlot {
16 private:
17         Exhibit *ex;
18
19 public:
20         SceneNode node;
21
22         ExhibitSlot(Exhibit *ex = 0);
23         ~ExhibitSlot();
24
25         void init(Exhibit *ex);
26
27         bool empty() const;
28         Exhibit *get_exhibit() const;
29
30         bool attach_exhibit(Exhibit *ex, ExSlotAttachMode mode = EXSLOT_ATTACH_PERMANENT);
31         bool detach_exhibit();
32 };
33
34
35 class ExhibitManager {
36 private:
37         std::vector<Exhibit*> items, stashed;
38         std::vector<ExhibitSlot*> exslots;
39         // TODO kdtree of slots for quick nearest queries
40
41 public:
42         ExhibitManager();
43         ~ExhibitManager();
44
45         void clear();
46
47         void add(Exhibit *ex);
48         bool remove(Exhibit *ex);
49
50         bool load(MetaScene *mscn, const char *fname);
51
52         ExSelection select(const Ray &ray) const;
53         ExSelection select(const Sphere &sph) const;
54
55         ExhibitSlot *nearest_empty_slot(const Vec3 &pos, float max_dist = 10) const;
56
57         void stash_exhibit(Exhibit *ex);
58
59         void update(float dt = 0.0f);
60         void draw() const;
61 };
62
63 #endif  // EXMAN_H_