integrate two fresh asteroid models
This commit is contained in:
parent
fce7fa58cd
commit
8bfe15d3d4
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,4 @@
|
|||
target
|
||||
assets/tmp
|
||||
assets/external
|
||||
*.blend
|
||||
*.blend1
|
||||
|
|
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -294,6 +294,7 @@ version = "0.13.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "611dd99f412e862610adb43e2243b16436c6d8009f6d9dbe8ce3d6d840b34029"
|
||||
dependencies = [
|
||||
"bevy_dylib",
|
||||
"bevy_internal",
|
||||
]
|
||||
|
||||
|
@ -470,6 +471,15 @@ dependencies = [
|
|||
"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]]
|
||||
name = "bevy_ecs"
|
||||
version = "0.13.0"
|
||||
|
|
|
@ -6,8 +6,8 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
#bevy = { version = "0.13.0", features = ["dynamic_linking"] }
|
||||
bevy = "0.13.0"
|
||||
bevy = { version = "0.13.0", features = ["dynamic_linking"] }
|
||||
#bevy = "0.13.0"
|
||||
|
||||
# Enable a small amount of optimization in debug mode
|
||||
[profile.dev]
|
||||
|
|
BIN
assets/models/asteroid.blend
Normal file
BIN
assets/models/asteroid.blend
Normal file
Binary file not shown.
BIN
assets/models/asteroid.glb
Normal file
BIN
assets/models/asteroid.glb
Normal file
Binary file not shown.
BIN
assets/models/asteroid2.blend
Normal file
BIN
assets/models/asteroid2.blend
Normal file
Binary file not shown.
BIN
assets/models/asteroid2.glb
Normal file
BIN
assets/models/asteroid2.glb
Normal file
Binary file not shown.
Binary file not shown.
34
src/world.rs
34
src/world.rs
|
@ -19,6 +19,8 @@ const PIZZERIA_SIZE: f32 = 30.0;
|
|||
//const ASSET_CUBEMAP: &str = "textures/cubemap-fs8.png";
|
||||
//const ASSET_CUBEMAP_AR: &str = "textures/out.png";
|
||||
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";
|
||||
|
||||
pub struct WorldPlugin;
|
||||
|
@ -138,31 +140,37 @@ pub fn setup(
|
|||
));
|
||||
|
||||
// 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;
|
||||
for i in -maxdist..maxdist {
|
||||
for j in -maxdist..maxdist {
|
||||
for k in -maxdist..maxdist {
|
||||
let offset = 500.0;
|
||||
let dist = 3e4;
|
||||
let dist = 8e3;
|
||||
let wobble = dist/2.0;
|
||||
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((
|
||||
actor::Actor::default(),
|
||||
PbrBundle {
|
||||
mesh: sphere_handle.clone(),
|
||||
material: asteroid_color_handle.clone(),
|
||||
transform: Transform::from_xyz(
|
||||
actor::Actor {
|
||||
v: Vec3::new(-0.00, 0.0, 0.35),
|
||||
angular_momentum: Quat::from_euler(EulerRot::XYZ, 0.01, 0.01, 0.003),
|
||||
..default()
|
||||
},
|
||||
SceneBundle {
|
||||
transform: Transform {
|
||||
translation: Vec3::new(
|
||||
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 * 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()
|
||||
}
|
||||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue