Compare commits
4 commits
8a35eb350a
...
7b53419899
Author | SHA1 | Date | |
---|---|---|---|
yuni | 7b53419899 | ||
yuni | 7c5c8e93d4 | ||
yuni | ec218c6351 | ||
yuni | d98b216c8d |
BIN
assets/models/metis.bin
Normal file
BIN
assets/models/metis.bin
Normal file
Binary file not shown.
213
assets/models/metis.gltf
Normal file
213
assets/models/metis.gltf
Normal file
|
@ -0,0 +1,213 @@
|
||||||
|
{
|
||||||
|
"asset":{
|
||||||
|
"generator":"Khronos glTF Blender I/O v4.2.60",
|
||||||
|
"version":"2.0"
|
||||||
|
},
|
||||||
|
"scene":0,
|
||||||
|
"scenes":[
|
||||||
|
{
|
||||||
|
"name":"Scene",
|
||||||
|
"nodes":[
|
||||||
|
0,
|
||||||
|
1
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"nodes":[
|
||||||
|
{
|
||||||
|
"mesh":0,
|
||||||
|
"name":"Sphere"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"mesh":1,
|
||||||
|
"name":"Collider"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"materials":[
|
||||||
|
{
|
||||||
|
"doubleSided":true,
|
||||||
|
"name":"Material",
|
||||||
|
"pbrMetallicRoughness":{
|
||||||
|
"baseColorTexture":{
|
||||||
|
"index":0
|
||||||
|
},
|
||||||
|
"metallicFactor":0.871999979019165,
|
||||||
|
"roughnessFactor":0.8320000171661377
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"meshes":[
|
||||||
|
{
|
||||||
|
"name":"Sphere",
|
||||||
|
"primitives":[
|
||||||
|
{
|
||||||
|
"attributes":{
|
||||||
|
"POSITION":0,
|
||||||
|
"NORMAL":1,
|
||||||
|
"TEXCOORD_0":2
|
||||||
|
},
|
||||||
|
"indices":3,
|
||||||
|
"material":0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name":"Collider",
|
||||||
|
"primitives":[
|
||||||
|
{
|
||||||
|
"attributes":{
|
||||||
|
"POSITION":4,
|
||||||
|
"NORMAL":5,
|
||||||
|
"TEXCOORD_0":6
|
||||||
|
},
|
||||||
|
"indices":7
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"textures":[
|
||||||
|
{
|
||||||
|
"sampler":0,
|
||||||
|
"source":0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"images":[
|
||||||
|
{
|
||||||
|
"mimeType":"image/jpeg",
|
||||||
|
"name":"mercury",
|
||||||
|
"uri":"../textures/mercury.jpg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"accessors":[
|
||||||
|
{
|
||||||
|
"bufferView":0,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":6752,
|
||||||
|
"max":[
|
||||||
|
0.8060516119003296,
|
||||||
|
0.7539172172546387,
|
||||||
|
0.9661670923233032
|
||||||
|
],
|
||||||
|
"min":[
|
||||||
|
-0.7730523347854614,
|
||||||
|
-0.7580877542495728,
|
||||||
|
-1.0261967182159424
|
||||||
|
],
|
||||||
|
"type":"VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":1,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":6752,
|
||||||
|
"type":"VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":2,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":6752,
|
||||||
|
"type":"VEC2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":3,
|
||||||
|
"componentType":5123,
|
||||||
|
"count":38088,
|
||||||
|
"type":"SCALAR"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":4,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":1803,
|
||||||
|
"max":[
|
||||||
|
0.806755006313324,
|
||||||
|
0.7549044489860535,
|
||||||
|
0.9662958979606628
|
||||||
|
],
|
||||||
|
"min":[
|
||||||
|
-0.7718440294265747,
|
||||||
|
-0.7597668766975403,
|
||||||
|
-1.0263147354125977
|
||||||
|
],
|
||||||
|
"type":"VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":5,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":1803,
|
||||||
|
"type":"VEC3"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":6,
|
||||||
|
"componentType":5126,
|
||||||
|
"count":1803,
|
||||||
|
"type":"VEC2"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"bufferView":7,
|
||||||
|
"componentType":5123,
|
||||||
|
"count":9522,
|
||||||
|
"type":"SCALAR"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"bufferViews":[
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":81024,
|
||||||
|
"byteOffset":0,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":81024,
|
||||||
|
"byteOffset":81024,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":54016,
|
||||||
|
"byteOffset":162048,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":76176,
|
||||||
|
"byteOffset":216064,
|
||||||
|
"target":34963
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":21636,
|
||||||
|
"byteOffset":292240,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":21636,
|
||||||
|
"byteOffset":313876,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":14424,
|
||||||
|
"byteOffset":335512,
|
||||||
|
"target":34962
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"buffer":0,
|
||||||
|
"byteLength":19044,
|
||||||
|
"byteOffset":349936,
|
||||||
|
"target":34963
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"samplers":[
|
||||||
|
{
|
||||||
|
"magFilter":9729,
|
||||||
|
"minFilter":9987
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"buffers":[
|
||||||
|
{
|
||||||
|
"byteLength":368980,
|
||||||
|
"uri":"metis.bin"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
BIN
src/blender/metis.blend
Normal file
BIN
src/blender/metis.blend
Normal file
Binary file not shown.
46
src/cmd.rs
46
src/cmd.rs
|
@ -91,6 +91,7 @@ struct ParserState {
|
||||||
is_moon: bool,
|
is_moon: bool,
|
||||||
is_planet: bool,
|
is_planet: bool,
|
||||||
is_point_of_interest: bool,
|
is_point_of_interest: bool,
|
||||||
|
is_tidally_locked: bool,
|
||||||
orbit_distance: Option<f64>,
|
orbit_distance: Option<f64>,
|
||||||
orbit_object_id: Option<String>,
|
orbit_object_id: Option<String>,
|
||||||
orbit_phase: Option<f64>,
|
orbit_phase: Option<f64>,
|
||||||
|
@ -149,6 +150,7 @@ impl Default for ParserState {
|
||||||
is_moon: false,
|
is_moon: false,
|
||||||
is_planet: false,
|
is_planet: false,
|
||||||
is_point_of_interest: false,
|
is_point_of_interest: false,
|
||||||
|
is_tidally_locked: false,
|
||||||
orbit_distance: None,
|
orbit_distance: None,
|
||||||
orbit_object_id: None,
|
orbit_object_id: None,
|
||||||
orbit_phase: None,
|
orbit_phase: None,
|
||||||
|
@ -456,6 +458,9 @@ pub fn load_defs(mut ew_spawn: EventWriter<SpawnEvent>) {
|
||||||
["ring", "yes"] => {
|
["ring", "yes"] => {
|
||||||
state.has_ring = true;
|
state.has_ring = true;
|
||||||
}
|
}
|
||||||
|
["tidally", "locked"] => {
|
||||||
|
state.is_tidally_locked = true;
|
||||||
|
}
|
||||||
["pointofinterest", "yes"] => {
|
["pointofinterest", "yes"] => {
|
||||||
state.is_point_of_interest = true;
|
state.is_point_of_interest = true;
|
||||||
}
|
}
|
||||||
|
@ -834,20 +839,25 @@ fn spawn_entities(
|
||||||
} else {
|
} else {
|
||||||
state.pos
|
state.pos
|
||||||
};
|
};
|
||||||
if let Some(r) = state.orbit_distance {
|
|
||||||
let mass: Option<f64> = if let Some(id) = &state.orbit_object_id {
|
let orbited_mass: Option<f64> = if let Some(id) = &state.orbit_object_id {
|
||||||
match id.as_str() {
|
match id.as_str() {
|
||||||
"jupiter" => Some(nature::JUPITER_MASS),
|
"jupiter" => Some(nature::JUPITER_MASS),
|
||||||
"sol" => Some(nature::JUPITER_MASS),
|
"sol" => Some(nature::JUPITER_MASS),
|
||||||
_ => {
|
_ => {
|
||||||
error!("Found no mass for object `{id}`");
|
error!("Found no mass for object `{id}`");
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
None
|
} else {
|
||||||
};
|
None
|
||||||
absolute_pos += nature::pos_offset_for_orbiting_body(r, mass, state.orbit_phase);
|
};
|
||||||
|
|
||||||
|
if let Some(r) = state.orbit_distance {
|
||||||
|
absolute_pos +=
|
||||||
|
nature::pos_offset_for_orbiting_body(r, orbited_mass, state.orbit_phase);
|
||||||
|
} else if state.is_tidally_locked {
|
||||||
|
error!("Attempted to use 'tidally locked' without specifying orbital distance via 'orbitaround'");
|
||||||
}
|
}
|
||||||
let scale = Vec3::splat(
|
let scale = Vec3::splat(
|
||||||
if state.is_sun {
|
if state.is_sun {
|
||||||
|
@ -915,6 +925,16 @@ fn spawn_entities(
|
||||||
});
|
});
|
||||||
load_asset(model.as_str(), &mut actor, &*asset_server);
|
load_asset(model.as_str(), &mut actor, &*asset_server);
|
||||||
}
|
}
|
||||||
|
if state.is_tidally_locked {
|
||||||
|
if let (Some(r), Some(mass)) = (state.orbit_distance, orbited_mass) {
|
||||||
|
rotation = Quat::from_rotation_y(nature::rotation_for_orbiting_body(r, mass) as f32)
|
||||||
|
* rotation;
|
||||||
|
} else {
|
||||||
|
error!(
|
||||||
|
"Attempted to use 'tidally locked' without specifying mass via 'orbitaround'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
actor.insert(Rotation::from(rotation));
|
actor.insert(Rotation::from(rotation));
|
||||||
|
|
||||||
// Physics Parameters
|
// Physics Parameters
|
||||||
|
|
|
@ -80,42 +80,45 @@ actor 0 0 0
|
||||||
only_in_map_at_dist 1e10 jupiter
|
only_in_map_at_dist 1e10 jupiter
|
||||||
clickable no
|
clickable no
|
||||||
physics off
|
physics off
|
||||||
actor 0 0 0 moonlet
|
actor 0 0 0 metis
|
||||||
name Metis
|
name Metis
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
id metis
|
id metis
|
||||||
orbitaround jupiter 128000e3
|
orbitaround jupiter 128000e3
|
||||||
|
tidally locked
|
||||||
scale 21.5e3
|
scale 21.5e3
|
||||||
moon yes
|
moon yes
|
||||||
angularmomentum 0 0.025 0
|
angularmomentum 0 0 0
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 128000e3
|
scale 128000e3
|
||||||
only_in_map_at_dist 1e7 metis
|
only_in_map_at_dist 1e7 metis
|
||||||
clickable no
|
clickable no
|
||||||
physics off
|
physics off
|
||||||
actor 0 0 0 moonlet
|
actor 0 0 0 metis
|
||||||
name Adrastea
|
name Adrastea
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
id adrastea
|
id adrastea
|
||||||
orbitaround jupiter 129000e3
|
orbitaround jupiter 129000e3
|
||||||
|
tidally locked
|
||||||
scale 8.2e3
|
scale 8.2e3
|
||||||
moon yes
|
moon yes
|
||||||
angularmomentum 0 0.025 0
|
angularmomentum 0 0 0
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 129000e3
|
scale 129000e3
|
||||||
only_in_map_at_dist 1e7 adrastea
|
only_in_map_at_dist 1e7 adrastea
|
||||||
clickable no
|
clickable no
|
||||||
physics off
|
physics off
|
||||||
actor 0 0 0 moonlet
|
actor 0 0 0 metis
|
||||||
name Amalthea
|
name Amalthea
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
id amalthea
|
id amalthea
|
||||||
orbitaround jupiter 181365.84e3
|
orbitaround jupiter 181365.84e3
|
||||||
|
tidally locked
|
||||||
scale 83.5e3
|
scale 83.5e3
|
||||||
moon yes
|
moon yes
|
||||||
angularmomentum 0 0.025 0
|
angularmomentum 0 0 0
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 181365.84e3
|
scale 181365.84e3
|
||||||
|
@ -127,10 +130,11 @@ actor 0 0 0
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
id thebe
|
id thebe
|
||||||
orbitaround jupiter 221900e3
|
orbitaround jupiter 221900e3
|
||||||
|
tidally locked
|
||||||
scale 50e3
|
scale 50e3
|
||||||
moon yes
|
moon yes
|
||||||
collider handcrafted
|
collider handcrafted
|
||||||
angularmomentum 0 0.0 0
|
angularmomentum 0 0 0
|
||||||
actor 0 0 0 orbitring
|
actor 0 0 0 orbitring
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
scale 221900e3
|
scale 221900e3
|
||||||
|
@ -142,8 +146,9 @@ actor 0 0 0
|
||||||
id io
|
id io
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
orbitaround jupiter 421700e3
|
orbitaround jupiter 421700e3
|
||||||
|
tidally locked
|
||||||
scale 1822e3
|
scale 1822e3
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
@ -158,8 +163,9 @@ actor 0 0 0
|
||||||
id europa
|
id europa
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
orbitaround jupiter 670900e3
|
orbitaround jupiter 670900e3
|
||||||
|
tidally locked
|
||||||
scale 1561e3
|
scale 1561e3
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
@ -174,8 +180,9 @@ actor 0 0 0
|
||||||
id ganymede
|
id ganymede
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
orbitaround jupiter 1070400e3
|
orbitaround jupiter 1070400e3
|
||||||
|
tidally locked
|
||||||
scale 2634e3
|
scale 2634e3
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
@ -190,8 +197,9 @@ actor 0 0 0
|
||||||
id callisto
|
id callisto
|
||||||
relativeto jupiter
|
relativeto jupiter
|
||||||
orbitaround jupiter 1882700e3
|
orbitaround jupiter 1882700e3
|
||||||
|
tidally locked
|
||||||
scale 2410e3
|
scale 2410e3
|
||||||
angularmomentum 0 0.0001 0
|
angularmomentum 0 0 0
|
||||||
sphere yes
|
sphere yes
|
||||||
moon yes
|
moon yes
|
||||||
physics off
|
physics off
|
||||||
|
@ -320,7 +328,7 @@ actor -55e3 44e3 0 suitv2
|
||||||
rotationx 180
|
rotationx 180
|
||||||
wants matchvelocitywith thebe
|
wants matchvelocitywith thebe
|
||||||
|
|
||||||
actor 5000 0 -3000 moonlet
|
actor 5000 0 -3000 metis
|
||||||
name Moonlet
|
name Moonlet
|
||||||
collider mesh
|
collider mesh
|
||||||
relativeto player
|
relativeto player
|
||||||
|
|
|
@ -55,6 +55,7 @@ pub fn asset_name_to_path(name: &str) -> &'static str {
|
||||||
"marker_satellites" => "models/marker_satellites.glb#Scene0",
|
"marker_satellites" => "models/marker_satellites.glb#Scene0",
|
||||||
"marker_planets" => "models/marker_planets.glb#Scene0",
|
"marker_planets" => "models/marker_planets.glb#Scene0",
|
||||||
"point_of_interest" => "models/point_of_interest.glb#Scene0",
|
"point_of_interest" => "models/point_of_interest.glb#Scene0",
|
||||||
|
"metis" => "models/metis.gltf#Scene0",
|
||||||
"thebe" => "models/thebe.gltf#Scene0",
|
"thebe" => "models/thebe.gltf#Scene0",
|
||||||
_ => "models/error.glb#Scene0",
|
_ => "models/error.glb#Scene0",
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,3 +230,18 @@ pub fn pos_offset_for_orbiting_body(
|
||||||
}
|
}
|
||||||
return phase_dist_to_coords(-phase_radians, r);
|
return phase_dist_to_coords(-phase_radians, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Assumes the "front" (as seen in blender) is pointing at the orbited mass
|
||||||
|
pub fn rotation_for_orbiting_body(
|
||||||
|
orbit_distance: f64,
|
||||||
|
mass: f64,
|
||||||
|
) -> f64 {
|
||||||
|
if let Ok(epoch) = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH) {
|
||||||
|
let orbital_period = nature::simple_orbital_period(mass, orbit_distance);
|
||||||
|
let now = epoch.as_secs_f64() + ORBIT_TIME_OFFSET;
|
||||||
|
PI * 2.0 * (now % orbital_period) / orbital_period - PI * 0.5
|
||||||
|
} else {
|
||||||
|
eprintln!("WARNING: Can't determine current time in calculate_position_offset_for_orbiting_body().");
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue