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: Possible to use JSBSIM in vehicles ?  (Read 1749 times)

fly77

  • Sr. Member
  • ****
  • Posts: 396
Possible to use JSBSIM in vehicles ?
« on: September 25, 2018, 04:14:44 pm »

I'd like to add  ability to zoom when inside a vehicle cockpit, as is possible in airplanes. Is it possible using the code of aiplane scripts ?
I tried as below but I get the following error:

TypeError: Object [object Object] has no method 'jsb' (ot::js::vehicle_physics.init_vehicle(): :

Am I doing wrong something or simple is it impossible now ?

Code: [Select]

var jsbsim,fov_cockpit_zoom,ot_world;
........

function init_vehicle(){
...
this.jsbsim = this.jsb();
ot_world = this.$query_interface("ot::js::world.get");
fov_cockpit_zoom = 81.8;
this.register_axis("air/sensor/fov_zoom", {minval:0, maxval:1, vel:1, center:0}, function(v){
    var dec2int = v*48;
    var integer = Math.floor(dec2int);
    var string = 81.8 - integer.toString();
    fov_cockpit_zoom = string;
  });

....
}


function update_frame(dt, engine, brake, steering)
{
...
  if (this.get_camera_mode() == 0){
  ot_world.set_camera_fov(fov_cockpit_zoom);
.......

 }






Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6610
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: Possible to use JSBSIM in vehicles ?
« Reply #1 on: September 26, 2018, 03:18:38 am »

Vehicles do not have jsbsim, but you do not need it for zooming. The zoom control handler just modifies fov_cockpit_zoom variable, which is then used in update_frame:

Code: [Select]
  this.set_fps_camera_fov(fov_cockpit_zoom);
Also you can remove ot_world, dunno why it goes through it when it can just set the fov directly on vehicle, does not even need to check camera mode (applies only in FPS).
Logged

fly77

  • Sr. Member
  • ****
  • Posts: 396
Re: Possible to use JSBSIM in vehicles ?
« Reply #2 on: September 26, 2018, 12:29:01 pm »

Thanks. Got it working like that:
 
Code: [Select]

var fov_cockpit_zoom;
....
function init_chassis()
{
 fov_cockpit_zoom = 81.8;
    this.register_axis("air/sensor/fov_zoom", {minval:0,    maxval:1, vel:1, center:0}, function(v){
       var dec2int = v*48;
       var integer = Math.floor(dec2int);
       var string = 81.8 - integer.toString();
       fov_cockpit_zoom = string;
     });
...
}

function update_frame(dt, engine, brake, steering)
{
  this.set_fps_camera_fov(fov_cockpit_zoom);
....
}



How can I increase the max zoom level correctly ? what are the numbers 81.8 and 48 ?  Do I need to change these also or just set maxval:1   to  say maxval:5   ?
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6610
  • Pegs is clever, but tae hain’t a touch sentimental
    • outerra.com
Re: Possible to use JSBSIM in vehicles ?
« Reply #3 on: September 26, 2018, 01:41:25 pm »

Action values have some limited range beyond 1, but it's best to use them in normalized range 0..1 or -1..1, and compute the desired values from that.

The FOV value is field-of-view in degrees. Zoom is related to the original FOV you are using, see for example https://gamedev.stackexchange.com/questions/141700/how-to-convert-fov-into-zoom-2x-3x-4x
Logged