Outerra forum
Anteworld - Outerra Game => Modding: Importer, Tools & Utilities => Topic started by: fly77 on October 12, 2019, 03:48:58 pm
-
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 ?
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;
}
}
-
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.
-
Wow...thanks ! I 'll try to see if I can use it to add some sounds specific for lakes when roaming around near lakes
-
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
-
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.
-
The second argument is used for optimization, if you do not really need to know how far the ground/water is, just if it's not to a certain distance from your position. Such limited raycast operation can be much faster.
-
Thanks ! works :)
elev.y-elev.x seems to indicate how deep is mud ..or in case of snow ...snow coverage nice !
how about the fact that with igc.info().alt_msl and igc.info().alt_grd i get those strange (very small) numbers wherever I move the ufo camera ?
-
That's because the body of that call is commented out for some reason and you are getting some uninitialized values :-[
-
If I understand right that is something that doesn't depend on me doing something wrong.
Ok it was just a curiosity.