Anteworld - Outerra Game > Modding: Importer, Tools & Utilities

Is it possible to detect if free camera is below lake waterlevel ?

(1/2) > >>

fly77:
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: ---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;
      }

}
--- End code ---

cameni:
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.

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

fly77:
I get wrong number of arguments error when I try   with
world.elevation_above_terrain_layers()  or  world.elevation_above_terrain_layers(ecef)
and when I try world.elevation_above_terrain_layers  I get
the string " function elevation_above_terrain_layers{ [native code] }"  but I still cannot understand how I should call the function
So I am just trying randomly ....

var elev = world.elevation_above_terrain_layers(ecef,world.water); 
var elev = world.elevation_above_terrain_layers(ecef,world); 
var elev = world.elevation_above_terrain_layers(ecef,true); 
var elev = world.elevation_above_terrain_layers(ecef,0); 
var elev = world.elevation_above_terrain_layers(ecef,10000);

seems to indicate that arguments need be two.

All gives me an object   but elev.water or   elev.whatever  is undefined   ... I guess I probably got at least one of the arguments wrong.

what should be the syntax ?  Is one of the arguments ecef ? ...and what is the second one?

Just to compare: In case of igc at least I am able to get out some numbers ....allthough also in this case I am still far from a positive result as numbers do not appear to make sense to me

var igc_data = $igc.info();   
var  altsea_cam = igc_data.alt_msl;                   
var altground_cam = igc_data.alt_grd;

I get values near zero ...like for instance  3.455.. e-39  for both igc_data.alt_msl and igc_data.alt_grd allthough location of camera is well above ground and well above sealevel

cameni:
Arguments are the ecef pos and max height below the distance to check.
The result is an object with .x, .y and .z properties (float3), with hard, soft and water surface distances.

Navigation

[0] Message Index

[#] Next page

Go to full version