Board index FlightGear Support Flying

Change view direction?

Controlling your aircraft, using the autopilot etc.

Change view direction?

Postby mahela007 » Thu Jan 19, 2017 12:43 pm

In MSFS 2004 (that's the last one I used) pressing the num pad keys (with num lock ON, I think) momentarily changes view direction. Left for the 4 key, and right for the 6th key. And once the key is released, the view automatically snaps back to forward view.

In flight gear, the num-pad keys behave like toggles, Releasing the key doesn't make the view snap back to forward. How do I make flight gear behave like MSFS?
mahela007
 
Posts: 41
Joined: Sat Nov 02, 2013 8:35 am
OS: Linux Mint 18

Re: Change view direction?

Postby Thorsten » Thu Jan 19, 2017 12:58 pm

By re-writing the view manager ( $FGData/Nasal/view.nas) accordingly. There's also several camera packages with custom view managers floating around in the forum, maybe one of these already provides the function you want.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Change view direction?

Postby mahela007 » Thu Jan 19, 2017 2:20 pm

Thanks for the reply but I'm afraid your answer is far to brief to be useful to a newby such as me.
I did take a look at the view.nas file. I can't understand what's in it.

I did however manage to gain some functionality by modifying the keyboard.xml file and inserting some code to look forwards which is triggered whenever the key is *released*. (using the "mod-up" tag)
I could only do this for left and right views; Not front-right diagonal or front-left diagonal views because there is no documentation of the relevant xml properties.
mahela007
 
Posts: 41
Joined: Sat Nov 02, 2013 8:35 am
OS: Linux Mint 18

Re: Change view direction?

Postby sim » Thu Jan 19, 2017 3:16 pm

Madda posted a code for switching view diagonally left/right. May help you a little but you'd have to adapt it to keyboard buttons because code is written for joysticks. Better to post your hardware queries under "Hardware" rather than "Flying".

Madda code >
https://forum.flightgear.org/viewtopic.php?f=24&t=31440#p303390
User avatar
sim
 
Posts: 1431
Joined: Tue Jun 30, 2009 3:13 pm
Location: Shropshire England
Callsign: Fly4Fun
Version: 0.9.10 up
OS: 64 Win 10 HD6450

Re: Change view direction?

Postby Thorsten » Thu Jan 19, 2017 5:19 pm

As I tried to indicate, I don't think it's a particularly straightforward thing to do to alter how the view manager operates, and I don't think you can do it all by just xml bindings.

FG is generally very configurable, but for some things you may just end up having to code.
Thorsten
 
Posts: 12490
Joined: Mon Nov 02, 2009 9:33 am

Re: Change view direction?

Postby AndersG » Thu Jan 19, 2017 6:38 pm

There are functions in Nasal/view.nas for saving and restoring view properties. The Saitek Aviator joystick configuration contains some code that use these to get momentary look left/right/forward on the hat. Using keys would be similar, but requires a bit of programming skill to set up.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2527
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Change view direction?

Postby mahela007 » Sat Jan 21, 2017 11:27 am

Ok. I do have a bit of programming skill.
what exactly do I need to do? There doesn't seem to be any documentation
mahela007
 
Posts: 41
Joined: Sat Nov 02, 2013 8:35 am
OS: Linux Mint 18

Re: Change view direction?

Postby AndersG » Sat Jan 21, 2017 1:38 pm

Looking at my old code extracting just the view handling would be something like this:

First the main code parts (here placed in the context of the Joystick binding - you could put it in a .nas file and if so leave out all XML parts - <script> tag and outside or similarly inside the <script> element in keyboard.xml):
Code: Select all
 <nasal>
  <script>
     var quick_view_active   = 0;
     var old_view            = view.point.save();
     var goal_heading_offset =
       props.globals.getNode("/sim/current-view/goal-heading-offset-deg", 1);
     var goal_pitch_offset   =
       props.globals.getNode("/sim/current-view/goal-pitch-offset-deg", 1);

     # The fuction to be used by the bindings.
     # Usage: quick_view(direction);
     #   The view directions are: 1 - left; 2 - right; 3 - forward; 4- backward; and 0 - off/return to previous manual view direction/zoom.
     var quick_view = func {
       var dir = arg[0];
       if (dir == 0) {
         quick_view_active = 0;
         view.point.move(old_view, 0.1);
       } else {
         if (quick_view_active == 0) {
           quick_view_active = 1;
           old_view = view.point.save();

           if (dir == 1) {
             goal_heading_offset.setDoubleValue
               (getprop("/sim/view/config/left-direction-deg"));
             goal_pitch_offset.setDoubleValue
               (getprop("/sim/view/config/pitch-offset-deg"));
             view.fovProp.setDoubleValue
               (getprop("/sim/view/config/default-field-of-view-deg"));
           } if (dir == 2) {
             goal_heading_offset.setDoubleValue
               (getprop("/sim/view/config/right-direction-deg"));
             goal_pitch_offset.setDoubleValue
               (getprop("/sim/view/config/pitch-offset-deg"));
             view.fovProp.setDoubleValue
               (getprop("/sim/view/config/default-field-of-view-deg"));
           } if (dir == 3) {
             goal_heading_offset.setDoubleValue
               (getprop("/sim/view/config/front-direction-deg"));
             goal_pitch_offset.setDoubleValue
               (getprop("/sim/view/config/pitch-offset-deg"));
             view.fovProp.setDoubleValue
               (getprop("/sim/view/config/default-field-of-view-deg"));
           } if (dir == 4) {
             goal_heading_offset.setDoubleValue
               (getprop("/sim/view/config/back-direction-deg"));
             goal_pitch_offset.setDoubleValue
               (getprop("/sim/view/config/pitch-offset-deg"));
             view.fovProp.setDoubleValue
               (getprop("/sim/view/config/default-field-of-view-deg"));
           }
         }
       }
     }
  </script>
 </nasal>


Bindings for one key then becomes something like this (quick view directions are 1 - left; 2 - right; 3 - forward; 4- backward; and 0 - off/return to manual view direction/zoom):
Code: Select all
   <binding>
    <command>nasal</command>
    <script>
         quick_view(1);
    </script>
   </binding>
   <mod-up>
    <binding>
     <command>nasal</command>
     <script>
        quick_view(0);
     </script>
    </binding>
   </mod-up>
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2527
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux

Re: Change view direction?

Postby mahela007 » Sat Jan 21, 2017 3:21 pm

Thank you :)
Do you know where I can a get list of what each of these "properties" mean or do?
Because I want to be able to look to the front-right and front left as well, and not just to the right and left.
I can't find any documentation :/
mahela007
 
Posts: 41
Joined: Sat Nov 02, 2013 8:35 am
OS: Linux Mint 18

Re: Change view direction?

Postby AndersG » Sat Jan 21, 2017 3:51 pm

They are defined in fgdata/preferences.xml (now renamed to fgdata/defaults.xml in FG/git, I think) and can be overriden by the aircraft -set file.

I suppose you can usually compute the directional offsets for intermediate views as the average of the two nearby 90 deg directions. The reason to use these properties instead of just 0, (45,) 90, 180, 270 degrees is that some views in some aircraft are not forward facing.
Callsign: SE-AG
Aircraft (uhm...): Submarine Scout, Zeppelin NT, ZF Navy free balloon, Nordstern, Hindenburg, Short Empire flying-boat, ZNP-K, North Sea class, MTB T21 class, U.S.S. Monitor, MFI-9B, Type UB I submarine, Gokstad ship, Renault FT.
AndersG
 
Posts: 2527
Joined: Wed Nov 29, 2006 10:20 am
Location: Göteborg, Sweden
Callsign: SE-AG
OS: Debian GNU Linux


Return to Flying

Who is online

Users browsing this forum: No registered users and 2 guests