3 * Copyright (C) 2006 Mathias Froehlich
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.
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.
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,
22 #ifndef SG_SCENE_UPDATEVISITOR_HXX
23 #define SG_SCENE_UPDATEVISITOR_HXX
25 #include <osg/NodeVisitor>
26 #include <osgUtil/UpdateVisitor>
28 class SGUpdateVisitor : public osgUtil::UpdateVisitor {
32 setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
34 void setViewData(const SGVec3d& globalEyePos,
35 const SGQuatd& globalViewOrientation)
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));
46 void setSceneryCenter(const SGVec3d& sceneryCenter)
48 mSceneryCenter = sceneryCenter;
51 void setVisibility(double visibility)
53 mVisibility = visibility;
54 mSqrVisibility = visibility*visibility;
57 double getVisibility() const
58 { return mVisibility; }
59 double getSqrVisibility() const
60 { return mSqrVisibility; }
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; }
77 SGGeod mGlobalGeodEyePos;
78 SGVec3d mGlobalEyePos;
79 SGQuatd mGlobalViewOr;
80 SGQuatd mGlobalHorizLocalOr;
81 SGVec3d mHorizLocalNorth;
82 SGVec3d mHorizLocalEast;
83 SGVec3d mHorizLocalDown;
85 SGVec3d mSceneryCenter;
88 double mSqrVisibility;