]> git.mxchange.org Git - flightgear.git/blob - src/Main/viewer.cxx
Continued FGViewer cleanups. FGViewer is now a base class so that we can
[flightgear.git] / src / Main / viewer.cxx
1 // viewer.cxx -- class for managing a viewer in the flightgear world.
2 //
3 // Written by Curtis Olson, started August 1997.
4 //                          overhaul started October 2000.
5 //
6 // Copyright (C) 1997 - 2000  Curtis L. Olson  - curt@flightgear.org
7 //
8 // This program is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU General Public License as
10 // published by the Free Software Foundation; either version 2 of the
11 // License, or (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful, but
14 // WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 // General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 //
22 // $Id$
23
24
25 #include <simgear/compiler.h>
26
27 #ifdef HAVE_CONFIG_H
28 #  include <config.h>
29 #endif
30
31 #include <plib/ssg.h>           // plib include
32
33 #include <simgear/constants.h>
34 #include <simgear/debug/logstream.hxx>
35 #include <simgear/math/point3d.hxx>
36 #include <simgear/math/polar3d.hxx>
37 #include <simgear/math/vector.hxx>
38
39 #include "globals.hxx"
40 #include "viewer.hxx"
41
42
43 // Constructor
44 FGViewer::FGViewer( void )
45 {
46 }
47
48
49 #define USE_FAST_VIEWROT
50 #ifdef USE_FAST_VIEWROT
51 // VIEW_ROT = LARC_TO_SSG * ( VIEWo * VIEW_OFFSET )
52 // This takes advantage of the fact that VIEWo and VIEW_OFFSET
53 // only have entries in the upper 3x3 block
54 // and that LARC_TO_SSG is just a shift of rows   NHV
55 inline static void fgMakeViewRot( sgMat4 dst, const sgMat4 m1, const sgMat4 m2 )
56 {
57     for ( int j = 0 ; j < 3 ; j++ ) {
58         dst[2][j] = m2[0][0] * m1[0][j] +
59             m2[0][1] * m1[1][j] +
60             m2[0][2] * m1[2][j];
61
62         dst[0][j] = m2[1][0] * m1[0][j] +
63             m2[1][1] * m1[1][j] +
64             m2[1][2] * m1[2][j];
65
66         dst[1][j] = m2[2][0] * m1[0][j] +
67             m2[2][1] * m1[1][j] +
68             m2[2][2] * m1[2][j];
69     }
70     dst[0][3] = 
71         dst[1][3] = 
72         dst[2][3] = 
73         dst[3][0] = 
74         dst[3][1] = 
75         dst[3][2] = SG_ZERO;
76     dst[3][3] = SG_ONE;
77 }
78 #endif
79
80
81 // Initialize a view structure
82 void FGViewer::init( void ) {
83     FG_LOG( FG_VIEW, FG_ALERT, "Shouldn't ever see this" );
84     exit(-1);
85 }
86
87
88 // Update the view parameters
89 void FGViewer::update() {
90     FG_LOG( FG_VIEW, FG_ALERT, "Shouldn't ever see this" );
91     exit(-1);
92 }
93
94
95 // Destructor
96 FGViewer::~FGViewer( void ) {
97 }