#include "boundary.h" boundary::boundary() { filename=""; } boundary::boundary(string file,float vol) { openFile(file); sound.setVolume(vol); } boundary::~boundary() { } void boundary::draw(){ if (points.size()>1) { for (int i=0;i0) { points.erase(points.end()-1); getCentroid(); } } void boundary::getCentroid(){ float y=0; float maxx=-1; float minx=100000; for (int i=0;i min(p1.y,p2.y)) { if (p.y <= max(p1.y,p2.y)) { if (p.x <= max(p1.x,p2.x)) { if (p1.y != p2.y) { xinters = (p.y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x; if (p1.x == p2.x || p.x <= xinters) counter++; } } } } p1 = p2; } if (counter % 2 == 0) return false; else return true; } int boundary::findPoint(ofPoint pos){ int threshold=6; int selected=-1; for (int i=0;i0) { if (sound.loadSound(filename)) sound.setLoop(false); else printf("failed to load %s\n",filename.c_str()); } } bool boundary::checkFile(ofPoint pos,string file) { if (contains(pos)) { sound.stop(); openFile(file); return true; } else return false; } bool boundary::checkClick(ofPoint pos){ if (contains(pos)&&sound.isLoaded()&&!sound.getIsPlaying()) { sound.play(); return true; } else return false; } void boundary::setVolume(float vol){ sound.setVolume(vol); }