Skip to content

Commit

Permalink
test get_camera_view
Browse files Browse the repository at this point in the history
  • Loading branch information
-karlos- committed Dec 22, 2023
1 parent 7b6c0cb commit a0339f2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 19 deletions.
22 changes: 5 additions & 17 deletions src/geoview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,29 +120,18 @@ impl GeoView {
let position = player.pos();

let geo_coord = position.to_planetary_position().to_geocoord();
//info!(?geo_coord);
let elevation =
position.position_double(space).length() as f32 - crate::geocoord::EARTH_RADIUS;
//info!(?elevation);

/*
let mut transform = player.pos().transform;
// Un-Pan up or down.
transform.rotate_local_x(geo_coord.lat.to_radians() + FRAC_PI_2);
// Un-Rotate to west or east
transform.rotate_local_z(geo_coord.lon.to_radians());
let up_view = transform.rotation.x.to_degrees(); // lat
let direction = transform.rotation.z.to_degrees(); // llon
*/

let forward = position.pos.transform.forward();
let directions = position.directions();
let up_view = forward.angle_between(-directions.up).to_degrees();

// we have to "rotate back the up" before calculating delta north
let direction = forward
.cross(directions.up)
.cross(position.pos.transform.right())
.angle_between(directions.north)
.cross(directions.up) // rotate back up ? https://en.wikipedia.org/wiki/Cross_product cross product or vector product
.cross(position.pos.transform.right()) // what ????
.angle_between(directions.north) // calculating delta north
.to_degrees();

Self {
Expand Down Expand Up @@ -197,7 +186,6 @@ fn keys_ui(
info!("*** key: {:?}", key_string);
let view3 = GeoView::restore(key_string, &mut views.map);
if let Some(view3) = view3 {
info!("*** out: {:?}", view3);
view3.set_camera_view(&space, &mut player);
}
}
Expand Down
14 changes: 12 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ pub fn main() {
lat: 48.1408, // Germany, Munic, Main railway station
lon: 11.5577,
};
let mut elevation: f32 = 300.0; // Camare hight about ground 5000000.; //
let mut elevation: f32 = 300.0;

// GeoView to city center, Marienplatz
let mut direction: f32 = -105.0; // Compass view-direction to Oeast-Southeast. 0 = Nord, -90 = East Todo: Why minus?
Expand Down Expand Up @@ -106,7 +106,7 @@ pub fn main() {
xr,
});

let start_view = GeoView {
let _start_view = GeoView {
geo_coord,
elevation,
direction,
Expand All @@ -115,6 +115,16 @@ pub fn main() {
camera_fov: 7.,
};

let start_view = GeoView {
// test only
geo_coord: GeoCoord { lat: 33., lon: 0. }, // up,dir
elevation: 5000000.,
direction: 0.,
up_view: 0.02,
distance: 6.,
camera_fov: 7.,
};

app.insert_resource(ViewDistance(2000.0));
app.add_plugins(HttpAssetReaderPlugin {
base_url: "gltiles.osm2world.org/glb/".into(),
Expand Down

0 comments on commit a0339f2

Please sign in to comment.