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

Zooming in vehicles, planes and boats

(1/2) > >>

fly77:
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: ---
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);
.......

 }


--- End code ---





cameni:
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: ---  this.set_fps_camera_fov(fov_cockpit_zoom);

--- End code ---
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).

fly77:
Thanks. Got it working like that:
 
--- Code: ---
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);
....
}


--- End code ---


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   ?

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

fly77:
Hi cameni !

I would like to add zoom to vehicles and boats. But if I just copy the code from the cessna 172  putting  this.register_axis("air/sensor/fov_zoom", {minval:0, maxval:1, vel:1, center:0}, function(v) ....
into init_chassis where it belongs I well can get the zoom to work but when exiting the vehicle or boat the zoom remains as last set..which is very annoying... whereas for the cessna it resets automatically to the default zoom. Seems that exiting a plane behaves differently from exiting a vehicle/boat ..from the camera view perspective.
I tried to solve this issue using the code below and it works for a single vehicle/boat but when I spawn a second one I get a black screen. Also I need to set the default FOV manually in the script .copying the FOV value of the menu into the script. Is it possible to get it via the world interface ?  OR is there a completely different way to set FOV to get the default FOV back when exiting a vehicle/boat ?


--- Code: ---function init_chassis(){

 ...
  this.fov=83;// as set in the outerr amenu


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

}




function update_frame(dt, engine, brake, steering, parking){
..
 
  if (this.get_camera_mode() == 256){             // if not inside the vehicle
    this.fov_cockpit_zoom=this.fov;
  }
 
  this.set_fps_camera_fov(this.fov_cockpit_zoom);
 ..

}
--- End code ---

Navigation

[0] Message Index

[#] Next page

Go to full version