ofFbo and Mesh: Trail effect

Hi,

I’m attempting to create a trail effect in ofxCv with ofFbo and I think I’m nearly there but I’m struggling with the order of things and also my program ends up crashing atm.

I’ve taken the contour and created an ofPath from it and now I’m attempting to turn it into a mesh and add a trailing effect with Fbo so that a trail of pixels is left when the user moves and gradually fades.

I am able to leave a trail by setting the colour of ofPath but I’m unable to pass in the texture from the video

This is my current code:

I’m quite new to oF so I think I’m making some mistakes with the order of things and efficiency, I’d appreciate any guidance.

Thanks!

rgbaFboFloat.begin();
   int n = contourFinder.size(); //number of contours found
          for(int i = 0; i < n; i++) {
              polyline = contourFinder.getPolyline(i); //get a polyline of every contour
              path; //to convert
              
          for( int i = 0; i < polyline.getVertices().size(); i++) {
              path.lineTo(polyline.getVertices()[i]);
                       
          }
              
              
              path.close();
              path.simplify();

// ofSetColor(255, 100);
// path.draw();

              mesh = path.getTessellation(); //tessellation only represents the fill of our shape

              for (int i = 0; i<mesh.getNumVertices(); i++){
                     mesh.addTexCoord(mesh.getVertex(i));

              texture.bind();
              mesh.draw();
              texture.unbind();
                  
              }
        }
}
              
rgbaFboFloat.end();

}

Hi, try this:

// setup()
rgbaFboFloat(ofGetWidth(), ofGetHeight(), GL_RGBA);
    rgbaFboFloat.begin();
    ofClear(0,0,0,0);
    rgbaFboFloat.end();

// draw()
rgbaFboFloat.begin();
    ofSetColor(0, 0, 0, 10); //  change this (10) for the length of trail :)
    ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight());

    // your drawing code goes here :)

    rgbaFboFloat.end();
    rgbaFboFloat.draw(0, 0);

Hi

I implemented your suggestion into my code and it seems have gotten the fbo to start working so thank you very much for that.

But it’s still not working quite right.

I’m still unable to replace the white path with the texture of the arm, and when my arm leaves the frame and re-enters - the trail re-appears.

I’ve attached some photos below

rgbaFboFloat.begin();
ofSetColor(0, 0, 0, 10);
    ofDrawRectangle(0, 0, ofGetWidth(), ofGetHeight());

    int n = contourFinder.size(); //number of contours found
          for(int i = 0; i < n; i++) {
              polyline = contourFinder.getPolyline(i); //get a polyline of every contour
              path; //to convert
              
          for( int i = 0; i < polyline.getVertices().size(); i++) {
              path.lineTo(polyline.getVertices()[i]);
                       
          }
              
              
              path.close();
              path.simplify();

// ofSetColor(255, 100);
path.draw();

// mesh = path.getTessellation(); //tessellation only represents the fill of our shape
//
// for (int i = 0; i<mesh.getNumVertices(); i++){
// mesh.addTexCoord(mesh.getVertex(i));
//
// texture.bind();
// mesh.draw();
// texture.unbind();
//
// }
}
}

rgbaFboFloat.end();

}

//----------------------------------------------------------------------------------
void ofApp::draw() {
cam.draw(0, 0);
rgbaFboFloat.draw(0, 0);