4 #include "blob_exhibit.h"
7 static Exhibit *create_exhibit(const char *type);
9 ExhibitManager::ExhibitManager()
13 ExhibitManager::~ExhibitManager()
18 void ExhibitManager::clear()
20 int num = (int)items.size();
21 for(int i=0; i<num; i++) {
27 void ExhibitManager::add(Exhibit *ex)
29 std::vector<Exhibit*>::iterator it = std::find(items.begin(), items.end(), ex);
30 if(it == items.end()) {
35 bool ExhibitManager::remove(Exhibit *ex)
37 std::vector<Exhibit*>::iterator it = std::find(items.begin(), items.end(), ex);
38 if(it != items.end()) {
45 bool ExhibitManager::load(MetaScene *mscn, const char *fname)
47 struct ts_node *root = ts_load(fname);
48 if(!root || strcmp(root->name, "exhibits") != 0) {
50 error_log("failed to load exhibits\n");
54 struct ts_node *iter = root->child_list;
56 struct ts_node *node = iter;
59 if(strcmp(node->name, "item") == 0) {
62 const char *amatch = ts_get_attr_str(node, "match_node");
63 if(!amatch || !(snode = mscn->match_node(amatch))) {
64 error_log("ExhibitManager::load: regexp \"%s\" didn't match any nodes\n",
65 amatch ? amatch : "");
70 const char *atype = ts_get_attr_str(node, "type");
71 if(!atype || !(ex = create_exhibit(atype))) {
72 error_log("failed to create exhibit of type: %s\n", atype);
85 ExSelection ExhibitManager::select(const Ray &ray) const
87 return ExSelection(); // TODO
90 ExSelection ExhibitManager::select(const Sphere &sph) const
92 return ExSelection(); // TODO
95 void ExhibitManager::update(float dt)
97 int num = items.size();
98 for(int i=0; i<num; i++) {
103 void ExhibitManager::draw() const
105 int num = items.size();
106 for(int i=0; i<num; i++) {
107 items[i]->pre_draw();
109 items[i]->post_draw();
113 static Exhibit *create_exhibit(const char *type)
115 if(strcmp(type, "static") == 0) {
116 debug_log("creating static exhibit\n");
118 } else if(strcmp(type, "blobs") == 0) {
119 debug_log("creating blobs exhibit\n");
120 return new BlobExhibit;
122 error_log("unknown exhibit type: %s\n", type);