ofxMathMesh, Create meshes from mathematical equations

Hey guys, I made a new add-on which lets you create meshes from 3d functions, 2d functions, parametric surfaces, and parametric curves. It also auto calculates normals and lets you customize colors as well as texture coordinates. Here is a video of the example projects. You can grab the addon here https://github.com/Ahbee/ofxMathMesh


@Ahbee super cool! Thank-s for sharing it!

this looks super fun, can’t wait to see what people do with it.

Really nice @Ahbee !! Once I find time, I am going to play with this one!

Can you explain what type of algorithm you are using to build the meshes (eg. something like Marching Cubes etc.)?

I found a website with some famous parametric surfaces for people to play around with.
Famous parametric surfaces
Some cool 3D functions

@inoodle, creating the mesh is easy. once you have the point cloud, you iterate through the points 4 at a time and create a quad between them. Marching cubes is for implicit equations,which I don’t currently support, but I’m looking into to it right now so I’ll try to add that feature. Thanks for your feedback.


wow! this is reeeeeally fun! thanks a lot.

here a little playaround in combination with displacement shader

( shader is basically rick companjes bumpmap thing: https://sites.google.com/site/ofauckland/examples/7-bumpmap-displacement-shader )

mesh is the breather (slighlty animated):

    class Breather:public ofxParametricSurface{
    ofPoint valueForPoint(float u,float v){
        float a = abs(sin(ofGetSystemTimeMicros()*0.0000001)) * 0.4 + 0.7;
        float wsqr = 1.0 - a * a;
        float w = sqrt(abs(wsqr));
        float denom = a * (sqr(w * cosh(a * u)) + sqr(a * sin(w * v)));

        float x = -u + (2 * wsqr * cosh(a * u) * sinh(a * u) / denom);
        float y = 2 * w * cosh(a * u) * (-(w * cos(v) * cos(w * v)) - (sin(v) * sin(w * v))) / denom;
        float z = 2 * w * cosh(a * u) * (-(w * sin(v) * cos(w * v)) + (cos(v) * sin(w * v))) / denom;
        return ofPoint(x,y,z);
    ofVec2f texCoordForPoint(float u,float v,ofPoint value){
        float x = ofMap(u,getUMin(),getUMax(),0,1);
        float y = ofMap(v,getVMin(),getVMax(),0,1);
        return ofVec2f(x,y);
    ofVec2f backTexCoordForPoint(float u,float v,ofPoint value){
        float x = ofMap(u,getUMin(),getUMax(),1,0);
        float y = ofMap(v,getVMin(),getVMax(),1,0);
        return ofVec2f(x,y);
    ofFloatColor colorForPoint(float u, float v, ofPoint value){
        if (u <= M_PI/2) {
            return ofFloatColor::red;
        }else if(u <= M_PI ){
            return ofFloatColor::green;
        }else if (u <= 3*M_PI/2){
            return ofFloatColor::white;
            return ofFloatColor::yellow;

if you’re looking for the sqr(), this is it:

inline float sqr(float x)
    return x*x;

is it okay to put videos in here? don’t want to spam the thread, just enthusiastic :slight_smile: