integrate two fresh asteroid models

This commit is contained in:
yuni 2024-03-19 21:09:20 +01:00
parent fce7fa58cd
commit 8bfe15d3d4
9 changed files with 36 additions and 19 deletions

1
.gitignore vendored
View file

@ -1,5 +1,4 @@
target target
assets/tmp assets/tmp
assets/external assets/external
*.blend
*.blend1 *.blend1

10
Cargo.lock generated
View file

@ -294,6 +294,7 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "611dd99f412e862610adb43e2243b16436c6d8009f6d9dbe8ce3d6d840b34029" checksum = "611dd99f412e862610adb43e2243b16436c6d8009f6d9dbe8ce3d6d840b34029"
dependencies = [ dependencies = [
"bevy_dylib",
"bevy_internal", "bevy_internal",
] ]
@ -470,6 +471,15 @@ dependencies = [
"sysinfo", "sysinfo",
] ]
[[package]]
name = "bevy_dylib"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3b3b76f0d7a4da8f944e5316f2d2d2af3bbb40d87508355993ea69afbc9411c"
dependencies = [
"bevy_internal",
]
[[package]] [[package]]
name = "bevy_ecs" name = "bevy_ecs"
version = "0.13.0" version = "0.13.0"

View file

@ -6,8 +6,8 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
#bevy = { version = "0.13.0", features = ["dynamic_linking"] } bevy = { version = "0.13.0", features = ["dynamic_linking"] }
bevy = "0.13.0" #bevy = "0.13.0"
# Enable a small amount of optimization in debug mode # Enable a small amount of optimization in debug mode
[profile.dev] [profile.dev]

Binary file not shown.

BIN
assets/models/asteroid.glb Normal file

Binary file not shown.

Binary file not shown.

BIN
assets/models/asteroid2.glb Normal file

Binary file not shown.

Binary file not shown.

View file

@ -19,6 +19,8 @@ const PIZZERIA_SIZE: f32 = 30.0;
//const ASSET_CUBEMAP: &str = "textures/cubemap-fs8.png"; //const ASSET_CUBEMAP: &str = "textures/cubemap-fs8.png";
//const ASSET_CUBEMAP_AR: &str = "textures/out.png"; //const ASSET_CUBEMAP_AR: &str = "textures/out.png";
const ASSET_ASTRONAUT: &str = "external/alien.glb#Scene0"; const ASSET_ASTRONAUT: &str = "external/alien.glb#Scene0";
const ASSET_ASTEROID1: &str = "models/asteroid.glb#Scene0";
const ASSET_ASTEROID2: &str = "models/asteroid2.glb#Scene0";
const ASSET_PIZZERIA: &str = "models/pizzeria.glb#Scene0"; const ASSET_PIZZERIA: &str = "models/pizzeria.glb#Scene0";
pub struct WorldPlugin; pub struct WorldPlugin;
@ -138,31 +140,37 @@ pub fn setup(
)); ));
// Generate a bunch of asteriods // Generate a bunch of asteriods
let asteroid_color_handle = materials.add(StandardMaterial {
base_color: Color::rgb(0.25, 0.2, 0.2),
perceptual_roughness: 1.0,
..default()
});
let maxdist = 10; let maxdist = 10;
for i in -maxdist..maxdist { for i in -maxdist..maxdist {
for j in -maxdist..maxdist { for j in -maxdist..maxdist {
for k in -maxdist..maxdist { for k in -maxdist..maxdist {
let offset = 500.0; let offset = 500.0;
let dist = 3e4; let dist = 8e3;
let wobble = dist/2.0; let wobble = dist/2.0;
let (i, j, k) = (i as f32, j as f32, k as f32); let (i, j, k) = (i as f32, j as f32, k as f32);
let asset = match ((i+j+k) as i32) % 2 {
0 => ASSET_ASTEROID1,
_ => ASSET_ASTEROID2,
};
commands.spawn(( commands.spawn((
actor::Actor::default(), actor::Actor {
PbrBundle { v: Vec3::new(-0.00, 0.0, 0.35),
mesh: sphere_handle.clone(), angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.01, 0.01, 0.003),
material: asteroid_color_handle.clone(), ..default()
transform: Transform::from_xyz( },
SceneBundle {
transform: Transform {
translation: Vec3::new(
offset + dist * i + wobble * (j+k/PI).sin() * (k+j/PI).cos(), offset + dist * i + wobble * (j+k/PI).sin() * (k+j/PI).cos(),
offset + dist * j + wobble * (k+i/PI).sin() * (i+k/PI).cos(), offset + dist * j + wobble * (k+i/PI).sin() * (i+k/PI).cos(),
offset + dist * k + wobble * (i+j/PI).sin() * (j+i/PI).cos(), offset + dist * k + wobble * (i+j/PI).sin() * (j+i/PI).cos(),
).with_scale(Vec3::splat(ASTEROID_SIZE)), ),
rotation: Quat::from_rotation_y(-PI / 3.),
scale: Vec3::splat(ASTEROID_SIZE),
},
scene: asset_server.load(asset),
..default() ..default()
} },
)); ));
} }
} }