talpa/iomesh.cpp
// ---------------------------------------------------------
///
/// Write mesh in Renderman RIB format.
///
// ---------------------------------------------------------
Write mesh in Renderman RIB format.
Write mesh in Renderman RIB format .
bool write_ribfile(const NonDestructiveTriMesh &mesh, const std::vector<float> &x, FILE *output)
{
    fprintf( output, "# generated by editmesh\n" );
    fprintf( output, "PointsPolygons\n" );
    fprintf( output, " [ " );
    const std::vector<Vec3st>& tris = mesh.get_triangles();
    for(unsigned int i=0; i<tris.size(); ++i){
        fprintf( output, "3 " );
        if(i%38==37 && i!=tris.size()-1) fprintf( output, "\n" );
    }
    fprintf( output, "]\n" );
    fprintf( output, " [ " );
    for(unsigned int i=0; i<tris.size(); ++i){
        Vec3ui new_tri;
        fprintf( output, " %d %d %d ", (int)tris[i][0], (int)tris[i][1], (int)tris[i][2] );
        if(i%6==5 && i!=tris.size()-1) fprintf( output, "\n" ); 
    }
    fprintf( output, "]\n" );
    fprintf( output, " \"P\" [" );
    for(unsigned int i=0; i<x.size(); ++i){
        fprintf( output, " %f ", x[i] );
        if(i%4==3 && i!=x.size()-1) fprintf( output, "\n" ); 
    }
    fprintf( output, "]\n" );
    return true; 
}
bool write_ribfile ( const NonDestructiveTriMesh & mesh , const std :: vector < float > & x , FILE * output ) { fprintf ( output , " \n " ) ; fprintf ( output , " \n " ) ; fprintf ( output , " " ) ; const std :: vector < Vec3st > & tris = mesh . get_triangles ( ) ; for ( unsigned int i = 0 ; i < tris . size ( ) ; ++ i ) { fprintf ( output , " " ) ; if ( i % 38 == 37 && i != tris . size ( ) - 1 ) fprintf ( output , " \n " ) ; } fprintf ( output , " \n " ) ; fprintf ( output , " " ) ; for ( unsigned int i = 0 ; i < tris . size ( ) ; ++ i ) { Vec3ui new_tri ; fprintf ( output , " " , ( int ) tris [ i ] [ 0 ] , ( int ) tris [ i ] [ 1 ] , ( int ) tris [ i ] [ 2 ] ) ; if ( i % 6 == 5 && i != tris . size ( ) - 1 ) fprintf ( output , " \n " ) ; } fprintf ( output , " \n " ) ; fprintf ( output , " \" \" " ) ; for ( unsigned int i = 0 ; i < x . size ( ) ; ++ i ) { fprintf ( output , " " , x [ i ] ) ; if ( i % 4 == 3 && i != x . size ( ) - 1 ) fprintf ( output , " \n " ) ; } fprintf ( output , " \n " ) ; return true ; }
Write mesh in Renderman RIB format.
Write mesh in Renderman RIB format .