2e818540258c98c52774c0f0ff6cd007f2037a96
[laserbrain_demo] / src / exhibit.cc
1 #include "exhibit.h"
2 #include "snode.h"
3 #include "scene.h"
4
5 ExSelection ExSelection::null;
6
7
8 // selection
9 ExSelection::ExSelection(Exhibit *ex)
10 {
11         this->ex = ex;
12         obj = data = 0;
13         validmask = 0;
14 }
15
16 ExSelection::operator bool() const
17 {
18         return ex != 0;
19 }
20
21 // Exhibit data
22 ExData::ExData()
23 {
24         voice = 0;
25 }
26
27 ExData::~ExData()
28 {
29         delete voice;
30 }
31
32 // exhibit class
33 Exhibit::Exhibit()
34 {
35         orig_parent = 0;
36         prev_slot = 0;
37 }
38
39 Exhibit::~Exhibit()
40 {
41 }
42
43 void Exhibit::set_node(SceneNode *node)
44 {
45         this->node = node;
46         orig_parent = node->get_parent();
47 }
48
49 ExSelection Exhibit::select(const Ray &ray) const
50 {
51         ExSelection sel;
52         HitPoint hit;
53         if(get_aabox().intersect(ray, &hit)) {
54                 sel.ex = (Exhibit*)this;
55                 sel.selray = ray;
56                 sel.dist = hit.dist;
57                 sel.validmask = EXSEL_RAY;
58         }
59         return sel;
60 }
61
62 ExSelection Exhibit::select(const Sphere &sph) const
63 {
64         return ExSelection(0);  // TODO
65 }
66
67 void Exhibit::update(float dt)
68 {
69 }
70
71 const AABox &Exhibit::get_aabox() const
72 {
73         aabb = node->get_bounds();
74         return aabb;
75 }