Thrust, Pitch, Roll......YAW?!

An area for discussing new ideas and additions to Oolite.

Moderators: winston, another_commander

Should there be an option to play OOLite with more realistic physics?

Yes. Roll, pitch, yaw, thrust, retro, and Newtonian inertia.
22
40%
No. OOlite should never be played in a way that is different from original Elite.
15
27%
Neither of the above.
18
33%
 
Total votes: 55

drumz
Competent
Competent
Posts: 36
Joined: Thu Jan 18, 2007 6:18 am

Post by drumz »

Okay, I think the joystick/yaw code is good to go. I redid most of PlayerEntity (Controls).m, as I implemented the yaw too much like throttle. Now the yaw stuff is in the throttle section, but is implemented very similar to pitch/roll. The reason I did this is because it's a non-essential joystick control -- like throttle -- but it should behave the same as pitch/roll. Here are all the diffs once again:

Code: Select all

*** JoystickHandler.h.old       2007-01-22 11:27:09.000000000 -0600
--- JoystickHandler.h.new       2007-01-22 00:55:40.000000000 -0600
***************
*** 27,32 ****
--- 27,33 ----
  enum {
    AXIS_ROLL,
    AXIS_PITCH,
+   AXIS_YAW,
    AXIS_PRECISION,
    AXIS_THRUST,
    AXIS_VIEW,
***************
*** 37,42 ****
--- 38,45 ----
  enum {
    BUTTON_INCTHRUST,
    BUTTON_DECTHRUST,
+   BUTTON_INCYAW,
+   BUTTON_DECYAW,
    BUTTON_SCANNERZOOM,
    BUTTON_JETTISON,
    BUTTON_COMPASSMODE,
***************
*** 127,132 ****
--- 130,138 ----
  // Roll/pitch axis
  - (NSPoint) getRollPitchAxis;

+ // Yaw axis
+ - (double) getYawAxis;
+
  // Setting button and axis functions
  - (void) setFunctionForAxis: (int)axis
                     function: (int)function

Code: Select all

*** JoystickHandler.m.old       2007-01-22 11:27:24.000000000 -0600
--- JoystickHandler.m.new       2007-01-22 13:30:05.000000000 -0600
***************
*** 87,92 ****
--- 87,97 ----
     return NSMakePoint(axstate[AXIS_ROLL], axstate[AXIS_PITCH]);
  }

+ - (double) getYawAxis
+ {
+    return axstate[AXIS_YAW];
+ }
+
  - (BOOL) getButtonState: (int)function
  {
     return butstate[function];
***************
*** 376,381 ****
--- 381,387 ----
           break;
        case AXIS_ROLL:
        case AXIS_PITCH:
+       case AXIS_YAW:
           if(precisionMode)
           {
              axstate[function]=axisvalue / STICK_PRECISIONDIV;
***************
*** 434,444 ****
--- 440,452 ----
           {
              axstate[AXIS_PITCH] /= STICK_PRECISIONFAC;
              axstate[AXIS_ROLL] /= STICK_PRECISIONFAC;
+             axstate[AXIS_YAW] /= STICK_PRECISIONFAC;
           }
           else
           {
              axstate[AXIS_PITCH] *= STICK_PRECISIONFAC;
              axstate[AXIS_ROLL] *= STICK_PRECISIONFAC;
+             axstate[AXIS_YAW] *= STICK_PRECISIONFAC;
           }
        }
     }

Code: Select all

*** PlayerEntity.h.old  2007-01-22 11:28:20.000000000 -0600
--- PlayerEntity.h.new  2007-01-22 00:42:54.000000000 -0600
***************
*** 126,131 ****
--- 126,132 ----

  #define ROLL_DAMPING_FACTOR                           1.0
  #define PITCH_DAMPING_FACTOR                  1.0
+ #define YAW_DAMPING_FACTOR                    1.0

  #define PLAYER_MAX_FORWARD_SHIELD             (128.0 * (shield_booster + shield_enhancer))
  #define PLAYER_MAX_AFT_SHIELD                 (128.0 * (shield_booster + shield_enhancer))
***************
*** 511,516 ****
--- 512,518 ----
    int                                         numSticks;
    JoystickHandler                     *stickHandler;
    BOOL                                                keyboardRollPitchOverride;
+   BOOL                                                keyboardYawOverride;

    // For PlayerEntity (StickMapper)
    int                                         selFunctionIdx;

Code: Select all

*** PlayerEntity_StickMapper.m.old      2007-01-22 11:28:41.000000000 -0600
--- PlayerEntity_StickMapper.m.new      2007-01-22 13:30:17.000000000 -0600
***************
*** 279,284 ****
--- 279,289 ----
                     allowable: HW_AXIS
                        axisfn: AXIS_PITCH
                         butfn: STICK_NOFUNCTION]];
