pub fn update(&mut self, rotations: &mut RotationData, delta_time: f32) {

        // Dynamic ubo with per-object model matrices indexed by offsets in the command buffer
        let dim: usize = (OBJECT_INSTANCES as f32).powf(1.0 / 3.0) as usize;
        let offset = Vec3F::new(5.0, 5.0, 5.0);

        for x in 0..dim {
            for y in 0..dim {
                for z in 0..dim {

                    let dim_f = dim as f32;

                    let index = x * dim * dim + y * dim + z;
                    // update rotations
                    rotations.rotations[index] += delta_time;

                    let pos = Vec3F::new(
                        -((dim_f * offset.x) / 2.0) + offset.x / 2.0 + (x as f32) * offset.x,
                        -((dim_f * offset.y) / 2.0) + offset.y / 2.0 + (y as f32) * offset.y,
                        -((dim_f * offset.z) / 2.0) + offset.z / 2.0 + (z as f32) * offset.z,
                    );

                    self.model[index] = Mat4F::rotation_3d(rotations.rotations[index] * 2.5, rotations.rotate_speeds[index])
                        .translated_3d(pos);
                }
            }
        }
    }
// Although the rotation effect is different from the original implementation..
Although the rotation effect is different from the original implementation
Although the rotation effect is different from the original implementation
pub fn update(&mut self, rotations: &mut RotationData, delta_time: f32) {
        // Dynamic ubo with per-object model matrices indexed by offsets in the command buffer
        let dim: usize = (OBJECT_INSTANCES as f32).powf(1.0 / 3.0) as usize;
        let offset = Vec3F::new(5.0, 5.0, 5.0);
        for x in 0..dim {
            for y in 0..dim {
                for z in 0..dim {
                    let dim_f = dim as f32;
                    let index = x * dim * dim + y * dim + z;
                    // update rotations
                    rotations.rotations[index] += delta_time;
                    let pos = Vec3F::new(
                        -((dim_f * offset.x) / 2.0) + offset.x / 2.0 + (x as f32) * offset.x,
                        -((dim_f * offset.y) / 2.0) + offset.y / 2.0 + (y as f32) * offset.y,
                        -((dim_f * offset.z) / 2.0) + offset.z / 2.0 + (z as f32) * offset.z,
                    );
                    self.model[index] = Mat4F::rotation_3d(rotations.rotations[index] * 2.5, rotations.rotate_speeds[index])
                        .translated_3d(pos);
                }
            }
        }
    }
pub fn update ( & mut self , rotations : & mut RotationData , delta_time : f32 ) { // Dynamic ubo with per-object model matrices indexed by offsets in the command buffer let dim : usize = ( OBJECT_INSTANCES as f32 ) . powf ( 1.0 / 3.0 ) as usize ; let offset = Vec3F :: new ( 5.0 , 5.0 , 5.0 ) ; for x in 0 .. dim { for y in 0 .. dim { for z in 0 .. dim { let dim_f = dim as f32 ; let index = x * dim * dim + y * dim + z ; // update rotations rotations . rotations [ index ] += delta_time ; let pos = Vec3F :: new ( - ( ( dim_f * offset . x ) / 2.0 ) + offset . x / 2.0 + ( x as f32 ) * offset . x , - ( ( dim_f * offset . y ) / 2.0 ) + offset . y / 2.0 + ( y as f32 ) * offset . y , - ( ( dim_f * offset . z ) / 2.0 ) + offset . z / 2.0 + ( z as f32 ) * offset . z , ) ; self . model [ index ] = Mat4F :: rotation_3d ( rotations . rotations [ index ] * 2.5 , rotations . rotate_speeds [ index ] ) . translated_3d ( pos ) ; } } } }
Although the rotation effect is different from the original implementation..
Although the rotation effect is different from the original implementation ..
&mut self
rotations
&mut RotationData
delta_time
f32
&mut self
rotations
&mut RotationData
delta_time
f32