From: curt Date: Sat, 19 Jun 1999 04:48:07 +0000 (+0000) Subject: Working on getting ssg integrated. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=bfe5df5f24694b08a067a7604ee08492adb7b8c8;p=flightgear.git Working on getting ssg integrated. --- diff --git a/src/Main/main.cxx b/src/Main/main.cxx index 75acc429a..719c1442c 100644 --- a/src/Main/main.cxx +++ b/src/Main/main.cxx @@ -401,24 +401,33 @@ static void fgRenderFrame( void ) { xglLoadIdentity(); ssgSetFOV(60.0f, 0.0f); ssgSetNearFar(1.0f, 700.0f); + sgMat4 sgTRANS; + + sgMakeTransMat4( sgTRANS, + current_view.view_pos.x() + + current_view.view_forward[0] * 20, + current_view.view_pos.y() + + current_view.view_forward[1] * 20, + current_view.view_pos.z() + + current_view.view_forward[2] * 20 ); + + sgMat4 sgTMP; + sgMat4 sgTUX; + sgMultMat4( sgTMP, current_view.sgUP, sgTRANS ); + sgMultMat4( sgTUX, current_view.sgLARC_TO_SSG, sgTMP ); + sgCoord tuxpos; - sgSetCoord( &tuxpos, - current_view.view_pos.x() + current_view.view_forward[0] - * 20, - current_view.view_pos.y() + current_view.view_forward[1] - * 20, - current_view.view_pos.z() + current_view.view_forward[2] - * 20, - 0.0, 0.0, 0.0 ); + sgSetCoord( &tuxpos, sgTUX ); penguin->setTransform( &tuxpos ); - sgCoord campos; - sgSetCoord( &campos, - current_view.view_pos.x(), - current_view.view_pos.y(), - current_view.view_pos.z(), - 0, 0, 0 ); - ssgSetCamera( &campos ); + sgMakeTransMat4( sgTRANS, + current_view.view_pos.x(), + current_view.view_pos.y(), + current_view.view_pos.z() ); + sgMat4 sgVIEW; + sgMultMat4( sgVIEW, current_view.sgVIEW, sgTRANS ); + ssgSetCamera( sgVIEW ); + // ssgSetCamera( current_view.sgVIEW ); ssgCullAndDraw( scene ); } @@ -1058,8 +1067,8 @@ int main( int argc, char **argv ) { // distribution) specifically from the ssg tux example // - ssgModelPath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" ); - ssgTexturePath( "/stage/pinky01/src/Libs/plib-1.0.12/examples/ssg/tux/data/" ); + ssgModelPath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" ); + ssgTexturePath( "/h/curt/src/Libs/plib-1.0.12/examples/ssg/tux/data/" ); scene = new ssgRoot; penguin = new ssgTransform; diff --git a/src/Main/views.cxx b/src/Main/views.cxx index d7f692add..98c9b53cd 100644 --- a/src/Main/views.cxx +++ b/src/Main/views.cxx @@ -508,8 +508,6 @@ void FGView::UpdateViewMath( FGInterface *f ) { MAT3mat R, TMP, UP, LOCAL, VIEW; double ntmp; - sgMat4 sgLOCAL, sgUP, sgVIEW; - if ( update_fov ) { // printf("Updating fov\n"); UpdateFOV( current_options ); @@ -603,38 +601,79 @@ void FGView::UpdateViewMath( FGInterface *f ) { } else { + // calculate the transformation matrix to go from LaRCsim to ssg + sgVec3 vec1; + sgSetVec3( vec1, 0.0, 1.0, 0.0 ); + sgMat4 mat1; + sgMakeRotMat4( mat1, 90, vec1 ); + + sgVec3 vec2; + sgSetVec3( vec2, 1.0, 0.0, 0.0 ); + sgMat4 mat2; + sgMakeRotMat4( mat2, 90, vec2 ); + + sgMultMat4( sgLARC_TO_SSG, mat1, mat2 ); + + cout << "LaRCsim to SSG:" << endl; + MAT3mat print; + int i; + int j; + for ( i = 0; i < 4; i++ ) { + for ( j = 0; j < 4; j++ ) { + print[i][j] = sgLARC_TO_SSG[i][j]; + } + } + MAT3print( print, stdout); + // code to calculate LOCAL matrix calculated from Phi, Theta, and // Psi (roll, pitch, yaw) in case we aren't running LaRCsim as our // flight model MAT3_SET_VEC(vec, 0.0, 0.0, 1.0); MAT3rotate(R, vec, f->get_Phi()); - /* printf("Roll matrix\n"); */ - /* MAT3print(R, stdout); */ + // cout << "Roll matrix" << endl; + // MAT3print(R, stdout); + + sgVec3 sgrollvec; + sgSetVec3( sgrollvec, 0.0, 0.0, 1.0 ); + sgMat4 sgPHI; // roll + sgMakeRotMat4( sgPHI, f->get_Phi() * RAD_TO_DEG, sgrollvec ); + MAT3_SET_VEC(vec, 0.0, 1.0, 0.0); - /* MAT3mult_vec(vec, vec, R); */ MAT3rotate(TMP, vec, f->get_Theta()); - /* printf("Pitch matrix\n"); */ - /* MAT3print(TMP, stdout); */ + // cout << "Pitch matrix" << endl;; + // MAT3print(TMP, stdout); MAT3mult(R, R, TMP); + // cout << "tmp rotation matrix, R:" << endl;; + // MAT3print(R, stdout); + + sgVec3 sgpitchvec; + sgSetVec3( sgpitchvec, 0.0, 1.0, 0.0 ); + sgMat4 sgTHETA; // pitch + sgMakeRotMat4( sgTHETA, f->get_Theta() * RAD_TO_DEG, + sgpitchvec ); + + sgMat4 sgROT; + sgMultMat4( sgROT, sgPHI, sgTHETA ); + MAT3_SET_VEC(vec, 1.0, 0.0, 0.0); - /* MAT3mult_vec(vec, vec, R); */ - /* MAT3rotate(TMP, vec, FG_Psi - FG_PI_2); */ MAT3rotate(TMP, vec, -f->get_Psi()); - /* printf("Yaw matrix\n"); - MAT3print(TMP, stdout); */ + // cout << "Yaw matrix" << endl; + // MAT3print(TMP, stdout); MAT3mult(LOCAL, R, TMP); - // cout << "FG derived LOCAL matrix using MAT3 routines" << endl; + // cout << "LOCAL matrix:" << endl; // MAT3print(LOCAL, stdout); - sgMakeRotMat4( sgLOCAL, - f->get_Psi() * RAD_TO_DEG, - f->get_Phi() * RAD_TO_DEG, - f->get_Theta() * RAD_TO_DEG ); + sgVec3 sgyawvec; + sgSetVec3( sgyawvec, 1.0, 0.0, 0.0 ); + sgMat4 sgPSI; // pitch + sgMakeRotMat4( sgPSI, -f->get_Psi() * RAD_TO_DEG, sgyawvec ); + + sgMultMat4( sgLOCAL, sgROT, sgPSI ); + /* - cout << "FG derived LOCAL matrix using sg routines" << endl; MAT3mat print; int i; int j; @@ -644,15 +683,6 @@ void FGView::UpdateViewMath( FGInterface *f ) { } } MAT3print( print, stdout); - - sgMat4 sgIDENT; - sgMakeIdentMat4( sgIDENT ); - for ( i = 0; i < 4; i++ ) { - for ( j = 0; j < 4; j++ ) { - print[i][j] = sgIDENT[i][j]; - } - } - MAT3print( print, stdout); */ } // if ( use_larcsim_local_to_body ) @@ -709,7 +739,10 @@ void FGView::UpdateViewMath( FGInterface *f ) { cout << "VIEW matrix" << endl;; MAT3print(VIEW, stdout); - sgMultMat4( sgVIEW, sgLOCAL, sgUP ); + sgMat4 sgTMP; + sgMultMat4( sgTMP, sgLOCAL, sgUP ); + sgMultMat4( sgVIEW, sgLARC_TO_SSG, sgTMP ); + cout << "FG derived VIEW matrix using sg routines" << endl; MAT3mat print; int i; @@ -721,6 +754,7 @@ void FGView::UpdateViewMath( FGInterface *f ) { } MAT3print( print, stdout); + // generate the current up, forward, and fwrd-view vectors MAT3_SET_VEC(vec, 1.0, 0.0, 0.0); MAT3mult_vec(view_up, vec, VIEW); diff --git a/src/Main/views.hxx b/src/Main/views.hxx index 332176bb3..378bf5876 100644 --- a/src/Main/views.hxx +++ b/src/Main/views.hxx @@ -29,6 +29,7 @@ # error This library requires C++ #endif +#include // plib include #include #include @@ -152,6 +153,8 @@ public: // Current model view matrix; GLfloat MODEL_VIEW[16]; + sgMat4 sgLOCAL, sgUP, sgVIEW, sgLARC_TO_SSG; + public: // Constructor