From e40eb9d3d541f6a5eaa5d99e7d6cdc31abcdc382 Mon Sep 17 00:00:00 2001 From: Craig Mayhew Date: Tue, 7 Apr 2020 21:42:15 +0100 Subject: [PATCH] Draw a 5x5x5 fleet of tetrahedrons --- src/main.rs | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 411a51b..7e58513 100644 --- a/src/main.rs +++ b/src/main.rs @@ -81,7 +81,7 @@ fn initialise_lifeforms(world: &mut World, sprite_sheet: Handle) { //load material let default_material = world.read_resource::().0.clone(); - let mat = world.exec(|loader: AssetLoaderSystemData | { + let mat_yellow = world.exec(|loader: AssetLoaderSystemData | { loader.load_from_data( Material { albedo: yellow, @@ -91,19 +91,28 @@ fn initialise_lifeforms(world: &mut World, sprite_sheet: Handle) { ) }); - //render some tetrahedrons! let mut transform = Transform::default(); + + //set size of tetrahedrons let scale = Vector3::new(150.0, 150.0, 150.0); transform.set_scale(scale); - // Create a life form entity. - world - .create_entity() - .with(mat.clone()) - .with(mesh_tetra.clone()) - .with(LifeForm::new())//todo this line maybe superflous - .with(transform) - .build(); + //render some tetrahedrons! + for x in 1..5 { + for y in 1..5 { + for z in 1..5 { + transform.set_translation_xyz(150.0 * x as f32, 150.0 * y as f32, 150.0 * z as f32); + // Create a life form entity. + world + .create_entity() + .with(mesh_tetra.clone()) + .with(mat_yellow.clone()) + .with(LifeForm::new())//todo this line maybe superflous + .with(transform.clone()) + .build(); + } + } + } //// 2d square let mut transform = Transform::default();