exhibit drawing is now handled by the Renderer
[laserbrain_demo] / src / exhibit.cc
index 8653343..2e81854 100644 (file)
@@ -1,41 +1,75 @@
 #include "exhibit.h"
 #include "snode.h"
+#include "scene.h"
 
-Exhibit::Exhibit()
+ExSelection ExSelection::null;
+
+
+// selection
+ExSelection::ExSelection(Exhibit *ex)
 {
+       this->ex = ex;
+       obj = data = 0;
+       validmask = 0;
 }
 
-void *Exhibit::select(const Ray &ray) const
+ExSelection::operator bool() const
 {
-       return 0;       // TODO
+       return ex != 0;
 }
 
-void *Exhibit::select(const Sphere &sph) const
+// Exhibit data
+ExData::ExData()
 {
-       return 0;       // TODO
+       voice = 0;
 }
 
-void Exhibit::update(float dt)
+ExData::~ExData()
+{
+       delete voice;
+}
+
+// exhibit class
+Exhibit::Exhibit()
 {
+       orig_parent = 0;
+       prev_slot = 0;
 }
 
-void Exhibit::pre_draw() const
+Exhibit::~Exhibit()
 {
-       if(node) {
-               glMatrixMode(GL_MODELVIEW);
-               glPushMatrix();
-               glMultMatrixf(node->get_matrix()[0]);
-       }
 }
 
-void Exhibit::draw() const
+void Exhibit::set_node(SceneNode *node)
 {
+       this->node = node;
+       orig_parent = node->get_parent();
 }
 
-void Exhibit::post_draw() const
+ExSelection Exhibit::select(const Ray &ray) const
 {
-       if(node) {
-               glMatrixMode(GL_MODELVIEW);
-               glPopMatrix();
+       ExSelection sel;
+       HitPoint hit;
+       if(get_aabox().intersect(ray, &hit)) {
+               sel.ex = (Exhibit*)this;
+               sel.selray = ray;
+               sel.dist = hit.dist;
+               sel.validmask = EXSEL_RAY;
        }
+       return sel;
+}
+
+ExSelection Exhibit::select(const Sphere &sph) const
+{
+       return ExSelection(0);  // TODO
+}
+
+void Exhibit::update(float dt)
+{
+}
+
+const AABox &Exhibit::get_aabox() const
+{
+       aabb = node->get_bounds();
+       return aabb;
 }