+    [funcList addObject:
+       [self makeStickGuiDict: @"Yaw"
+                    allowable: HW_AXIS
+                       axisfn: AXIS_YAW
+                        butfn: STICK_NOFUNCTION]];
     [funcList addObject:
        [self makeStickGuiDict: @"Increase thrust"
                     allowable: HW_AXIS|HW_BUTTON

Code: Select all

*** PlayerEntity (Controls).m.old       2007-01-22 11:27:59.000000000 -0600
--- PlayerEntity (Controls).m.new       2007-01-22 22:31:07.000000000 -0600
***************
*** 257,262 ****
--- 257,345 ----
                 }
  #endif

+ // Start Yaw control
+ #ifdef GNUSTEP
+                // DJS: Yaw can be an axis or a button. Axis takes precidence.
+          double virtualYaw=-([stickHandler getAxisState: AXIS_YAW]);
+          double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
+          yawing = NO;
+          keyboardYawOverride=NO;
+          if ([gameView isDown:key_yaw_left])
+          {
+             keyboardYawOverride=YES;
+             if (flight_yaw < 0.0)  flight_yaw = 0.0;
+             [self increase_flight_yaw:delta_t*yaw_delta];
+             yawing = YES;
+          }
+          if ([gameView isDown:key_yaw_right])
+          {
+             keyboardYawOverride=YES;
+             if (flight_yaw > 0.0)  flight_yaw = 0.0;
+             [self decrease_flight_yaw:delta_t*yaw_delta];
+             yawing = YES;
+          }
+          if(numSticks && !keyboardYawOverride)
+          {
+             double stick_yaw = max_flight_yaw * virtualYaw;
+             if (flight_yaw < stick_yaw)
+             {
+                [self increase_flight_yaw:delta_t*yaw_delta];
+                if (flight_yaw > stick_yaw)
+                   flight_yaw = stick_yaw;
+             }
+             if (flight_yaw > stick_yaw)
+             {
+                [self decrease_flight_yaw:delta_t*yaw_delta];
+                if (flight_yaw < stick_yaw)
+                   flight_yaw = stick_yaw;
+             }
+             yawing = (abs(virtualYaw) > .10);
+          }
+          if (!yawing)
+          {
+             if (flight_yaw > 0.0)
+             {
+                if (flight_yaw > yaw_dampner)  [self decrease_flight_yaw:yaw_dampner];
+                else   flight_yaw = 0.0;
+             }
+             if (flight_yaw < 0.0)
+             {
+                if (flight_yaw < -yaw_dampner) [self increase_flight_yaw:yaw_dampner];
+                else   flight_yaw = 0.0;
+             }
+          }
+ #else
+       double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
+       yawing = NO;
+       if ([gameView isDown:key_yaw_left])
+       {
+               if (flight_yaw < 0.0)  flight_yaw = 0.0;
+               [self increase_flight_yaw:delta_t*yaw_delta];
+               yawing = YES;
+       }
+       else if ([gameView isDown:key_yaw_right])
+       {
+               if (flight_yaw > 0.0)  flight_yaw = 0.0;
+               [self decrease_flight_yaw:delta_t*yaw_delta];
+               yawing = YES;
+       }
+       if (!yawing)
+       {
+               if (flight_yaw > 0.0)
+               {
+                       if (flight_yaw > yaw_dampner)   [self decrease_flight_yaw:yaw_dampner];
+                       else    flight_yaw = 0.0;
+               }
+               if (flight_yaw < 0.0)
+               {
+                       if (flight_yaw < -yaw_dampner)   [self increase_flight_yaw:yaw_dampner];
+                       else    flight_yaw = 0.0;
+               }
+       }
+ #endif
+ // End Yaw control
+
+
                        //
                        //  hyperspeed controls
                        //
***************
*** 1181,1187 ****

        double roll_dampner = ROLL_DAMPING_FACTOR * delta_t;
        double pitch_dampner = PITCH_DAMPING_FACTOR * delta_t;
-       double yaw_dampner = PITCH_DAMPING_FACTOR * delta_t;

        rolling = NO;
        if (!mouse_control_on )
--- 1264,1269 ----
***************
*** 1280,1312 ****
                        else    flight_pitch = 0.0;
                }
        }
