Mesh.ply breaks in Meshlab

Hi everyone,

I am generating a mesh from an audio file. It renders fine IN OF but when I save the .ply and try to open it in Meshlab I get the following error.

My code seems pretty straight forward anyone have any idea what might be breaking Meshlab?

    //verts
    for(int i =0; i < circlepts; i++){
        
        float angle = i * TWO_PI / circlepts;
        
        vertpt.x = volrad * cos(angle);
        vertpt.y = volrad * sin(angle);
        vertpt.z = zdepth;
        
        mesh.addVertex(vertpt);
        
    }
    
    //increment depth
    zdepth = zdepth + 16;
    
    //triangles
    int base = mesh.getNumVertices() - 2 * circlepts;
    
    for (int i=0; i<circlepts; i++){
        
        int a = base + i;
        int b = base + (i + 1) % circlepts;
        int c = circlepts + a;
        int d = circlepts + b;
        
        mesh.addTriangle( a, b, d ); //clockwise
        mesh.addTriangle( a, d, c );
        
    }

Actually I figured it out… I was missing a line on drawing the triangles

   //triangles
    int base = mesh.getNumVertices() - 2 * circlepts;

if(base >= 0){
    
    for (int i=0; i<circlepts; i++){
        
        int a = base + i;
        int b = base + (i + 1) % circlepts;
        int c = circlepts + a;
        int d = circlepts + b;
        
        mesh.addTriangle( a, b, d ); //clockwise
        mesh.addTriangle( a, d, c );
        
    }
    
}
1 Like

This looks pretty interesting, what is your project about?