philiplinden / spacetime

a real(istic) time simulator
https://philiplinden.github.io/spacetime/
Mozilla Public License 2.0
8 stars 0 forks source link

Models do not have a consistent scale #6

Closed philiplinden closed 9 months ago

philiplinden commented 9 months ago

Even if it's not 1:1 with reality, the relative scale between the earth, moon, and satellite models should be consistent.

image

philiplinden commented 9 months ago
Asset Dimension Original scale Real scale Scale factor
Earth Radius 26.5 m 6,378,000 m 240679.25
Moon Radius 37.96 m 1,737,400 m 45769.23
Satellite Height 21.128 m 1 m 0.04733056
philiplinden commented 9 months ago

image

philiplinden commented 9 months ago
  1. Use the Measure tool to inspect the native size of the model. Remember that the editor has a native unit system too. Blender initializes with units of meters.
  2. Get the Scale Factor by Real / Model = Scale Factor. Make sure to do unit conversions if necessary. We want the scale factor that is multiplied to Model length in order have it be equal to the Real length.
  3. In Blender go to "Scene Properties" and insert the scale factor in the Unit Scale field. Changing Length from meters to kilometers will not change the scale of the world, it will only change how units are reported.

image

image

image

philiplinden commented 9 months ago
fn from_preset(name: &str) -> Self {
        let preset = match name {
            "Earth" => Ok(CelestialBody {
                name: String::from("Earth"),
                radius: Length::new::<kilometer>(6_378.0),
                mass: Mass::new::<kilogram>(5.9722E24),
                model_path: String::from("models/Earth.glb#Scene0"),
            }),
            "Luna" => Ok(CelestialBody {
                name: String::from("Luna"),
                radius: Length::new::<kilometer>(1_737.4),
                mass: Mass::new::<kilogram>(7.342E22),
                model_path: String::from("models/Moon.glb#Scene0"),
            }),

// ...

let body = CelestialBody::from_preset(name);
        let radius = body.radius.get::<meter>();
        info!("Radius of {:?} = {:?} m", name, radius);
2023-12-11T01:17:11.001999Z  INFO clocss_abm::cosmic: Radius of "Earth" = 6378000.0 m
2023-12-11T01:17:11.001991Z  INFO clocss_abm::cosmic: Radius of "Luna" = 1737400.0 m
philiplinden commented 9 months ago

The models are orders of magnitude smaller than their bounding balls. Something isn't right here. The radius is calculated correctly (I'm using the unit conversion crate properly) but the mesh doesn't seem to be spawning with the correct size.

philiplinden commented 9 months ago

The core issue was ordering, I think. Once I added the collider to the celestial object bundle, everything worked.

philiplinden commented 9 months ago
2023-12-11T01:59:56.229636Z  INFO clocss_abm::cosmic: Spawning "Luna": Radius 1737400.0 m, Mass 7.342e22 kg
2023-12-11T01:59:56.229636Z  INFO clocss_abm::cosmic: Spawning "Earth": Radius 6378000.0 m, Mass 5.9722e24 kg

image