root/OpenSceneGraph/trunk/src/osgPlugins/txp/TileMapper.h @ 13041

Revision 13041, 2.9 kB (checked in by robert, 3 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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
29namespace txp
30{
31
32struct TileIdentifier : public osg::Referenced
33{
34    TileIdentifier():
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
46    TileIdentifier(const TileIdentifier& rhs):
47        osg::Referenced(),
48        x(rhs.x),
49        y(rhs.y),
50        lod(rhs.lod)
51    {}
52
53    TileIdentifier& operator = (const TileIdentifier& rhs)
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
90class TileMapper : public osg::NodeVisitor, public osg::CullStack
91{
92public:
93
94    typedef osg::Matrix::value_type value_type;
95
96
97    TileMapper():
98        osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN) {}
99
100
101    virtual osg::Vec3 getEyePoint() const
102    {
103        return getEyeLocal();
104    }
105    virtual float getDistanceToEyePoint(const osg::Vec3& pos, bool withLODScale) const;
106    virtual float getDistanceFromEyePoint(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
117protected:
118
119    typedef std::map< TileIdentifier, int>        TileMap;
120    TileMap                                        _tileMap;
121    bool                                        _containsGeode;
122
123};
124
125} // namespace
126
127#endif // __TILEMAPPER_H_
Note: See TracBrowser for help on using the browser.