1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2009 Robert Osfield
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.
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.
15#define OSGVOLUME_tile 1
20#include <osgDB/ReaderWriter>
22#include <osgVolume/Layer>
23#include <osgVolume/VolumeTechnique>
29class OSGVOLUME_EXPORT TileID
35 TileID(int in_level, int in_x, int in_y, int in_z);
37 bool operator == (const TileID& rhs) const
39 return (level==rhs.level) && (x==rhs.x) && (y==rhs.y) && (z==rhs.z);
42 bool operator != (const TileID& rhs) const
44 return (level!=rhs.level) || (x!=rhs.x) || (y!=rhs.y) || (z!=rhs.z);
47 bool operator < (const TileID& rhs) const
49 if (level<rhs.level) return true;
50 if (level>rhs.level) return false;
51 if (x<rhs.x) return true;
52 if (x>rhs.x) return false;
53 if (y<rhs.y) return true;
54 if (y>rhs.y) return false;
58 bool valid() const { return level>=0; }
67/** VolumeTile provides a framework for loosely coupling 3d image data with rendering algorithms.
68 * This allows TerrainTechnique's to be plugged in at runtime.*/
69class OSGVOLUME_EXPORT VolumeTile : public osg::Group
75 /** Copy constructor using CopyOp to manage deep vs shallow copy.*/
76 VolumeTile(const VolumeTile&,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
78 META_Node(osgVolume, VolumeTile);
80 virtual void traverse(osg::NodeVisitor& nv);
82 /** Call init on any attached TerrainTechnique.*/
86 /** Set the Volume that this Volume tile is a member of.*/
87 void setVolume(Volume* ts);
89 /** Get the Volume that this Volume tile is a member of.*/
90 Volume* getVolume() { return _volume; }
92 /** Get the const Volume that this Volume tile is a member of.*/
93 const Volume* getVolume() const { return _volume; }
96 /** Set the TileID (layer, x,y,z) of the VolumeTile.
97 * The TileID is used so it can be located by its neighbours
98 * via the enclosing Volume node that manages a map of TileID to VolumeTiles.*/
99 void setTileID(const TileID& tileID);
101 /** Get the TileID (layer, x,y,z) of the VolumeTile.*/
102 const TileID& getTileID() const { return _tileID; }
105 void setLocator(Locator* locator) { _locator = locator; }
106 Locator* getLocator() { return _locator.get(); }
107 const Locator* getLocator() const { return _locator.get(); }
110 void setLayer(Layer* layer);
111 Layer* getLayer() { return _layer.get(); }
112 const Layer* getLayer() const { return _layer.get(); }
116 /** Set the VolumeTechnique that will be used to render this tile. */
117 void setVolumeTechnique(VolumeTechnique* VolumeTechnique);
119 /** Get the VolumeTechnique that will be used to render this tile. */
120 VolumeTechnique* getVolumeTechnique() { return _volumeTechnique.get(); }
122 /** Get the const VolumeTechnique that will be used to render this tile. */
123 const VolumeTechnique* getVolumeTechnique() const { return _volumeTechnique.get(); }
126 /** Set the dirty flag on/off.*/
127 void setDirty(bool dirty);
129 /** return true if the tile is dirty and needs to be updated,*/
130 bool getDirty() const { return _dirty; }
133 virtual osg::BoundingSphere computeBound() const;
137 virtual ~VolumeTile();
144 bool _hasBeenTraversal;
148 osg::ref_ptr<VolumeTechnique> _volumeTechnique;
150 osg::ref_ptr<Locator> _locator;
152 osg::ref_ptr<Layer> _layer;