-
-       yawing = NO;
-       if ([gameView isDown:key_yaw_left])
-       {
-               if (flight_yaw < 0.0)  flight_yaw = 0.0;
-               [self increase_flight_yaw:delta_t*yaw_delta];
-               yawing = YES;
-       }
-       else if ([gameView isDown:key_yaw_right])
-       {
-               if (flight_yaw > 0.0)  flight_yaw = 0.0;
-               [self decrease_flight_yaw:delta_t*yaw_delta];
-               yawing = YES;
-       }
-       if (!yawing)
-       {
-               if (flight_yaw > 0.0)
-               {
-                       if (flight_yaw > yaw_dampner)   [self decrease_flight_yaw:yaw_dampner];
-                       else    flight_yaw = 0.0;
-               }
-               if (flight_yaw < 0.0)
-               {
-                       if (flight_yaw < -yaw_dampner)   [self increase_flight_yaw:yaw_dampner];
-                       else    flight_yaw = 0.0;
-               }
-       }
  }
  #else         // ifdef GNUSTEP else
  - (void) pollFlightArrowKeyControls:(double) delta_t
--- 1362,1367 ----
These diffs are against oolite-linux rev 773.

I'm not sure how to test the non-GNUstep code. I just know the code works both with and without my joystick plugged in. Using a combination of keyboard and joystick at the same time behaves the same for yaw and pitch.

EDIT: Whoops, when I redid the code I forgot to add in joystick button control for yaw. Should support for that really be added in? I'm thinking most multi-button sticks will be multi-axis as well.
User avatar
Cmdr Wyvern
---- E L I T E ----
---- E L I T E ----
Posts: 1649
Joined: Tue Apr 11, 2006 1:47 am
Location: Somewhere in the great starry void

Post by Cmdr Wyvern »

Nice job. 8) I don't think button mode is neccessary; you either have a spare axis to use or you don't. Most sticks come with 4 axis (axiii?) nowadays anyway.

Now for the bad news...

When I compiled this code (on XP) I found two very annoying, in-your-face bugs.

- Precision Mode doesn't work on yaw.
- For some reason, it wrecks custom HUDs, throwing underlay images waaaaaaaaay off-center.
Running Oolite buttery smooth & rock stable w/ tons of eyecandy oxps on:
ASUS Prime X370-A
Ryzen 5 1500X
16GB DDR4 3200MHZ
128GB NVMe M.2 SSD (Boot drive)
1TB Hybrid HDD (For software and games)
EVGA GTX-1070 SC
1080P Samsung large screen monitor
drumz
Competent
Competent
Posts: 36
Joined: Thu Jan 18, 2007 6:18 am

Post by drumz »

