From d31fcd21ef27bf06e66d3b723072eb54c9e7c931 Mon Sep 17 00:00:00 2001 From: david Date: Wed, 13 Mar 2002 04:58:08 +0000 Subject: [PATCH] Patch from Jim Wilson to fix internal cockpit view rotations: 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 | 44 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/src/Main/model.cxx b/src/Main/model.cxx index 859a8faf0..c178e9ed9 100644 --- a/src/Main/model.cxx +++ b/src/Main/model.cxx @@ -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