Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: Is it possible to detect if free camera is below lake waterlevel ?  (Read 123 times)

fly77

  • Sr. Member
  • ****
  • Posts: 477

I have figured out that I can check in "free camera mode" (ufo mode) when camera is "underwater", "above land" or "above sea" by determining altitude above sealevel of the ECEF position of the camera and also altitude of terrain under the camera through raycasting. I'd like to do the same to check if I am "above lake"  or "under lake water level"...but don't know what to probe for. Is there a way to do raycasting to  intersect also lake surfaces ?


Code: [Select]
function init_vehicle(){
...
    $igc = this.$query_interface("ot::js::igc.get");
}

function update_frame(){

ecef_cam = $igc.pos();
   
   altsea_cam=Math.sqrt(ecef_cam.x*ecef_cam.x+ecef_cam.y*ecef_cam.y+ecef_cam.z*ecef_cam.z)-6378137;
   
   norm = gravity_normal(ecef_cam);
   ground_ecef = {x:ecef_cam.x-10000*norm.x,y:ecef_cam.y-10000*norm.y,z:ecef_cam.z-10000*norm.z};
   igc_ray = $igc.intersect( ecef_cam, ground_ecef );
   
   if ((igc_ray.$ret !=undefined) && (igc_ray.$ret !=null)){ 
     altground_cam =  igc_ray.$ret;     
   }else{
     altground_cam  = -10000;
   }


   if (altsea_cam+2 < 0 ){   
      underwater=true;
   }
   
   
   if (! underwater){
      if  ( altsea_cam+2 < altground_cam  - 10  )       {
        insea=true;
      }

}
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6627
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: Is it possible to detect if free camera is below lake waterlevel ?
« Reply #1 on: October 14, 2019, 02:56:27 am »

Not from IGC, which predates the lakes and doesn't have any above_water field in igc_data. In world there's elevation_above_terrain_layers returning signed elevations above hard ground, soft ground (mud, snow) and water.
Logged

fly77

  • Sr. Member
  • ****
  • Posts: 477
Re: Is it possible to detect if free camera is below lake waterlevel ?
« Reply #2 on: October 14, 2019, 04:21:56 am »

Wow...thanks ! I 'll try to see if I can use it to add some sounds specific for lakes when roaming around near lakes
Logged