From 6e10fd9a05961ec7eadfdf015e6f04ca52be6c64 Mon Sep 17 00:00:00 2001
From: curt <curt>
Date: Fri, 18 Jun 1999 16:12:17 +0000
Subject: [PATCH] Fiddling with ssg.

---
 README.plib        | 18 ++++---------
 src/Main/main.cxx  |  6 ++---
 src/Main/views.cxx | 64 +++++++++++++++++++++++++++++++++++++++++++---
 3 files changed, 67 insertions(+), 21 deletions(-)

diff --git a/README.plib b/README.plib
index 0bbf51cb9..d2a8aaecb 100644
--- a/README.plib
+++ b/README.plib
@@ -1,21 +1,13 @@
 You *must* have the plib library installed on your system to build
 the FGFS simulator!"
 
-You can get the original library from:
+You can get the library from:
 
     http://www.woodsoup.org/projs/plib/
 
 Build notes:
 
-When you run "./configure" to configure the package, plib's defaults
-to installing the headers in /usr/local/plib/include and the libraries
-in /usr/local/plib/lib.
-
-If you would prefer to install these in /usr/local/include/plib/ and
-/usr/local/lib, then run configure with the following options:
-
-    ./configure --prefix=/usr/local --includedir=/usr/local/include/plib
-
-Installing into /usr/local/include/plib/ and /usr/local/lib makes it 
-possible for the fgfs configure script to automatically locate the plib 
-includes and libs.
+You should be able to just run "./configure" to configure the package
+and use all of plib's defaults.  Then run "make" followed by "make
+install".  By default, plib installs itself into /usr/local/plib/
+which is where flightgear now expects to find it.
diff --git a/src/Main/main.cxx b/src/Main/main.cxx
index 265f34118..75acc429a 100644
--- a/src/Main/main.cxx
+++ b/src/Main/main.cxx
@@ -1058,8 +1058,8 @@ int main( int argc, char **argv ) {
     // distribution) specifically from the ssg tux example
     //
 
-    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/" );
+    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/" );
 
     scene = new ssgRoot;
     penguin = new ssgTransform;
@@ -1071,8 +1071,6 @@ int main( int argc, char **argv ) {
 
     scene->addKid( penguin );
 
-    cout << "loaded ssg scene so it should be ready to go" << endl;
-
     // pass control off to the master GLUT event handler
     glutMainLoop();
 
diff --git a/src/Main/views.cxx b/src/Main/views.cxx
index 418b6dcf4..d7f692add 100644
--- a/src/Main/views.cxx
+++ b/src/Main/views.cxx
@@ -508,6 +508,8 @@ 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 );
@@ -624,9 +626,34 @@ void FGView::UpdateViewMath( FGInterface *f ) {
 	/* printf("Yaw matrix\n");
 	   MAT3print(TMP, stdout); */
 	MAT3mult(LOCAL, R, TMP);
-	// printf("FG derived LOCAL matrix\n");
+	// cout << "FG derived LOCAL matrix using MAT3 routines" << endl;
 	// MAT3print(LOCAL, stdout);
 
+	sgMakeRotMat4( sgLOCAL, 
+		       f->get_Psi() * RAD_TO_DEG,
+		       f->get_Phi() * RAD_TO_DEG,
+		       f->get_Theta() * RAD_TO_DEG );
+	/*
+	cout << "FG derived LOCAL matrix using sg routines" << endl;
+	MAT3mat print;
+	int i;
+	int j;
+	for ( i = 0; i < 4; i++ ) {
+	    for ( j = 0; j < 4; j++ ) {
+		print[i][j] = sgLOCAL[i][j];
+	    }
+	}
+	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 ) 
 
 #if !defined(FG_VIEW_INLINE_OPTIMIZATIONS)
@@ -645,9 +672,26 @@ void FGView::UpdateViewMath( FGInterface *f ) {
     // MAT3print(TMP, stdout);
 
     MAT3mult(UP, R, TMP);
-    // printf("Local up matrix\n");
+    // cout << "Local up matrix" << endl;;
     // MAT3print(UP, stdout);
 
+    sgMakeRotMat4( sgUP, 
+		   f->get_Longitude() * RAD_TO_DEG,
+		   0.0,
+		   -f->get_Latitude() * RAD_TO_DEG );
+    /*
+    cout << "FG derived UP matrix using sg routines" << endl;
+    MAT3mat print;
+    int i;
+    int j;
+    for ( i = 0; i < 4; i++ ) {
+	for ( j = 0; j < 4; j++ ) {
+	    print[i][j] = sgUP[i][j];
+	}
+    }
+    MAT3print( print, stdout);
+    */
+
     MAT3_SET_VEC(local_up, 1.0, 0.0, 0.0);
     MAT3mult_vec(local_up, local_up, UP);
 
@@ -662,8 +706,20 @@ void FGView::UpdateViewMath( FGInterface *f ) {
 
     // Calculate the VIEW matrix
     MAT3mult(VIEW, LOCAL, UP);
-    // printf("VIEW matrix\n");
-    // MAT3print(VIEW, stdout);
+    cout << "VIEW matrix" << endl;;
+    MAT3print(VIEW, stdout);
+
+    sgMultMat4( sgVIEW, sgLOCAL, sgUP );
+    cout << "FG derived VIEW matrix using sg routines" << endl;
+    MAT3mat print;
+    int i;
+    int j;
+    for ( i = 0; i < 4; i++ ) {
+	for ( j = 0; j < 4; j++ ) {
+	    print[i][j] = sgVIEW[i][j];
+	}
+    }
+    MAT3print( print, stdout);
 
     // generate the current up, forward, and fwrd-view vectors
     MAT3_SET_VEC(vec, 1.0, 0.0, 0.0);