]> git.mxchange.org Git - simgear.git/blob - simgear/scene/util/SGUpdateVisitor.hxx
Modified Files:
[simgear.git] / simgear / scene / util / SGUpdateVisitor.hxx
1 /* -*-c++-*-
2  *
3  * Copyright (C) 2006 Mathias Froehlich 
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License as
7  * published by the Free Software Foundation; either version 2 of the
8  * License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  * MA 02110-1301, USA.
19  *
20  */
21
22 #ifndef SG_SCENE_UPDATEVISITOR_HXX
23 #define SG_SCENE_UPDATEVISITOR_HXX
24
25 #include <osg/NodeVisitor>
26 #include <osgUtil/UpdateVisitor>
27
28 class SGUpdateVisitor : public osgUtil::UpdateVisitor {
29 public:
30   SGUpdateVisitor()
31   {
32     setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
33   }
34   void setViewData(const SGVec3d& globalEyePos,
35                    const SGQuatd& globalViewOrientation)
36   {
37     mGlobalGeodEyePos = SGGeod::fromCart(globalEyePos);
38     mGlobalEyePos = globalEyePos;
39     mGlobalViewOr = globalViewOrientation;
40     mGlobalHorizLocalOr = SGQuatd::fromLonLat(mGlobalGeodEyePos);
41     mHorizLocalNorth = mGlobalHorizLocalOr.backTransform(SGVec3d(1, 0, 0));
42     mHorizLocalEast = mGlobalHorizLocalOr.backTransform(SGVec3d(0, 1, 0));
43     mHorizLocalDown = mGlobalHorizLocalOr.backTransform(SGVec3d(0, 0, 1));
44   }
45
46   void setSceneryCenter(const SGVec3d& sceneryCenter)
47   {
48     mSceneryCenter = sceneryCenter;
49   }
50
51   void setVisibility(double visibility)
52   {
53     mVisibility = visibility;
54     mSqrVisibility = visibility*visibility;
55   }
56
57   double getVisibility() const
58   { return mVisibility; }
59   double getSqrVisibility() const
60   { return mSqrVisibility; }
61
62   const SGVec3d& getGlobalEyePos() const
63   { return mGlobalEyePos; }
64   const SGGeod& getGeodEyePos() const
65   { return mGlobalGeodEyePos; }
66   const SGQuatd& getGlobalViewOr() const
67   { return mGlobalViewOr; }
68   const SGQuatd& getGlobalHorizLocalOr() const
69   { return mGlobalViewOr; }
70   const SGVec3d& getHorizLocalNorth() const
71   { return mHorizLocalNorth; }
72   const SGVec3d& getHorizLocalEast() const
73   { return mHorizLocalEast; }
74   const SGVec3d& getHorizLocalDown() const
75   { return mHorizLocalDown; }
76 private:
77   SGGeod mGlobalGeodEyePos;
78   SGVec3d mGlobalEyePos;
79   SGQuatd mGlobalViewOr;
80   SGQuatd mGlobalHorizLocalOr;
81   SGVec3d mHorizLocalNorth;
82   SGVec3d mHorizLocalEast;
83   SGVec3d mHorizLocalDown;
84
85   SGVec3d mSceneryCenter;
86
87   double mVisibility;
88   double mSqrVisibility;
89 };
90
91 #endif