Indicate these models want to use their own terrein handling code, until they switch...
[fg:toms-fgdata.git] / Aircraft / PBY-Catalina / Systems / terrain.nas
1
2 var min_carrier_alt = 2;
3
4 # Do terrain modelling ourselves.
5 setprop("sim/fdm/surface/override-level", 1);
6
7 terrain_survol = func {
8
9 var lat = getprop("/position/latitude-deg");
10 var lon = getprop("/position/longitude-deg");
11 var info = geodinfo(lat, lon);
12
13
14
15
16  if (info != nil) {
17     if (info[0] != nil){
18        setprop("fdm/jsbsim/environment/terrain-hight",info[0]);
19 #var terrain_hight = info[0];
20 #print("TERRAIN ",terrain_hight);
21     }
22     if (info[1] != nil){
23       if (info[1].solid !=nil){
24         setprop("fdm/jsbsim/environment/terrain-undefined",0);
25         setprop("fdm/jsbsim/environment/terrain-solid",info[1].solid);
26 #var solid = info[1].solid;
27 #print("SOLID ",solid);
28
29     }
30       if (info[1].light_coverage !=nil)
31        setprop("fdm/jsbsim/environment/terrain-light-coverage",info[1].light_coverage);
32       if (info[1].load_resistance !=nil)
33        setprop("fdm/jsbsim/environment/terrain-load-resistance",info[1].load_resistance);
34       if (info[1].friction_factor !=nil)
35        setprop("fdm/jsbsim/environment/terrain-friction-factor",info[1].friction_factor);
36       if (info[1].bumpiness !=nil)
37        setprop("fdm/jsbsim/environment/terrain-bumpiness",info[1].bumpiness);
38       if (info[1].rolling_friction !=nil)
39        setprop("fdm/jsbsim/environment/terrain-rolling-friction",info[1].rolling_friction);
40       if (info[1].names !=nil)
41        setprop("fdm/jsbsim/environment/terrain-names",info[1].names[0]);
42
43 #unfortunately when on carrier the info[1]  is nil,  only info[0] is valid
44 #var terrain_name = info[1].names[0];
45 #print("NAME ",terrain_name);
46       #if (terrain_name == "Ocean" and terrain_hight >  min_carrier_alt)
47         #setprop("fdm/jsbsim/environment/terrain-oncarrier",1);
48     }else{
49 setprop("fdm/jsbsim/environment/terrain-undefined",1);
50 }
51               #debug.dump(geodinfo(lat, lon));
52
53
54   }else {
55     setprop("fdm/jsbsim/environment/terrain-hight",0);
56     setprop("fdm/jsbsim/environment/terrain-solid",1);
57     setprop("fdm/jsbsim/environment/terrain-oncarrier",0);
58     setprop("fdm/jsbsim/environment/terrain-light-coverage",1);
59     setprop("fdm/jsbsim/environment/terrain-load-resistance",1e+30);
60     setprop("fdm/jsbsim/environment/terrain-friction-factor",1);
61     setprop("fdm/jsbsim/environment/terrain-bumpiness",0);
62     setprop("fdm/jsbsim/environment/terrain-rolling-friction",0.02);
63     setprop("fdm/jsbsim/environment/terrain-names","unknown");
64     }
65
66 settimer (terrain_survol, 0.1);
67 }
68
69
70 terrain_survol();
71
72