I know I tested precision mode and it worked, but I think I made changes after that. Wrecking custom HUDs... now that's interesting. Looks like I'll have to go grab one and see if does the same thing on mine. I'm afraid I won't be able to work on this more until this weekend, though. Probably would be smart if school-work took precedence over this :)
dajt
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 364
Joined: Tue Aug 17, 2004 7:05 am
Location: Orange, NSW, Australia

Post by dajt »

Cmdr Wyvern wrote:
- For some reason, it wrecks custom HUDs, throwing underlay images waaaaaaaaay off-center.
I don't think this is anything to do with your code. It has been reported against the textured planets branch which was brought up-to-date with the SVN head before the last release.

There was a suggestion that some HUD code was modified to fix custom HUDs on the Mac, which then broke them on the Win32 (and probably Linux) ports.

This is the problem with no one developer (except Winston?) having all the "supported" platforms.
Regards,
David Taylor.
Brianetta
Competent
Competent
Posts: 47
Joined: Sat Jan 27, 2007 5:02 pm
Location: Newcastle upon Tyne, UK
Contact:

Post by Brianetta »

My first post to this forum. Hello, everybody.
Pangloss wrote:
There was a game for the PC around 2000. It reminded me a lot of Elite in that the game had handling like Elite. Looking online, it looks like X: Beyond The Frontier but I could be wrong, because I only played the demo version. But this screenshot brings back some memories.
Ah, the first encounter with the Teladi Phoenix after the mis-jump.

Indeed it was very much like Elite; the subtitle, "Beyond the Frontier," was a little poke at that seminal title's sequels. It was by a small German company name Egosoft. The sequels, X2 and X3, feature my name in the credits for testing and mission development, amongst other bits and bobs. Not that I was paid, or anything! They make use of volunteer developers for some things, and occasionally they formally employ the most useful.
Anyhow, it was similar to Elite (mine stuff, shoot ships) but had some bells and whistles. When you came in to land manually at a space station, the program would take over once you passed a certain point and land your ship perfectly (even if you screamed in at full throttle).
Not in X. There was a maximum speed, indicated by a green line on your throttle scale on the left side of the cockpit. You had to get into the door yourself, and safely. Then the cut scene took you to a landing bay. X2 introduced an autopilot that could dock you. Both titles featured a "docking computer" that just teleported you inside.

My fan site for the game used to be the most popular around, except that it hasn't really been updated since X3 was released (although an update is coming soon, according to my partner-in-crime on that site). http://argonopedia.ppcis.org/
Continuing, Pangloss wrote:
Back to flight dynamics. It was just like Elite; you could pull up and down, and rotate. But there was an added bonus. The 'motion lock' button or key. When unpressed, the ship would fly in the direction it was pointed in, as long as you had thrust. But if you held down the button, the thrusters instantly cut out (but would cut back on again at their original level once the button was released) because your forward motion would continue along its original vector and speed. Meaning you could now turn the ship to pass-and-strafe an asteroid or enemy ship.

That was it. Simple, but it was incredibly intuitive and it was immense fun.

Don't push the button = direction of flight is dictated by direction the ship is headed in.

Push the button = ship is locked on last known trajectory, orientation of ship just moved the ship around like you're handbrake-spinning on an icy road. Meaning you could speed by a target but then pivot and get off some great shots before releasing the button and shooting off in the direction you were now headed.
That wasn't X: Beyond the Frontier, or either of its sequels. I know those games very well indeed, and it wasn't until X3 that a ship did anything but fly as if on rails. You might be mixing up memories of Tachyon: The Fringe, which had exactly the feature you describe.
PGP fingerprint: E66A 9D58 AA10 E967 41A6 474E E41D 10AE 082C F3ED
drumz
Competent
Competent
Posts: 36
Joined: Thu Jan 18, 2007 6:18 am

Post by drumz »

Now that's something I could for: disabling your thrusters but allowing directional control. Sounds like a lot of fun.
User avatar
Killer Wolf
---- E L I T E ----
---- E L I T E ----
Posts: 2279
Joined: Tue Jan 02, 2007 12:38 pm

Post by Killer Wolf »

