]> git.mxchange.org Git - flightgear.git/commitdiff
Patch from Jim Wilson to fix internal cockpit view rotations:
authordavid <david>
Wed, 13 Mar 2002 04:58:08 +0000 (04:58 +0000)
committerdavid <david>
Wed, 13 Mar 2002 04:58:08 +0000 (04:58 +0000)
This seems to pretty much correct the problem.  Part of the problem is that
rotations are occuring at the firewall (model origin) which seems a little
un-natural inside the cockpit.  The rest of the problem is I am just learning
how this stuff works (I know I've been saying this for a couple months
now...but hey I'm slow :-)).

src/Main/model.cxx

index 859a8faf07139089713cec625ddbb8fcfb440db9..c178e9ed94da5fdbb1bc38a5ba731260cfa65eaa 100644 (file)
@@ -180,16 +180,50 @@ FGAircraftModel::update (int dt)
                                // correctly when view is not forward
       sgMakeRotMat4( sgROT, -pilot_view->get_view_offset()
                     * SGD_RADIANS_TO_DEGREES, pilot_view->get_world_up() );
-      sgPostMultMat4( VIEW_ROT, sgROT );
+
+      /* Warning lame hack from Wilson ahead */
+      /* get the pitch value */
+      sgVec3 rph;
+      sgCopyVec3(rph, pilot_view->get_rph());
+      /* double it to counter the value already in the VIEW_ROT */
+      float pitch = rph[1] * 2;
+      /* make a ROT matrix 
+         with the values waited by the X coordinate from the offset 
+         rotation see sgROT above
+      */
+      sgMat4 PunROT;
+      PunROT[0][0] = SG_ONE;
+      PunROT[0][1] = SG_ZERO;
+      PunROT[0][2] = SG_ZERO;
+      PunROT[0][3] = SG_ZERO;
+      PunROT[1][0] = SG_ZERO;
+      PunROT[1][1] = cos((1 - sgROT[0][0]) * -pitch);
+      PunROT[1][2] = -sin((1 - sgROT[0][0]) * -pitch);
+      PunROT[1][3] = SG_ZERO;
+      PunROT[2][0] = SG_ZERO;
+      PunROT[2][1] = sin((1 - sgROT[0][0]) * -pitch);
+      PunROT[2][2] = cos((1 - sgROT[0][0]) * -pitch);
+      PunROT[2][3] = SG_ZERO;
+      PunROT[3][0] = SG_ZERO;
+      PunROT[3][1] = SG_ZERO;
+      PunROT[3][2] = SG_ZERO;
+      PunROT[3][3] = SG_ONE;
+
+      sgPostMultMat4( sgTUX, PunROT );
+      sgPostMultMat4( sgTUX, VIEW_ROT );
+      sgPostMultMat4( sgTUX, sgROT );
+      sgPostMultMat4( sgTUX, sgTRANS );
+      /* end lame hack */
+
+    } else {
+      sgPostMultMat4( sgTUX, VIEW_ROT );
+      sgPostMultMat4( sgTUX, sgTRANS );
     }
-    sgPostMultMat4( sgTUX, VIEW_ROT );
-    sgPostMultMat4( sgTUX, sgTRANS );
-    
+
     sgCoord tuxpos;
     sgSetCoord( &tuxpos, sgTUX );
     _position->setTransform( &tuxpos );
   }
-
 }
 
 FGAircraftModel::Animation