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

Last change on this file since 288 was 279, checked in by Torben Dannhauer, 14 years ago
File size: 4.5 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#include "Export.h"
27
28
29
30namespace osgTerrain {
31
32
33/**
34 * \brief This class provides a management interface to control terrain modification.
35 *
36 * It is possible to modify preprocessed VirtualPLanetBuilder (VPB) Databases on the fly.
37 * The modification can be performed in two ways:
38 * a) Modifying only the tile data and using the standard geometryTechnique to mesh the drawable.
39 * b) Using an userdefined geometryTechnique to create other meshes than the regular triangle mesh.
40 *
41 * 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.
42 *
43 * @author Torben Dannhauer
44 * @date  Mrz 2011
45 */ 
46class TERRAINMODMANAGER_EXPORT ModificationManager
47{
48public:
49        //! Destructor: Must be public to ensure the singleton can be cleand up at the end of the programm.
50        ~ModificationManager(){};
51
52        /**
53         * \brief This function returns a reference to the singleton instance of the terrain manager.
54         *
55         * @return Reference to the singleton instance of the terrain manager.
56         */ 
57        static ModificationManager* getInstance() {static ModificationManager instance; return &instance;}
58
59        /**
60         * \brief This function adds a terrain class to the manager to be managed and accessible to terrain modifications.
61         *
62         * @param terrain : Terrain to manage.
63         */ 
64        void addTerrainToManage(osgTerrain::Terrain* terrain);
65
66        /**
67         * \brief This functions removes a terrain class from the manager to stop it's managing.
68         *
69         * @param terrain : Terrain to remove.
70         * @return : True of the specified terrain was managed and is now removed. If the specified terrain was not managed it will return false.
71         */ 
72        bool removeTerrainToManage(osgTerrain::Terrain* terrain);
73
74
75
76        //void addRoi(region modificationROI, terrainModificationTechnique* technique=NULL);
77        //bool removeRoi(region modificationROI);
78
79
80
81        /**
82         * \brief This functions sets the geometryTechniqueProtoype. The geometryTechnique is responsible for creating a renderable mesh from the tile data.
83         *
84         * If you want to use a geometryTechnique different from the standard one, you have to use this function.
85         *
86         * @param geomTechnique : GeometryTechnique you want to use for the specified terrain.
87         * @param terrain : Terrain you want to set it's geometryTechniquePrototype. If NULL, the geometrytechnique will be applied to all terrains.
88         */ 
89        void setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain=NULL );
90
91        /**
92         * \brief This function sets the terrainModificationTechnique.
93         *
94         * The terrainModificationTechnique can modify the tile data before the data is used by the geometryTechnique to create the renderable mesh.
95         *
96         * @param terrainModTechnique
97         * @param terrain
98         */ 
99        void setTerrainModificationTechnique( osgTerrain::GeometryTechnique* terrainModTechnique, osgTerrain::Terrain* terrain=NULL );
100
101
102private:
103        //! Constructor: Private to avoid that this class can be instantiated - it should only be usable as singleton.
104        ModificationManager(){};
105
106        //! Copy-Constructor: Private to avoid that someone can create an class instance by copying the singleton instance.
107        ModificationManager(const ModificationManager& cc) {cc;};
108
109        //! Vector of all managed terrain pointers.
110        std::vector<osgTerrain::Terrain*> managedTerrain;
111
112};
113
114}       // Namespace end.
Note: See TracBrowser for help on using the repository browser.