Yay, a fellow geordie :-)

i loved X - i played about 80 hours worth, explored everywhere and drew a map of teh gates etc, and was well into the mission when my pouter started playing silly buggers. so i backed-up and reformetted....then realised i hadn't backed -up my save games X-(

what a mook.

the new X3 looks mint, but my puters probbly way below spec for playing it w/ full bells and whistles.
drumz
Competent
Competent
Posts: 36
Joined: Thu Jan 18, 2007 6:18 am

Yaw and View Control via Joystick

Post by drumz »

Cmdr Wyvern: I had a look at the code, but I can't figure out why the precision button isn't working for you.

I did just a little clean-up on the yaw stuff, and I added view control to the joystick. However, now there's so many joystick options the last one gets cut off (Roll/pitch precision toggle button). Anyway, here's the diffs to the svn revision 779:

src/SDL/JoystickHandler.h

Code: Select all

*** JoystickHandler.h.old       2007-02-02 00:24:01.000000000 -0600
--- JoystickHandler.h   2007-02-03 10:35:44.000000000 -0600
***************
*** 27,35 ****
  enum {
    AXIS_ROLL,
    AXIS_PITCH,
    AXIS_PRECISION,
    AXIS_THRUST,
!   AXIS_VIEW,
    AXIS_end
  } axfn;

--- 27,37 ----
  enum {
    AXIS_ROLL,
    AXIS_PITCH,
+   AXIS_YAW,
    AXIS_PRECISION,
    AXIS_THRUST,
!   AXIS_VIEW_X,
!   AXIS_VIEW_Y,
    AXIS_end
  } axfn;

***************
*** 127,132 ****
--- 129,140 ----
  // Roll/pitch axis
  - (NSPoint) getRollPitchAxis;

+ // Yaw axis
+ - (double) getYawAxis;
+
+ // View_x/View_y axis
+ - (NSPoint) getViewAxis;
+
  // Setting button and axis functions
  - (void) setFunctionForAxis: (int)axis
                     function: (int)function
src/SDL/JoystickHandler.m

Code: Select all

*** JoystickHandler.m.old       2007-02-02 00:24:08.000000000 -0600
--- JoystickHandler.m   2007-02-03 10:33:49.000000000 -0600
***************
*** 87,92 ****
--- 87,102 ----
     return NSMakePoint(axstate[AXIS_ROLL], axstate[AXIS_PITCH]);
  }

+ - (double) getYawAxis
+ {
+    return axstate[AXIS_YAW];
+ }
+
+ - (NSPoint) getViewAxis
+ {
+    return NSMakePoint(axstate[AXIS_VIEW_X], axstate[AXIS_VIEW_Y]);
+ }
+
  - (BOOL) getButtonState: (int)function
  {
     return butstate[function];
***************
*** 376,381 ****
--- 386,392 ----
           break;
        case AXIS_ROLL:
        case AXIS_PITCH:
+       case AXIS_YAW:
           if(precisionMode)
           {
              axstate[function]=axisvalue / STICK_PRECISIONDIV;
***************
*** 385,390 ****
--- 396,404 ----
              axstate[function]=axisvalue / STICK_NORMALDIV;
           }
           break;
+       case AXIS_VIEW_X:
+       case AXIS_VIEW_Y:
+          axstate[function]=axisvalue;
        default:
           // set the state with no modification.
           axstate[function]=axisvalue / 32768;
***************
*** 434,444 ****
--- 448,460 ----
           {
              axstate[AXIS_PITCH] /= STICK_PRECISIONFAC;
              axstate[AXIS_ROLL] /= STICK_PRECISIONFAC;
+             axstate[AXIS_YAW] /= STICK_PRECISIONFAC;
           }
           else
           {
              axstate[AXIS_PITCH] *= STICK_PRECISIONFAC;
              axstate[AXIS_ROLL] *= STICK_PRECISIONFAC;
+             axstate[AXIS_YAW] *= STICK_PRECISIONFAC;
           }
        }
     }
