]> git.mxchange.org Git - flightgear.git/blobdiff - src/Main/views.hxx
Various SGI portability tweaks.
[flightgear.git] / src / Main / views.hxx
index 332176bb3379b98cd9184eee535a919d1c7cc1c4..9f499db403e1c63b5c2b2388b06a8f2080543522 100644 (file)
 # error This library requires C++
 #endif                                   
 
+#include <Include/compiler.h>
+
+#include <list>
+
+#include <sg.h>                        // plib include
 
 #include <FDM/flight.hxx>
-#include <Math/mat3.h>
 #include <Math/point3d.hxx>
 #include <Time/fg_time.hxx>
 #include <Time/light.hxx>
 
 #include "options.hxx"
 
+FG_USING_STD(list);
+
 
 // used in views.cxx and tilemgr.cxx
 #define USE_FAST_FOV_CLIP 
@@ -95,63 +101,60 @@ public:
     // view position translated to scenery.center
     Point3D view_pos;
 
+    // pilot offset from center of gravity.  The X axis is positive
+    // out the tail, Y is out the right wing, and Z is positive up.
+    // Distances in meters of course.
+    sgVec3 pilot_offset;
+
     // cartesion coordinates of current lon/lat if at sea level
-    // translated to scenery.center*/
+    // translated to scenery.center
     Point3D cur_zero_elev;
 
     // vector in cartesian coordinates from current position to the
     // postion on the earth's surface the sun is directly over
-    MAT3vec to_sun;
-    
+    sgVec3 to_sun;
+
     // surface direction to go to head towards sun
-    MAT3vec surface_to_sun;
+    sgVec3 surface_to_sun;
 
     // vector in cartesian coordinates from current position to the
     // postion on the earth's surface the moon is directly over
-    MAT3vec to_moon;
+    sgVec3 to_moon;
   
     // surface direction to go to head towards moon
-    MAT3vec surface_to_moon;
+    sgVec3 surface_to_moon;
 
     // surface vector heading south
-    MAT3vec surface_south;
+    sgVec3 surface_south;
 
     // surface vector heading east (used to unambiguously align sky
     // with sun)
-    MAT3vec surface_east;
+    sgVec3 surface_east;
 
     // local up vector (normal to the plane tangent to the earth's
     // surface at the spot we are directly above
-    MAT3vec local_up;
+    sgVec3 local_up;
 
     // up vector for the view (usually point straight up through the
     // top of the aircraft
-    MAT3vec view_up;
+    sgVec3 view_up;
 
     // the vector pointing straight out the nose of the aircraft
-    MAT3vec view_forward;
+    sgVec3 view_forward;
 
     // Transformation matrix for eye coordinates to aircraft coordinates
-    MAT3mat AIRCRAFT;
+    // sgMat4 AIRCRAFT;
 
     // Transformation matrix for the view direction offset relative to
     // the AIRCRAFT matrix
-    MAT3mat VIEW_OFFSET;
-
-    // Transformation matrix for aircraft coordinates to world
-    // coordinates
-    MAT3mat WORLD;
-
-    // Combined transformation from eye coordinates to world coordinates
-    MAT3mat EYE_TO_WORLD;
-
-    // Inverse of EYE_TO_WORLD which is a transformation from world
-    // coordinates to eye coordinates
-    MAT3mat WORLD_TO_EYE;
+    sgMat4 VIEW_OFFSET;
 
     // Current model view matrix;
     GLfloat MODEL_VIEW[16];
 
+    // sg versions of our friendly matrices
+    sgMat4 LOCAL, UP, VIEW_ROT, TRANS, VIEW, LARC_TO_SSG;
+
 public:
 
     // Constructor
@@ -163,26 +166,15 @@ public:
     // Initialize a view class
     void Init( void );
 
