/// \brief Generates a square grid consisting of triangles.  
///        Allocates memory for the vertex data and stores
///        the results in the arrays.  Generate index list as TRIANGLES.
/// @size create a grid of size by size (number of triangles = (size-1)*(size-1)*2)
///
/// Return value: (vertices, indices) vertices, will contain array of float3 positions,
/// indices, will contain the array of indices for the triangle strip
\brief Generates a square grid consisting of triangles.
Allocates memory for the vertex data and stores
the results in the arrays.  Generate index list as TRIANGLES.
\ brief Generates a square grid consisting of triangles . Allocates memory for the vertex data and stores the results in the arrays . Generate index list as TRIANGLES .
fn gen_square_grid(size: u32) -> (Vec<Point3<f32>>, Vec<u32>) {
    let num_indices = (size - 1) * (size - 1) * 2 * 3;
    let num_vertices = size * size;
    let step_size = size as f32 - 1_f32;
    let mut vertices = Vec::with_capacity(3 * num_vertices as usize);
    for row in 0..size {
        for column in 0..size {
            vertices.push(Point3::new(row as f32 / step_size, column as f32 / step_size, 0_f32));
        }
    }
    // Generate the indices
    let mut indices: Vec<u32> = Vec::with_capacity(num_indices as usize);
    for row in 0..size - 1 {
        for column in 0..size - 1 {
            // two triangles per quad
            indices.push(column + row * size);
            indices.push(column + row * size + 1);
            indices.push(column + (row + 1) * size + 1);
            indices.push(column + row * size);
            indices.push(column + (row + 1) * size + 1);
            indices.push(column + (row + 1) * size);
        }
    }
    return (vertices, indices);
}
fn gen_square_grid ( size : u32 ) -> ( Vec < Point3 < f32 > > , Vec < u32 > ) { let num_indices = ( size - 1 ) * ( size - 1 ) * 2 * 3 ; let num_vertices = size * size ; let step_size = size as f32 - 1_f32 ; let mut vertices = Vec :: with_capacity ( 3 * num_vertices as usize ) ; for row in 0 .. size { for column in 0 .. size { vertices . push ( Point3 :: new ( row as f32 / step_size , column as f32 / step_size , 0_f32 ) ) ; } } // Generate the indices let mut indices : Vec < u32 > = Vec :: with_capacity ( num_indices as usize ) ; for row in 0 .. size - 1 { for column in 0 .. size - 1 { // two triangles per quad indices . push ( column + row * size ) ; indices . push ( column + row * size + 1 ) ; indices . push ( column + ( row + 1 ) * size + 1 ) ; indices . push ( column + row * size ) ; indices . push ( column + ( row + 1 ) * size + 1 ) ; indices . push ( column + ( row + 1 ) * size ) ; } } return ( vertices , indices ) ; }
\brief Generates a square grid consisting of triangles.
\ brief Generates a square grid consisting of triangles .
size
u32
size
create a grid of size by size (number of triangles = (size-1)*(size-1)*2)
Return value: (vertices, indices) vertices, will contain array of float3 positions,
indices, will contain the array of indices for the triangle strip
create a grid of size by size ( number of triangles = ( size - 1 ) * ( size - 1 ) * 2 ) Return value : ( vertices indices ) vertices will contain array of float3 positions indices will contain the array of indices for the triangle strip