src/Core/PlayerEntity.h

Code: Select all

*** PlayerEntity.h.old  2007-01-30 16:34:55.000000000 -0600
--- PlayerEntity.h      2007-02-03 10:34:01.000000000 -0600
***************
*** 126,131 ****
--- 126,132 ----

  #define ROLL_DAMPING_FACTOR                           1.0
  #define PITCH_DAMPING_FACTOR                  1.0
+ #define YAW_DAMPING_FACTOR                    1.0

  #define PLAYER_MAX_FORWARD_SHIELD             (128.0 * (shield_booster + shield_enhancer))
  #define PLAYER_MAX_AFT_SHIELD                 (128.0 * (shield_booster + shield_enhancer))
***************
*** 513,518 ****
--- 512,518 ----
    int                                         numSticks;
    JoystickHandler                     *stickHandler;
    BOOL                                                keyboardRollPitchOverride;
+   BOOL                                                keyboardYawOverride;

    // For PlayerEntity (StickMapper)
    int                                         selFunctionIdx;
src/Core/PlayerEntity_StickMapper.m

Code: Select all

*** PlayerEntity_StickMapper.m.old      2007-01-30 16:34:55.000000000 -0600
--- PlayerEntity_StickMapper.m  2007-02-03 10:38:59.000000000 -0600
***************
*** 279,284 ****
--- 279,289 ----
                     allowable: HW_AXIS
                        axisfn: AXIS_PITCH
                         butfn: STICK_NOFUNCTION]];
+    [funcList addObject:
+       [self makeStickGuiDict: @"Yaw"
+                    allowable: HW_AXIS
+                       axisfn: AXIS_YAW
+                        butfn: STICK_NOFUNCTION]];
     [funcList addObject:
        [self makeStickGuiDict: @"Increase thrust"
                     allowable: HW_AXIS|HW_BUTTON
***************
*** 290,295 ****
--- 295,311 ----
                        axisfn: AXIS_THRUST
                         butfn: BUTTON_DECTHRUST]];
     [funcList addObject:
+       [self makeStickGuiDict: @"View left/right"
+                    allowable: HW_AXIS
+                       axisfn: AXIS_VIEW_X
+                        butfn: STICK_NOFUNCTION]];
+    [funcList addObject:
+       [self makeStickGuiDict: @"View forward/back"
+                    allowable: HW_AXIS
+                       axisfn: AXIS_VIEW_Y
+                        butfn: STICK_NOFUNCTION]];
+
+    [funcList addObject:
        [self makeStickGuiDict: @"Primary weapon"
                     allowable: HW_BUTTON
                        axisfn: STICK_NOFUNCTION
src/Core/PlayerEntityControls.m

Code: Select all

*** PlayerEntityControls.m.old  2007-02-02 00:31:36.000000000 -0600
--- PlayerEntityControls.m      2007-02-03 10:37:21.000000000 -0600
***************
*** 257,262 ****
--- 257,344 ----
                 }
  #endif

+ // Start Yaw control
+ #ifdef GNUSTEP
+          double virtualYaw=-([stickHandler getAxisState: AXIS_YAW]);
+          double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
+          yawing = NO;
+          keyboardYawOverride=NO;
+          if ([gameView isDown:key_yaw_left])
+          {
+             keyboardYawOverride=YES;
+             if (flight_yaw < 0.0)  flight_yaw = 0.0;
+             [self increase_flight_yaw:delta_t*yaw_delta];
+             yawing = YES;
+          }
+          if ([gameView isDown:key_yaw_right])
+          {
+             keyboardYawOverride=YES;
+             if (flight_yaw > 0.0)  flight_yaw = 0.0;
+             [self decrease_flight_yaw:delta_t*yaw_delta];
+             yawing = YES;
+          }
+          if(numSticks && !keyboardYawOverride)
+          {
+             double stick_yaw = max_flight_yaw * virtualYaw;
+             if (flight_yaw < stick_yaw)
+             {
+                [self increase_flight_yaw:delta_t*yaw_delta];
+                if (flight_yaw > stick_yaw)
+                   flight_yaw = stick_yaw;
+             }
+             if (flight_yaw > stick_yaw)
+             {
+                [self decrease_flight_yaw:delta_t*yaw_delta];
+                if (flight_yaw < stick_yaw)
+                   flight_yaw = stick_yaw;
+             }
+             yawing = (abs(virtualYaw) > .10);
+          }
+          if (!yawing)
+          {
+             if (flight_yaw > 0.0)
+             {
+                if (flight_yaw > yaw_dampner)  [self decrease_flight_yaw:yaw_dampner];
+                else   flight_yaw = 0.0;
+             }
+             if (flight_yaw < 0.0)
+             {
+                if (flight_yaw < -yaw_dampner) [self increase_flight_yaw:yaw_dampner];
+                else   flight_yaw = 0.0;
+             }
+          }
+ #else
+       double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
+       yawing = NO;
+       if ([gameView isDown:key_yaw_left])
+       {
+               if (flight_yaw < 0.0)  flight_yaw = 0.0;
+               [self increase_flight_yaw:delta_t*yaw_delta];
+               yawing = YES;
+       }
+       else if ([gameView isDown:key_yaw_right])
+       {
+               if (flight_yaw > 0.0)  flight_yaw = 0.0;
+               [self decrease_flight_yaw:delta_t*yaw_delta];
+               yawing = YES;
+       }
+       if (!yawing)
+       {
+               if (flight_yaw > 0.0)
+               {
+                       if (flight_yaw > yaw_dampner)   [self decrease_flight_yaw:yaw_dampner];
+                       else    flight_yaw = 0.0;
+               }
+               if (flight_yaw < 0.0)
+               {
+                       if (flight_yaw < -yaw_dampner)   [self increase_flight_yaw:yaw_dampner];
+                       else    flight_yaw = 0.0;
+               }
+       }
+ #endif
+ // End Yaw control
+
+
                        //
                        //  hyperspeed controls
                        //
***************
*** 1181,1187 ****

        double roll_dampner = ROLL_DAMPING_FACTOR * delta_t;
        double pitch_dampner = PITCH_DAMPING_FACTOR * delta_t;
-       double yaw_dampner = PITCH_DAMPING_FACTOR * delta_t;

        rolling = NO;
        if (!mouse_control_on )
--- 1263,1268 ----
***************
*** 1280,1312 ****
                        else    flight_pitch = 0.0;
                }
        }
-
-       yawing = NO;
-       if ([gameView isDown:key_yaw_left])
-       {
-               if (flight_yaw < 0.0)  flight_yaw = 0.0;
-               [self increase_flight_yaw:delta_t*yaw_delta];
-               yawing = YES;
-       }
-       else if ([gameView isDown:key_yaw_right])
-       {
-               if (flight_yaw > 0.0)  flight_yaw = 0.0;
-               [self decrease_flight_yaw:delta_t*yaw_delta];
-               yawing = YES;
-       }
-       if (!yawing)
-       {
-               if (flight_yaw > 0.0)
-               {
-                       if (flight_yaw > yaw_dampner)   [self decrease_flight_yaw:yaw_dampner];
-                       else    flight_yaw = 0.0;
-               }
-               if (flight_yaw < 0.0)
-               {
-                       if (flight_yaw < -yaw_dampner)   [self increase_flight_yaw:yaw_dampner];
-                       else    flight_yaw = 0.0;
-               }
-       }
  }
  #else         // ifdef GNUSTEP else
  - (void) pollFlightArrowKeyControls:(double) delta_t
--- 1361,1366 ----
***************
*** 2218,2224 ****
        }
        if (flight_roll < 0.0)
        {
!               if (flight_roll < -delta_t)   [self increase_flight_roll:delta_t];
                else    flight_roll = 0.0;
        }
        if (flight_pitch > 0.0)
