forgot to add the new files
authorJohn Tsiombikas <nuclear@mutantstargoat.com>
Fri, 24 Feb 2017 09:53:04 +0000 (11:53 +0200)
committerJohn Tsiombikas <nuclear@mutantstargoat.com>
Fri, 24 Feb 2017 09:53:04 +0000 (11:53 +0200)
src/exman.cc [new file with mode: 0644]
src/exman.h [new file with mode: 0644]

diff --git a/src/exman.cc b/src/exman.cc
new file mode 100644 (file)
index 0000000..e0ededc
--- /dev/null
@@ -0,0 +1,42 @@
+#include "exman.h"
+#include "exhibit.h"
+#include "blob_exhibit.h"
+
+static Exhibit *create_exhibit(const char *type);
+
+ExhibitManager::ExhibitManager()
+{
+}
+
+ExhibitManager::~ExhibitManager()
+{
+       int num = (int)items.size();
+       for(int i=0; i<num; i++) {
+               delete items[i];
+       }
+       items.clear();
+}
+
+bool ExhibitManager::load(const MetaScene *mscn, const char *fname)
+{
+       struct ts_node *root = ts_load(fname);
+       if(!root || strcmp(root->name, "exhibits") != 0) {
+               ts_free_tree(root);
+               error_log("failed to load exhibits\n");
+               return false;
+       }
+
+       ts_free_tree(root);
+       return true;
+}
+
+
+static Exhibit *create_exhibit(const char *type)
+{
+       if(strcmp(type, "static") == 0) {
+               return new Exhibit;
+       } else if(strcmp(type, "blobs") == 0) {
+               return new BlobExhibit;
+       }
+       return 0;
+}
diff --git a/src/exman.h b/src/exman.h
new file mode 100644 (file)
index 0000000..5c627e6
--- /dev/null
@@ -0,0 +1,22 @@
+#ifndef EXMAN_H_
+#define EXMAN_H_
+
+#include <vector>
+#include "exhibit.h"
+#include "metascene.h"
+
+class ExhibitManager {
+private:
+       std::vector<Exhibit*> items;
+
+public:
+       ExhibitManager();
+       ~ExhibitManager();
+
+       bool load(const MetaScene *mscn, const char *fname);
+
+       ExSelection select(const Ray &ray) const;
+       ExSelection select(const Sphere &sph) const;
+};
+
+#endif // EXMAN_H_