fixed bounding volume issue
[laserbrain_demo] / src / exhibit.cc
1 #include "exhibit.h"
2 #include "snode.h"
3 #include "scene.h"
4 #include "geomdraw.h"
5
6 class ExhibitPriv {
7 public:
8         Vec3 orig_pos;
9         Quat orig_rot;
10         SceneNode *orig_node;
11
12         ExhibitPriv();
13 };
14
15
16 // selection
17 ExSelection::ExSelection(Exhibit *ex)
18 {
19         this->ex = ex;
20         obj = data = 0;
21         validmask = 0;
22 }
23
24 ExSelection::operator bool() const
25 {
26         return ex != 0;
27 }
28
29 // Exhibit data
30 ExData::ExData()
31 {
32         voice = 0;
33 }
34
35 ExData::~ExData()
36 {
37         delete voice;
38 }
39
40 // private data for each exhibit type
41 ExhibitPriv::ExhibitPriv()
42 {
43         orig_node = 0;
44 }
45
46 // exhibit class
47 Exhibit::Exhibit()
48 {
49         priv = new ExhibitPriv;
50 }
51
52 Exhibit::~Exhibit()
53 {
54         delete priv;
55 }
56
57 void Exhibit::set_node(SceneNode *node)
58 {
59         this->node = priv->orig_node = node;
60         priv->orig_pos = node->get_position();
61         priv->orig_rot = node->get_rotation();
62 }
63
64 ExSelection Exhibit::select(const Ray &ray) const
65 {
66         return ExSelection(0);
67 }
68
69 ExSelection Exhibit::select(const Sphere &sph) const
70 {
71         return ExSelection(0);
72 }
73
74 void Exhibit::update(float dt)
75 {
76 }
77
78 void Exhibit::pre_draw() const
79 {
80         if(node) {
81                 glMatrixMode(GL_MODELVIEW);
82                 glPushMatrix();
83                 glMultMatrixf(node->get_matrix()[0]);
84         }
85 }
86
87 void Exhibit::draw() const
88 {
89 }
90
91 void Exhibit::post_draw() const
92 {
93         if(node) {
94                 glMatrixMode(GL_MODELVIEW);
95                 glPopMatrix();
96
97                 const AABox &bvol = get_aabox();
98                 debug_log("bvol (%g %g %g) -> (%g %g %g)\n", bvol.min.x, bvol.min.y, bvol.min.z,
99                                 bvol.max.x, bvol.max.y, bvol.max.z);
100                 draw_geom_object(&bvol);
101         }
102 }
103
104
105 const AABox &Exhibit::get_aabox() const
106 {
107         aabb = node->get_bounds();
108         return aabb;
109 }