Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

ofxCv and ofFbo: Trail effect

$
0
0

@tjabugg wrote:

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.

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!

void ofApp::draw() {
fadeAmnt = 10;
cam.draw(0, 0);

    ofSetLineWidth(2);
    contourFinder.draw();
    
    ofNoFill();

    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
        //to convert
        path;
        
    for( int i = 0; i < polyline.getVertices().size(); i++) {
        path.lineTo( polyline.getVertices()[i] );
       
    }
        
        path.close();
        path.simplify();

// ofSetColor(255,255,255, fadeAmnt);

        path.draw();
        rgbaFboFloat.draw(0, 0);
        //ofPath internally calculates its tessellation and stores it in an ofVboMesh
        
        
        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();

        }

    }

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles