void Mesh::init_ibo() { ibo = new uint[ ibo_len ]; for ( int i = 0; i < mesh_len; i++ ) { int x_mesh, y_mesh; to_mesh_coord(i, &x_mesh, &y_mesh); if ( ( x_mesh < width - res ) && ( y_mesh < height - res ) ) { int ibo_idx = i * 6; // triang 1 ibo[ ibo_idx + 0 ] = (uint)( y_mesh * width + x_mesh ); ibo[ ibo_idx + 1 ] = (uint)( y_mesh * width + (x_mesh + res) ); ibo[ ibo_idx + 2 ] = (uint)( (y_mesh + res) * width + x_mesh ); // triang 2 ibo[ ibo_idx + 3 ] = (uint)( (y_mesh) * width + (x_mesh + res) ); ibo[ ibo_idx + 4 ] = (uint)( (y_mesh + res) * width + (x_mesh + res) ); ibo[ ibo_idx + 5 ] = (uint)( (y_mesh + res) * width + (x_mesh) ); } } }
void Mesh::init_texcoords( int tex_width, int tex_height ) { texcoords = new ofVec2f[mesh_len]; for (int i = 0; i < mesh_len; i++) { int x_mesh, y_mesh; to_mesh_coord(i, &x_mesh, &y_mesh); float t = ((float)x_mesh /width) * tex_width; float u = ((float)y_mesh /height) * tex_height; texcoords[i] = ofVec2f( t, u ); } }
void Mesh::to_depth( int mesh_idx, int *x_depth, int *y_depth, int *depth_idx ) { int x_mesh, y_mesh; to_mesh_coord( mesh_idx, &x_mesh, &y_mesh ); to_depth_coord( x_mesh, y_mesh, x_depth, y_depth); *depth_idx = to_depth_idx( *x_depth, *y_depth ); }
void Mesh::init_ibo() { ibo = new uint[ibo_len]; for (int i = 0; i < mesh_len; i++) { int x_mesh, y_mesh; to_mesh_coord( i, &x_mesh, &y_mesh ); if ( ( x_mesh < width - step ) && ( y_mesh < height - step ) ) { int ibo_idx = i * 4; ibo[ibo_idx+0] = (uint)( y_mesh * width + x_mesh ); ibo[ibo_idx+1] = (uint)( (y_mesh + step) * width + x_mesh ); ibo[ibo_idx+2] = (uint)( (y_mesh + step) * width + (x_mesh + step) ); ibo[ibo_idx+3] = (uint)( y_mesh * width + (x_mesh + step) ); } } }