void ofxPolylineLoad(ofPolyline & poly, string xmlPath) {
    ofXml xml;
    bool bLoaded = xml.load(xmlPath);
    if(bLoaded == false) {
        return;
    }
    
    xml.setTo("poly");
    bool bClosed = ofToInt(xml.getAttribute("closed"));
    
    poly.clear();
    
    int numOfPoints = xml.getNumChildren();
    for(int i=0; i<numOfPoints; i++) {
        xml.setToChild(i);
        float x = ofToFloat(xml.getAttribute("x"));
        float y = ofToFloat(xml.getAttribute("y"));
        
        poly.addVertex(x, y);
    }
    
    if(bClosed == true) {
        poly.close();
    }
}
Ejemplo n.º 2
0
//--------------------------------------------------------------
void drawWithNormals(const ofPolyline& polyline, int zeroX, int zeroY,
		bool drawContours) {
	for (int i = 0; i < (int) polyline.size(); i++) {
		bool repeatNext = i == (int) polyline.size() - 1;

		const ofPoint& cur = polyline[i];
		const ofPoint& next = repeatNext ? polyline[0] : polyline[i + 1];

		float angle = atan2f(next.y - cur.y, next.x - cur.x) * RAD_TO_DEG;
		float distance = cur.distance(next);

		if (repeatNext) {
			ofSetColor(255, 0, 255);
		}
		glPushMatrix();
		glTranslatef(cur.x + zeroX, cur.y + zeroY, 0);
		ofRotate(angle);
//		ofLine(0, 0, 0, distance);
		ofLine(0, 0, distance, 0);
		ofLine(0, distance, distance, distance);
		if (drawContours) {
			for (int i = distance; i < distance * 3; i += 5) {
				ofLine(0, 0, i, 0);
				ofLine(0, i, i, i);
			}
		}
		glPopMatrix();
	}
}
Ejemplo n.º 3
0
ofPolyline ofGetSmoothed(const ofPolyline& polyline, int smoothingSize, float smoothingShape) {
	ofPolyline result = polyline;
	
	if(!polyline.getClosed()) {
		ofLog( OF_LOG_ERROR, "ofSmooth() currently only supports closed ofPolylines." );
		return polyline;
	}
	
	// precompute weights and normalization
	vector<float> weights;
	float weightSum = 0;
	weights.push_back(1); // center weight
	// side weights
	for(int i = 1; i <= smoothingSize; i++) {
		float curWeight = ofMap(i, 0, smoothingSize, 1, smoothingShape);
		weights.push_back(curWeight);
		weightSum += curWeight;
	}
	float weightNormalization = 1 / (1 + 2 * weightSum);
	
	// use weights to make weighted averages of neighbors
	int n = polyline.size();
	for(int i = 0; i < n; i++) {
		for(int j = 1; j <= smoothingSize; j++) {
			int leftPosition = (n + i - j) % n;
			int rightPosition = (i + j) % n;
			const ofPoint& left = polyline[leftPosition];
			const ofPoint& right = polyline[rightPosition];
			result[i] += (left + right) * weights[j];
		}
		result[i] *= weightNormalization;
	}
	
	return result;
}
Ejemplo n.º 4
0
void testApp::renderOutlinesToFBO(ofPolyline& leftEye, ofPolyline& rightEye, ofPolyline& faceOutline){
    outputFbo.begin();
    ofClear(0,0,0,0);
    
    ofPushStyle();
    
    //ofEnableAlphaBlending();
    ofEnableBlendMode(OF_BLENDMODE_ADD);
    
    ofSetColor(0,0,255,255);
    ofBeginShape();
    ofVertices(faceOutline.getVertices());
    ofEndShape();
    
    ofSetColor(255,0,0,255);
    ofBeginShape();
    ofVertices(leftEye.getVertices());
    ofEndShape();
    
    ofSetColor(255,0,0,255);
    ofBeginShape();
    ofVertices(rightEye.getVertices());
    ofEndShape();
    
    ofPopStyle();
    
    outputFbo.end();
}
Ejemplo n.º 5
0
void contourToConvexHull(ofPolyline &src, ofPolyline &dst) {

    dst.clear();

    vector<hPoint> P(src.size());
    for(int i = 0; i < src.size(); i++) {
        P[i].x = src[i].x;
        P[i].y = src[i].y;
    }

    int n = src.size(), k = 0;
    vector<hPoint> H(2*n);

    // Sort points lexicographically
    sort(P.begin(), P.end());

    // Build lower hull
    for (int i = 0; i < n; i++) {
        while (k >= 2 && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
        H[k++] = P[i];
    }

    // Build upper hull
    for (int i = n-2, t = k+1; i >= 0; i--) {
        while (k >= t && cross(H[k-2], H[k-1], P[i]) <= 0) k--;
        H[k++] = P[i];
    }

    H.resize(k);

    for(int i = 0; i < H.size(); i++) {
        dst.addVertex(H[i].x + 500, H[i].y);
    }
}
Ejemplo n.º 6
0
void ofxPolyline2Mesh::updateShape(const ofPolyline &polyline)
{
	shape.clear();
	norm.clear();

	for (int i = 0; i < polyline.size(); i++)
	{
		shape.push_back(polyline[i]);
	}

	if (polyline.isClosed())
		shape.push_back(polyline[0]);

	const ofVec3f V(0, 0, -1);

	for (int i = 0; i < shape.size() - 1; i++)
	{
		const ofVec3f& p1 = shape[i];
		const ofVec3f& p2 = shape[i + 1];
		const ofVec3f& n21 = (p2 - p1).normalized();

		norm.push_back(n21.crossed(V));
	}

	{
		const ofVec3f& p1 = shape[shape.size() - 1];
		const ofVec3f& p2 = shape[0];
		const ofVec3f& n21 = (p2 - p1).normalized();

		norm.push_back(n21.crossed(V));
	}

	current_segments.resize(shape.size());
	last_segments.resize(shape.size());
}
Ejemplo n.º 7
0
ofPolyline ofGetResampledSpacing(const ofPolyline& polyline, float spacing) {
	ofPolyline result;
	// if more properties are added to ofPolyline, we need to copy them here
	result.setClosed(polyline.getClosed());

	float totalLength = 0;
	int curStep = 0;
	int lastPosition = polyline.size() - 1;
	if(polyline.getClosed()) {
		lastPosition++;
	}
	for(int i = 0; i < lastPosition; i++) {
		bool repeatNext = i == (int) (polyline.size() - 1);
	
		const ofPoint& cur = polyline[i];
		const ofPoint& next = repeatNext ? polyline[0] : polyline[i + 1];
		ofPoint diff = next - cur;
		
		float curSegmentLength = diff.length();
		totalLength += curSegmentLength;
		
		while(curStep * spacing <= totalLength) {
			float curSample = curStep * spacing;
			float curLength = curSample - (totalLength - curSegmentLength);
			float relativeSample = curLength / curSegmentLength;
			result.addVertex(cur.getInterpolated(next, relativeSample));
			curStep++;
		}
	}
	
	return result;
}
Ejemplo n.º 8
0
void testApp::oscSendContour(int label, const ofPolyline &polyline){
    ofxOscMessage m;
    stringstream ss;
    ss<<"/contour";
    m.setAddress(ss.str());
    
    int size = polyline.size();
    m.addIntArg(label);
    m.addIntArg(size);
    cout<<"contour: "<<label<<" size: "<<size<<endl;
    const ofRectangle& rect = polyline.getBoundingBox();
    m.addIntArg(rect.getTopLeft().x);
    m.addIntArg(rect.getTopLeft().y);
    m.addIntArg(rect.getBottomRight().x);
    m.addIntArg(rect.getBottomRight().y);
    ofPolyline newLine = polyline.getResampledByCount(100);
    cout<<"resized to "<<newLine.size()<<endl;
//    newLine.draw();
    
    if(bSendContours){
        const vector<ofPoint> points = newLine.getVertices();
        for(int i=0; i< newLine.size(); i++){
            m.addFloatArg(points[i].x);
            m.addFloatArg(points[i].y);
        }
    }
    sender.sendMessage(m);
}
Ejemplo n.º 9
0
	vector<cv::Point2f> toCv(const ofPolyline& polyline) {
		vector<cv::Point2f> contour(polyline.size());
		for(int i = 0; i < polyline.size(); i++) {
			contour[i].x = polyline[i].x;
			contour[i].y = polyline[i].y;
		}
		return contour;		
	}
Ejemplo n.º 10
0
void phdGimbal2d::getKeyPoints(ofPolyline & _keys) {
	_keys.clear();
	_keys.addVertex( 1.00, 0.0);
	_keys.addVertex( 0.75, 0.0);
	_keys.addVertex( 0.00, 0.0);
	_keys.addVertex( 0.00,-1.0);
	getTransformedPolyline(_keys, _keys, getOTSMatrix());
}
Ejemplo n.º 11
0
void LaserManager::addLaserPolyline(const ofPolyline& line, ColourSystem* coloursystem, float intens){
	
	if((line.getVertices().size()==0)||(line.getPerimeter()<0.1)) return;
	
	shapes.push_back(new LaserPolyline(line, coloursystem, intens));
	
	
}
Ejemplo n.º 12
0
void update()
{
    // Update our little offset thingy.
    offset += 0.01;

    if (offset > 1) 
    {
        offset = 0;   
    }
    
    // Update our camera.
    grabber.update();
    
    // If the camera has a new frame to offer us ...
    if (grabber.isFrameNew())
    {
        // Make a copy of our grabber pixels in the colorImage.
        colorImage.setFromPixels(grabber.getPixelsRef());

        // When we assign a color image to a grayscale image, it is converted automatically.
        grayscaleImage = colorImage;
		
	    // If we set learnBackground to true using the keyboard, we'll take a snapshot of 
	    // the background and use it to create a clean foreground image.
		if (learnBackground == true)
		{
		    // We assign the grayscaleImage to the grayscaleBackgroundImage.
			grayscaleBackgroundImage = grayscaleImage;	
			
			// Now we set learnBakground so we won't set a background unless
			// explicitly directed to with a keyboard command.
			learnBackground = false;
		}

        // Create a difference image by comparing the background and the current grayscale images.
		grayscaleAbsoluteDifference.absDiff(grayscaleBackgroundImage, grayscaleImage);

        // Assign grayscaleAbsoluteDifference to the grayscaleBinary image.
        grayscaleBinary = grayscaleAbsoluteDifference;
        
        // Then threshold the grayscale image to create a binary image.
        grayscaleBinary.threshold(threshold, invert);

        // Find contours (blobs) that are between the size of 20 pixels and 
        // 1 / 3 * (width * height) of the camera. Also find holes.
		contourFinder.findContours(grayscaleBinary, 100, (width * height) / 3.0, 10, true);

        // Get the biggest blob and use it to draw.
        if (contourFinder.nBlobs > 0)
        {
            holePositions.addVertex(contourFinder.blobs[0].boundingRect.getCenter());
        }
        else 
        {
		   holePositions.clear(); 
        }
    }
}
Ejemplo n.º 13
0
//--------------------------------------------------------------
void testApp::newPath() {
  path.clear();
  // A path is a series of connected points
  // A more sophisticated path might be a curve
  path.addVertex(0, ofGetHeight()/2);
  path.addVertex(ofRandom(0, ofGetWidth()/2), ofRandom(0, ofGetHeight()));
  path.addVertex(ofRandom(ofGetWidth()/2, ofGetWidth()), ofRandom(0, ofGetHeight()));
  path.addVertex(ofGetWidth(), ofGetHeight()/2);
}
Ejemplo n.º 14
0
	vector<cv::Point2f> toCv(const ofPolyline& polyline) {
		// if polyline.getVertices() were const, this could wrap toCv(vec<vec2f>)
		vector<cv::Point2f> contour(polyline.size());
		for(int i = 0; i < polyline.size(); i++) {
			contour[i].x = polyline[i].x;
			contour[i].y = polyline[i].y;
		}
		return contour;		
	}
Ejemplo n.º 15
0
void ofCairoRenderer::draw(ofPolyline & poly){
	cairo_new_path(cr);
	for(int i=0;i<(int)poly.size();i++){
		cairo_line_to(cr,poly.getVertices()[i].x,poly.getVertices()[i].y);
	}
	if(poly.isClosed())
		cairo_close_path(cr);
	cairo_stroke( cr );
}
Ejemplo n.º 16
0
// Backported from oF-dev branch on github
float ShapeUtils::polylineArea(const ofPolyline &poly) {
    if (poly.size() < 2) return 0;

    float area = 0;
    for (int i = 0; i < (int) poly.size() - 1; i++) {
        area += poly[i].x * poly[i+1].y - poly[i+1].x * poly[i].y;
    }
    area += poly[poly.size()-1].x * poly[0].y - poly[0].x * poly[poly.size()-1].y;
    return 0.5 * area;
}
void AnimatedShadow::insertHole( ofPolyline &holeContourLine ){
    if (shapes.size() > 0){
        holeContourLine.setClosed(true);    
        holeContourLine.simplify(1);
        
        int lastFrame = shapes.size()-1;
        shapes[lastFrame].hole = holeContourLine.getSmoothed(1,1);
        shapes[lastFrame].haveHole = true;
    }
}
Ejemplo n.º 18
0
void testApp::update(){
    ofSetWindowTitle(ofToString(ofGetFrameRate()));
    mesh.clear();
    for (int i = 0; i < balls.size(); i++) {
        balls[i].update();
	float z = 0;
	ofPoint sp = ofPoint(balls[i].getPos().x, balls[i].getPos().y, z);
	mesh.curveTo(sp*1.0);
    }
}
Ejemplo n.º 19
0
//----------------------------------------------------------
void ofGLRenderer::draw(ofPolyline & poly){
	// use smoothness, if requested:
	if (bSmoothHinted) startSmoothing();

	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, sizeof(ofVec3f), &poly.getVertices()[0].x);
	glDrawArrays(poly.isClosed()?GL_LINE_LOOP:GL_LINE_STRIP, 0, poly.size());

	// use smoothness, if requested:
	if (bSmoothHinted) endSmoothing();
}
Ejemplo n.º 20
0
bool operator==(const ofPolyline& lhs, const ofPolyline& rhs)
{
    vector<ofPoint> vertices1 = lhs.getVertices();
    vector<ofPoint> vertices2 = rhs.getVertices();
    if(vertices1.size() != vertices2.size()) return false;
    else {
        for(int i = 0; i < vertices1.size(); i++) {
            if(vertices1[i] != vertices2[i]) return false;
        }
    }
    return true;
}
Ejemplo n.º 21
0
void ropeMesh::draw(ofPolyline stroke){

    if (stroke.hasChanged()) {
        
        mesh.clear();
        
        mesh.setMode(OF_PRIMITIVE_TRIANGLE_STRIP);
        
        vector < ofPoint > pts = stroke.getVertices();
        
        for (int i = 0; i < pts.size(); i++){
            
            int i_m_1 = MAX(i-1,0);
            int i_p_1 = MIN(i+1, pts.size()-1);
            
            ofPoint pta = pts[i_m_1];
            ofPoint ptb = pts[i];
            ofPoint ptc = pts[i_p_1];
            
            ofPoint diff = ptc - pta;
            
            float angle = atan2(diff.y, diff.x);
            
            angle += PI/2;
            
            float width = 3; //diff.length();
            
            ofPoint offsetA;
            offsetA.x = ptb.x + width * cos(angle);
            offsetA.y = ptb.y + width * sin(angle);
            
            ofPoint offsetB;
            offsetB.x = ptb.x - width * cos(angle);
            offsetB.y = ptb.y - width * sin(angle);
            
            ofSetColor(123,94,65);
          
            ofLine(offsetA, offsetB);
            
            mesh.addVertex(offsetA);
            mesh.addVertex(offsetB);
        }
    
        ofSetColor(197,155,108);
        ofFill();
        mesh.draw();
        ofSetRectMode(OF_RECTMODE_CENTER);
        if (stroke.size()>0) {
             top[num].draw(stroke.getVertices()[stroke.size()-1], width, height);
        }
    }
    
}
Ejemplo n.º 22
0
void bezierSplinePoints(ofPolyline pnts, int count, int segments, ofPolyline & points) {
    double mu, mudelta;
    int x1, y1, x2, y2, n, h;
    ofVec2f pha, phb;

    if(count < 4 || count > 16383) return;

    // Phantom Points
    pha = ofVec2f(2.0*pnts[0].x-pnts[1].x, 2.0*pnts[0].y-pnts[1].y);
    phb = ofVec2f(2.0*pnts[count-1].x-pnts[count-2].x, 2.0*pnts[count-1].y-pnts[count-2].y);

    mudelta = 1.0 / segments;

    for(n = 2; n < count; n++) {

        mu = 0;

        if(n == 2) {
            x1 = Calculate(mu,pha.x,pnts[n-2].x,pnts[n-1].x,pnts[n].x);
            y1 = Calculate(mu,pha.y,pnts[n-2].y,pnts[n-1].y,pnts[n].y);
        } else if(n == count) {
            x1 = Calculate(mu,pnts[n-3].x,pnts[n-2].x,pnts[n-1].x,phb.x);
            y1 = Calculate(mu,pnts[n-3].y,pnts[n-2].y,pnts[n-1].y,phb.y);
        } else {
            x1 = Calculate(mu,pnts[n-3].x,pnts[n-2].x,pnts[n-1].x,pnts[n].x);
            y1 = Calculate(mu,pnts[n-3].y,pnts[n-2].y,pnts[n-1].y,pnts[n].y);
        }

        points.addVertex(x1, y1);

        mu = mu + mudelta;

        for(h = 1; h < segments; h++) {

            if(n == 2) {
                x2 = Calculate(mu,pha.x,pnts[n-2].x,pnts[n-1].x,pnts[n].x);
                y2 = Calculate(mu,pha.y,pnts[n-2].y,pnts[n-1].y,pnts[n].y);
            } else if(n == count) {
                x2 = Calculate(mu,pnts[n-3].x,pnts[n-2].x,pnts[n-1].x,phb.x);
                y2 = Calculate(mu,pnts[n-3].y,pnts[n-2].y,pnts[n-1].y,phb.y);
            } else {
                x2 = Calculate(mu,pnts[n-3].x,pnts[n-2].x,pnts[n-1].x,pnts[n].x);
                y2 = Calculate(mu,pnts[n-3].y,pnts[n-2].y,pnts[n-1].y,pnts[n].y);
            }

            points.addVertex(x2, y2);

            mu = mu + mudelta;
        }
    }
}
Ejemplo n.º 23
0
// Backported from oF-dev branch on github
ofPoint ShapeUtils::getCentroid2D(const ofPolyline &poly) {
    ofPoint centroid;
    for(int i=0;i<(int)poly.size()-1;i++){
        centroid.x += (poly[i].x + poly[i+1].x) * (poly[i].x*poly[i+1].y - poly[i+1].x*poly[i].y);
        centroid.y += (poly[i].y + poly[i+1].y) * (poly[i].x*poly[i+1].y - poly[i+1].x*poly[i].y);
    }
    centroid.x += (poly[poly.size()-1].x + poly[0].x) * (poly[poly.size()-1].x*poly[0].y - poly[0].x*poly[poly.size()-1].y);
    centroid.y += (poly[poly.size()-1].y + poly[0].y) * (poly[poly.size()-1].x*poly[0].y - poly[0].x*poly[poly.size()-1].y);

    float area = ShapeUtils::polylineArea(poly);
    centroid.x /= (6*area);
    centroid.y /= (6*area);
    return centroid;
}
Ejemplo n.º 24
0
//--------------------------------------------------------------
void ofxFatLine::setFromPolyline(ofPolyline & poly){
//	ofxFatLine();
	setGlobalColor(ofGetStyle().color);
	setGlobalWidth(ofGetStyle().lineWidth);
	if (!poly.getVertices().empty()){
		addVertices(poly.getVertices());
	for (int i = 0; i <getVertices().size(); i++) {
		addColor(globalColor);
		addWeight(globalWidth);
	}
	update();
	//*/
	}		
}
Ejemplo n.º 25
0
// Backported from oF-dev branch on github
bool ShapeUtils::inside(const ofPolyline &polyline, float x, float y) {
    int counter = 0;
    int i;
    double xinters;
    ofPoint p1,p2;

    int N = polyline.size();
    if (N == 0) {
        return false;
    }

    p1 = polyline[0];
    for (i=1;i<=N;i++) {
        p2 = polyline[i % N];
        if (y > MIN(p1.y,p2.y)) {
            if (y <= MAX(p1.y,p2.y)) {
                if (x <= MAX(p1.x,p2.x)) {
                    if (p1.y != p2.y) {
                        xinters = (y-p1.y)*(p2.x-p1.x)/(p2.y-p1.y)+p1.x;
                        if (p1.x == p2.x || x <= xinters)
                            counter++;
                    }
                }
            }
        }
        p1 = p2;
    }

    if (counter % 2 == 0) return false;
    else return true;
}
Ejemplo n.º 26
0
bool ShapeUtils::isRectangle(const ofPolyline &poly, float angle) {
    if (poly.size() != 4) {
       return false;
    }

    float delta = cos((90 - angle) * PI / 180);

    // Make sure it's a rectangle
    ofVec2f top    = ofVec2f(poly[1].x - poly[0].x, poly[1].y - poly[0].y);
    ofVec2f right  = ofVec2f(poly[2].x - poly[1].x, poly[2].y - poly[1].y);
    ofVec2f bottom = ofVec2f(poly[3].x - poly[2].x, poly[3].y - poly[2].y);
    ofVec2f left   = ofVec2f(poly[0].x - poly[3].x, poly[0].y - poly[3].y);

    top.normalize();
    right.normalize();
    bottom.normalize();
    left.normalize();

    bool isRect = abs(top.dot(right))    < delta
               && abs(right.dot(bottom)) < delta
               && abs(bottom.dot(left))  < delta
               && abs(left.dot(top))     < delta;

    return isRect;
}
Ejemplo n.º 27
0
void scanner_faces::draw_featEnMarco(ofPolyline feat, int gap, bool uu, bool rr) {
	
	ofRectangle featRect;
	featRect = feat.getBoundingBox();
	featRect.x-=gap;
	featRect.y-=gap;
	featRect.width+=2*gap;
	featRect.height+=2*gap;
	
	ofSetLineWidth(1);
	if(rr) {
		ofLine(marco.rect.x-marco.gap, featRect.y, featRect.x, featRect.y);
		ofLine(marco.rect.x-marco.gap, featRect.y+featRect.height, featRect.x, featRect.y+featRect.height);
	}
	else {
		ofLine(marco.rect.x+marco.rect.width+marco.gap, featRect.y, featRect.x, featRect.y);
		ofLine(marco.rect.x+marco.rect.width+marco.gap, featRect.y+featRect.height, featRect.x, featRect.y+featRect.height);
	}
	
	if(uu) {
		ofLine(featRect.x, featRect.y, featRect.x, marco.rect.y-marco.gap);
		ofLine(featRect.x+marco.rect.width, featRect.y, featRect.x+marco.rect.width+marco.gap, featRect.y);
	}
	else {
		ofLine(featRect.x, featRect.y, featRect.x, marco.rect.y+marco.rect.height+marco.gap);
		ofLine(featRect.x+featRect.width, featRect.y, 
			   featRect.x+featRect.width, marco.rect.y+marco.rect.height+marco.gap);
	}
	
	ofSetLineWidth(2.5);
	ofRect(featRect);
	
}
Ejemplo n.º 28
0
//
// send ofPolyline to laser cutter
//
bool ofxEpilog::send(ofPolyline vector_vertexes)
{
    if(vector_vertexes.size() == 0)
        return false;
    
    ofBuffer buffer;
    buffer.append(createPayloadHeader(getMachineProfile(), getOutputConfig()));
    
    // end raster part regardless of it's empty
    buffer.append(PCL_RASTER_END);
    
    // begin HPGL commands (vector part)
    buffer.append(HPGL_START);
    buffer.append(HPGL_VECTOR_INIT + HPGL_CMD_DELIMITER);

    // create vector part and append to the buffer
    buffer.append(createPayloadVectorBody(vector_vertexes, getOutputConfig()));
    
    if(!keep_alive)
        buffer.append(createPayloadFooter()); // end the session
    
    if(pjl_file.get() != NULL)
        pjl_file->writeFromBuffer(buffer);
    
    return tcp_client.sendRaw(buffer);
}
Ejemplo n.º 29
0
glmPolyline toGlm(const ofPolyline &_poly){
    glmPolyline poly;
    for (int i = 0; i < _poly.size(); i++) {
        poly.add(toGlm(_poly[i]));
    }
    return poly;
}
Ejemplo n.º 30
0
void testApp::calibrationDone(ofPolyline &_surface){
    ofLog(OF_LOG_NOTICE, "Calibration done");
    
    if ( bStart )
        killGame();
    
    if (activeGameName == "simon"){
        game = new Simon();
    } else if (activeGameName == "pong"){
        game = new Pong();
    } else if (activeGameName == "shadows"){
        game = new Shadows();
    } else if (activeGameName == "oca"){
        game = new Oca();
    } else if (activeGameName == "communitas"){
        game = new Communitas();
    } else if (activeGameName == "kaleido"){
        game = new Kaleido();
    }
    
    if (game != NULL){
        ofLog(OF_LOG_NOTICE, "Game " + activeGameName + " loaded");
        game->init( _surface.getBoundingBox() );
        iSurface.setTrackMode( game->getTrackMode() );
        bStart = true;
    } else {
        ofLog(OF_LOG_ERROR, "Game " + activeGameName + " not loaded.");
        bStart = false;
    }
}