--- 2272,2278 ----
        }
        if (flight_roll < 0.0)
        {
!               if (flight_roll < -delta_t)     [self increase_flight_roll:delta_t];
                else    flight_roll = 0.0;
        }
        if (flight_pitch > 0.0)
***************
*** 2231,2236 ****
--- 2285,2300 ----
                if (flight_pitch < -delta_t)    [self increase_flight_pitch:delta_t];
                else    flight_pitch = 0.0;
        }
+       if (flight_yaw > 0.0)
+       {
+               if (flight_yaw > delta_t)       [self decrease_flight_yaw:delta_t];
+               else    flight_yaw = 0.0;
+       }
+       if (flight_yaw < 0.0)
+       {
+               if (flight_yaw < -delta_t)      [self increase_flight_yaw:delta_t];
+               else    flight_yaw = 0.0;
+       }
  }

  - (void) switchToMainView
***************
*** 2256,2286 ****
        return;

        MyOpenGLView  *gameView = (MyOpenGLView *)[universe gameView];
        //
        //  view keys
        //
!       if (([gameView isDown:gvFunctionKey1])||([gameView isDown:gvNumberKey1]))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
                [universe setViewDirection:VIEW_FORWARD];
                currentWeaponFacing = VIEW_FORWARD;
        }
!       if (([gameView isDown:gvFunctionKey2])||([gameView isDown:gvNumberKey2]))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
                [universe setViewDirection:VIEW_AFT];
                currentWeaponFacing = VIEW_AFT;
        }
!       if (([gameView isDown:gvFunctionKey3])||([gameView isDown:gvNumberKey3]))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
                [universe setViewDirection:VIEW_PORT];
                currentWeaponFacing = VIEW_PORT;
        }
!       if (([gameView isDown:gvFunctionKey4])||([gameView isDown:gvNumberKey4]))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
--- 2320,2371 ----
        return;

        MyOpenGLView  *gameView = (MyOpenGLView *)[universe gameView];
+       NSPoint         virtualView;
+       virtualView.x=0;
+       virtualView.y=0;
        //
        //  view keys
        //
! #ifdef GNUSTEP
!       if(!stickHandler)
!       {
!               stickHandler=[gameView getStickHandler];
!       }
!       numSticks=[stickHandler getNumSticks];
!       if(numSticks)
!       {
!               virtualView=[stickHandler getViewAxis];
!               if(virtualView.x == STICK_AXISUNASSIGNED ||
!                  virtualView.y == STICK_AXISUNASSIGNED)
!               {
!                       // At least one not assigned - set both to zero.
!                       virtualView.x=0;
!                       virtualView.y=0;
!               }
!       }
! #endif
!       if (([gameView isDown:gvFunctionKey1])||([gameView isDown:gvNumberKey1])||(virtualView.y<0))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
                [universe setViewDirection:VIEW_FORWARD];
                currentWeaponFacing = VIEW_FORWARD;
        }
!       if (([gameView isDown:gvFunctionKey2])||([gameView isDown:gvNumberKey2])||(virtualView.y>0))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
                [universe setViewDirection:VIEW_AFT];
                currentWeaponFacing = VIEW_AFT;
        }
!       if (([gameView isDown:gvFunctionKey3])||([gameView isDown:gvNumberKey3])||(virtualView.x<0))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
                [universe setViewDirection:VIEW_PORT];
                currentWeaponFacing = VIEW_PORT;
        }
!       if (([gameView isDown:gvFunctionKey4])||([gameView isDown:gvNumberKey4])||(virtualView.x>0))
        {
                if ([universe displayGUI])
                        [self switchToMainView];
User avatar
Phrostbyte
Competent
Competent
Posts: 36
Joined: Mon Feb 14, 2005 4:40 pm
Location: Fort Bragg, NC, USA

Post by Phrostbyte »

Wow, this thread's still going? Nice to see some community implementation of my original suggestion.
"The world Arexe is fabled for its exciting sit coms and its inhabitants' ancient loathing of sit coms."
Post Reply