source: experimental/TerrainTest/ModificationManager/ModificationManager.h @ 277

Last change on this file since 277 was 277, checked in by Torben Dannhauer, 13 years ago
File size: 4.4 KB
Line 
1#pragma once
2/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
3 *
4 * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under
5 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
6 * (at your option) any later version.  The full license is in LICENSE file
7 * included with this distribution, and on the openscenegraph.org website.
8 *
9 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
10 * You have to aquire licenses for all used proprietary modules.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * OpenSceneGraph Public License for more details.
16*/
17
18#include "region.h"
19#include "myTileLoadedCallback.h"
20#include "terrainModificationTechnique.h"
21#include <osgTerrain/Terrain>
22#include <osgTerrain/GeometryTechnique>
23#include <osg/observer_ptr>
24#include <vector>
25
26
27
28namespace osgTerrain {
29
30
31/**
32 * \brief This class provides a management interface to control terrain modification.
33 *
34 * It is possible to modify preprocessed VirtualPLanetBuilder (VPB) Databases on the fly.
35 * The modification can be performed in two ways:
36 * a) Modifying only the tile data and using the standard geometryTechnique to mesh the drawable.
37 * b) Using an userdefined geometryTechnique to create other meshes than the regular triangle mesh.
38 *
39 * Currently the changes are made on run time but in the pseudo loader. This way the modification does not affect the frame rate but only the delay in the tile delivery to the rendering thread.
40 *
41 * @author Torben Dannhauer
42 * @date  Mrz 2011
43 */ 
44class ModificationManager
45{
46public:
47        //! Destructor: Must be public to ensure the singleton can be cleand up at the end of the programm.
48        ~ModificationManager(){};
49
50        /**
51         * \brief This function returns a reference to the singleton instance of the terrain manager.
52         *
53         * @return Reference to the singleton instance of the terrain manager.
54         */ 
55        static ModificationManager* getInstance() {static ModificationManager instance; return &instance;}
56
57        /**
58         * \brief This function adds a terrain class to the manager to be managed and accessible to terrain modifications.
59         *
60         * @param terrain : Terrain to manage.
61         */ 
62        void addTerrainToManage(osgTerrain::Terrain* terrain);
63
64        /**
65         * \brief This functions removes a terrain class from the manager to stop it's managing.
66         *
67         * @param terrain : Terrain to remove.
68         * @return : True of the specified terrain was managed and is now removed. If the specified terrain was not managed it will return false.
69         */ 
70        bool removeTerrainToManage(osgTerrain::Terrain* terrain);
71
72
73
74        //void addRoi(region modificationROI, terrainModificationTechnique* technique=NULL);
75        //bool removeRoi(region modificationROI);
76
77
78
79        /**
80         * \brief This functions sets the geometryTechniqueProtoype. The geometryTechnique is responsible for creating a renderable mesh from the tile data.
81         *
82         * If you want to use a geometryTechnique different from the standard one, you have to use this function.
83         *
84         * @param geomTechnique : GeometryTechnique you want to use for the specified terrain.
85         * @param terrain : Terrain you want to set it's geometryTechniquePrototype. If NULL, the geometrytechnique will be applied to all terrains.
86         */ 
87        void setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain=NULL );
88
89        /**
90         * \brief This function sets the terrainModificationTechnique.
91         *
92         * The terrainModificationTechnique can modify the tile data before the data is used by the geometryTechnique to create the renderable mesh.
93         *
94         * @param terrainModTechnique
95         * @param terrain
96         */ 
97        void setTerrainModificationTechnique( osgTerrain::GeometryTechnique* terrainModTechnique, osgTerrain::Terrain* terrain=NULL );
98
99
100private:
101        //! Constructor: Private to avoid that this class can be instantiated - it should only be usable as singleton.
102        ModificationManager(){};
103
104        //! Copy-Constructor: Private to avoid that someone can create an class instance by copying the singleton instance.
105        ModificationManager(const ModificationManager& cc) {};
106
107        //! Vector of all managed terrain pointers.
108        std::vector<osgTerrain::Terrain*> managedTerrain;
109
110};
111
112}       // Namespace end.
Note: See TracBrowser for help on using the repository browser.