X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=blobdiff_plain;f=src%2Fexman.cc;h=21e00749f7e9a405e3d29649be36f9ebc3b23546;hp=d93c2ff66d95bf5f89f31913a13fd97908e4f4bf;hb=b5ed5107e21ff834d5a4510b9047f976abb03dff;hpb=35c329e4b66fc60622080be1b9ff30148a7e74e4 diff --git a/src/exman.cc b/src/exman.cc index d93c2ff..21e0074 100644 --- a/src/exman.cc +++ b/src/exman.cc @@ -1,3 +1,4 @@ +#include #include #include "exman.h" #include "exhibit.h" @@ -12,6 +13,11 @@ ExhibitManager::ExhibitManager() ExhibitManager::~ExhibitManager() { + clear(); +} + +void ExhibitManager::clear() +{ int num = (int)items.size(); for(int i=0; imatch_node(amatch))) { - error_log("regexp \"%s\" didn't match any nodes\n", amatch ? amatch : ""); + error_log("ExhibitManager::load: regexp \"%s\" didn't match any nodes\n", + amatch ? amatch : ""); continue; } @@ -67,6 +74,25 @@ bool ExhibitManager::load(MetaScene *mscn, const char *fname) continue; } + const char *desc = ts_get_attr_str(node, "description"); + const char *voice = ts_get_attr_str(node, "voiceover"); + if(desc || voice) { + ExData exd; + + if(desc) { + exd.text = std::string(desc); + } + if(voice) { + exd.voice = new OggVorbisStream; + if(!exd.voice->open(voice)) { + error_log("failed to open voiceover: %s\n", voice); + delete exd.voice; + exd.voice = 0; + } + } + ex->data.push_back(exd); + } + ex->set_node(snode); items.push_back(ex); } @@ -76,19 +102,63 @@ bool ExhibitManager::load(MetaScene *mscn, const char *fname) return true; } +ExSelection ExhibitManager::select(const Ray &ray) const +{ + ExSelection nearest; + nearest.dist = FLT_MAX; + + int nitems = items.size(); + for(int i=0; iselect(ray); + if(sel && sel.dist < nearest.dist) { + nearest = sel; + } + } + + return nearest; +} + +ExSelection ExhibitManager::select(const Sphere &sph) const +{ + ExSelection sel; + if(!items.empty()) { + sel.ex = items[0]; + sel.selsphere = sph; + sel.validmask = EXSEL_SPHERE; + } + return sel; // TODO +} + void ExhibitManager::update(float dt) { int num = items.size(); for(int i=0; inode->get_parent()) { + items[i]->node->update(dt); + } items[i]->update(dt); } } +void ExhibitManager::draw() const +{ + int num = items.size(); + for(int i=0; ipre_draw(); + items[i]->draw(); + items[i]->post_draw(); + } +} + static Exhibit *create_exhibit(const char *type) { if(strcmp(type, "static") == 0) { + debug_log("creating static exhibit\n"); return new Exhibit; } else if(strcmp(type, "blobs") == 0) { + debug_log("creating blobs exhibit\n"); return new BlobExhibit; } error_log("unknown exhibit type: %s\n", type);