VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TileMapper.h
Go to the documentation of this file.
1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2004 Robert Osfield
2  *
3  * This library is open source and may be redistributed and/or modified under
4  * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5  * (at your option) any later version. The full license is in LICENSE file
6  * included with this distribution, and on the openscenegraph.org website.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * OpenSceneGraph Public License for more details.
12 */
13 
14 /* Dec 2010 - TileMapper was fixed and simplified
15  Nick
16 */
17 
18 #ifndef __TILEMAPPER_H_
19 #define __TILEMAPPER_H_
20 
21 #include "trpage_sys.h"
22 #include "trpage_read.h"
23 
24 #include <osg/CullStack>
25 #include <osg/NodeVisitor>
26 
27 #include <set>
28 
29 namespace txp
30 {
31 
32 struct TileIdentifier : public osg::Referenced
33 {
35  x(-1),
36  y(-1),
37  lod(-1)
38  {}
39 
40  TileIdentifier(int ax, int ay, int alod):
41  x(ax),
42  y(ay),
43  lod(alod)
44  {}
45 
47  osg::Referenced(),
48  x(rhs.x),
49  y(rhs.y),
50  lod(rhs.lod)
51  {}
52 
54  {
55  if (this==&rhs) return *this;
56  x = rhs.x;
57  y = rhs.y;
58  lod = rhs.lod;
59  return *this;
60  }
61 
62  void set(int ax, int ay, int alod)
63  {
64  x = ax;
65  y = ay;
66  lod = alod;
67  }
68 
69  bool operator < (const TileIdentifier& rhs) const
70  {
71  if (lod<rhs.lod)
72  return true;
73  if (lod>rhs.lod)
74  return false;
75  if (x<rhs.x)
76  return true;
77  if (x>rhs.x)
78  return false;
79  if (y<rhs.y)
80  return true;
81  if (y>rhs.y)
82  return false;
83  return false;
84  }
85 
86  int x,y,lod;
87 
88 };
89 
90 class TileMapper : public osg::NodeVisitor, public osg::CullStack
91 {
92 public:
93 
94  typedef osg::Matrix::value_type value_type;
95 
96 
98  osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN) {}
99 
100 
101  virtual void setCullVisitorForDistance(osg::NodeVisitor* nv)
102  {
103  _nodeVisitor = nv;
104  }
105 
106  virtual float getDistanceToViewPoint(const osg::Vec3& pos, bool withLODScale) const;
107 
108  virtual void apply(osg::Node& node);
109  virtual void apply(osg::Group& node);
110  virtual void apply(osg::Geode& node);
111  virtual void apply(osg::PagedLOD& node);
112 
113  void insertTile(const TileIdentifier& tid);
114 
115  bool isTileNeighbourALowerLODLevel(const TileIdentifier& tid, int dx, int dy) const;
116 
117 protected:
118 
119  typedef std::map< TileIdentifier, int> TileMap;
123 
124 };
125 
126 }
127 
128 #endif
void insertTile(const TileIdentifier &tid)
TileIdentifier(const TileIdentifier &rhs)
Definition: TileMapper.h:46
TileMap _tileMap
Definition: TileMapper.h:120
std::map< TileIdentifier, int > TileMap
Definition: TileMapper.h:119
int lod
Definition: TileMapper.h:86
int y
Definition: TileMapper.h:86
virtual float getDistanceToViewPoint(const osg::Vec3 &pos, bool withLODScale) const
virtual void setCullVisitorForDistance(osg::NodeVisitor *nv)
Definition: TileMapper.h:101
Definition: TileMapper.h:90
osg::ref_ptr< osg::NodeVisitor > _nodeVisitor
Definition: TileMapper.h:122
TileMapper()
Definition: TileMapper.h:97
TileIdentifier()
Definition: TileMapper.h:34
TileIdentifier & operator=(const TileIdentifier &rhs)
Definition: TileMapper.h:53
bool operator<(const TileIdentifier &rhs) const
Definition: TileMapper.h:69
osg::Matrix::value_type value_type
Definition: TileMapper.h:94
Definition: TileMapper.h:32
int x
Definition: TileMapper.h:86
virtual void apply(osg::Node &node)
void set(int ax, int ay, int alod)
Definition: TileMapper.h:62
bool _containsGeode
Definition: TileMapper.h:121
bool isTileNeighbourALowerLODLevel(const TileIdentifier &tid, int dx, int dy) const
TileIdentifier(int ax, int ay, int alod)
Definition: TileMapper.h:40

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)