Closed philiplinden closed 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 |
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
.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.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.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
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.
The core issue was ordering, I think. Once I added the collider to the celestial object bundle, everything worked.
0.0, 1.0E5, 1.0E9
0.0, 1.0E5, 0.999999E9
(right in front of the camera)0,0,0
384_400.0E3, 0.0, 0.0
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
Even if it's not 1:1 with reality, the relative scale between the earth, moon, and satellite models should be consistent.