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

Make mesh from combined ofPaths

$
0
0

@stephanschulz wrote:

I am trying to make a mesh from combining two paths. one is a rectangle path the order a rounded rect path.

I am able to get a path for both shapes, get a polyline and combine them in to one mesh.
But the mesh does not automatically know that i am interested on getting the created frame.

I hope to create a mesh just for the "TV" frame, not the inside of the rounded rect.

Once i worked out how to make the mesh, i will try to use it to make a color gradient from the inside to the outside.
I have done this already but just for meshes with 4 vertices.

I would be great to get any advice on how to tesselate this path correctly.
thx

 ofNoFill();
    ofPath roundedRectPath;

    float r = 30;

    ofPushMatrix();
    ofTranslate(10, 0);
    roundedRectPath.rectRounded(0, 0, 0, 100, 100,r,r,r,r);
    ofSetColor(255);
    roundedRectPath.draw();
      ofPopMatrix();

    ofPushMatrix();
    ofTranslate(200, 0);
    ofSetColor(255,0, 0);
    roundedRectPath.getOutline()[0].draw();
    ofPopMatrix();


    ofSetColor(255);
    ofPushMatrix();
    ofTranslate(400, 0);
    ofSetColor(255,0, 0);
    roundedRectPath.getTessellation().drawWireframe();
    ofPopMatrix();


    //------  ofPath rectPath;
    ofPath rectPath;
    int frameW = 10;
    ofPushMatrix();
    ofTranslate(10, 200);
    rectPath.rectangle(-frameW, -frameW, 0, 100+frameW*2, 100+frameW*2);
    ofSetColor(255);
    rectPath.draw();
    ofPopMatrix();

    ofPushMatrix();
    ofTranslate(200, 200);
    ofSetColor(255,0, 0);
    rectPath.getOutline()[0].draw();
    ofPopMatrix();

    ofSetColor(255);
    ofPushMatrix();
    ofTranslate(400, 200);
    ofSetColor(255,0, 0);
    rectPath.getTessellation().drawWireframe();
    ofPopMatrix();



    ofPolyline myPline;

    int rectPathSize = rectPath.getOutline()[0].size();
    myPline.addVertices(rectPath.getOutline()[0].getVertices());
    myPline.addVertex(rectPath.getOutline()[0][0]);

    myPline.addVertices(roundedRectPath.getOutline()[0].getVertices());


    ofSetColor(255);
    ofPushMatrix();
    ofTranslate(mouseX+50, mouseY+50);
    ofSetColor(255,0, 0);
    myPline.draw();
    ofPopMatrix();


    ofMesh myMesh;    for(int i=0; i<rectPath.getOutline()[0].size(); i++){
        myMesh.addVertices(myPline.getVertices());
    }

    ofSetColor(255);
    ofPushMatrix();
    ofTranslate(mouseX+50, mouseY+250);
    ofSetColor(255,0, 0);
    myMesh.draw();
    ofPopMatrix();

Posts: 3

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4929

Latest Images

Trending Articles



Latest Images