-    // Basically, this is a modified version of the Mesa gluLookAt()
-    // function that's been modified slightly so we can capture the
-    // result (and use it later) otherwise this all gets calculated in
-    // OpenGL land and we don't have access to the results.
-    void LookAt( GLdouble eyex, GLdouble eyey, GLdouble eyez,
-                GLdouble centerx, GLdouble centery, GLdouble centerz,
-                GLdouble upx, GLdouble upy, GLdouble upz );
-
     // Update the view volume, position, and orientation
-    void UpdateViewParams( void );
+    void UpdateViewParams( const FGInterface& f );
 
     // Flag to request that UpdateFOV() be called next time
     // UpdateViewMath() is run.
     inline void force_update_fov_math() { update_fov = true; }
 
     // Update the view parameters
-    void UpdateViewMath( FGInterface *f );
-
-    // Update the "World to Eye" transformation matrix
-    void UpdateWorldToEye( FGInterface *f );
+    void UpdateViewMath( const FGInterface& f );
 
     // Update the field of view coefficients
     void UpdateFOV( const fgOPTIONS& o );
@@ -213,40 +205,36 @@ public:
     inline void set_tris_culled( int tris) { tris_culled = tris; }
     inline Point3D get_abs_view_pos() const { return abs_view_pos; }
     inline Point3D get_view_pos() const { return view_pos; }
+    inline float *get_pilot_offset() { return pilot_offset; }
+    inline void set_pilot_offset( float x, float y, float z ) {
+       sgSetVec3( pilot_offset, x, y, z );
+    }
     inline Point3D get_cur_zero_elev() const { return cur_zero_elev; }
-    inline double *get_to_sun() { return to_sun; }
-    inline void set_to_sun( double x, double y, double z) {
-       to_sun[0] = x;
-       to_sun[1] = y;
-       to_sun[2] = z;
+    inline float *get_to_sun() { return to_sun; }
+    inline void set_to_sun( float x, float y, float z ) {
+       sgSetVec3( to_sun, x, y, z );
     }
-    inline double *get_surface_to_sun() { return surface_to_sun; }
-    inline void set_surface_to_sun( double x, double y, double z) {
-       surface_to_sun[0] = x;
-       surface_to_sun[1] = y;
-       surface_to_sun[2] = z;
+    inline float *get_surface_to_sun() { return surface_to_sun; }
+    inline void set_surface_to_sun( float x, float y, float z) {
+       sgSetVec3( surface_to_sun, x, y, z );
     }
-    inline double *get_to_moon() { return to_moon; }
-    inline void set_to_moon( double x, double y, double z) {
-       to_moon[0] = x;
-       to_moon[1] = y;
-       to_moon[2] = z;
+    inline float *get_to_moon() { return to_moon; }
+    inline void set_to_moon( float x, float y, float z) {
+       sgSetVec3( to_moon, x, y, z );
     }
-    inline double *get_surface_to_moon() { return surface_to_moon; }
-    inline void set_surface_to_moon( double x, double y, double z) {
-       surface_to_moon[0] = x;
-       surface_to_moon[1] = y;
-       surface_to_moon[2] = z;
+    inline float *get_surface_to_moon() { return surface_to_moon; }
+    inline void set_surface_to_moon( float x, float y, float z) {
+       sgSetVec3( surface_to_moon, x, y, z );
     }
-    inline double *get_surface_south() { return surface_south; }
-    inline double *get_surface_east() { return surface_east; }
-    inline double *get_local_up() { return local_up; }
-    inline double *get_view_forward() { return view_forward; }
-    inline const MAT3mat *get_WORLD_TO_EYE() const { return &WORLD_TO_EYE; }
+    inline float *get_surface_south() { return surface_south; }
+    inline float *get_surface_east() { return surface_east; }
+    inline float *get_local_up() { return local_up; }
+    inline float *get_view_forward() { return view_forward; }
     inline GLfloat *get_MODEL_VIEW() { return MODEL_VIEW; }
 };
 
 
+extern FGView pilot_view;
 extern FGView current_view;