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

Draw mesh with flat faces

$
0
0

@Gallo wrote:

hello,

i have a mesh which i am able to display in multiple modes : points, lines or triangles.

What i would like (and i can't find the right solution) is to draw the mesh with simple faces like a low poly rendering.
For now all faces are drawn with interpolated color between each vertex.

void ofApp::onDisplacementChanged(float &val){
    for (int i = 0 ; i < mesh.getNumVertices() ; i++) {

        ofColor color = mesh.getColor(i);
        float brightness = ofMap(color.getBrightness(), 0, 255, -val, val);

        ofPoint oldPoint = mesh.getVertex(i);
        ofPoint newPoint(oldPoint.x, oldPoint.y, brightness);


        float distance = newPoint.distance(mesh.getVertex(i + 1));
        float alpha = ofMap(distance, 1, 400, 170, 255);
        ofColor newColor(color.r, color.g, color.b, alpha);

        mesh.setVertex(i, newPoint);
        mesh.setColor(i, newColor);

    }
}

I can't find the logic to draw faces with plain colors.

thanks a lot for any tip

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles