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

Last change on this file since 277 was 277, checked in by Torben Dannhauer, 13 years ago
File size: 2.4 KB
Line 
1/* -*-c++-*- osgVisual - Copyright (C) 2009-2011 Torben Dannhauer
2 *
3 * This library is based on OpenSceneGraph, 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 * osgVisual requires for some proprietary modules a license from the correspondig manufacturer.
9 * You have to aquire licenses for all used proprietary modules.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * OpenSceneGraph Public License for more details.
15*/
16
17#include "ModificationManager.h"
18
19// Used geometryTechniques
20#include "myTerrainTechnique.h"
21
22// Used terrainTechniques.
23//-
24
25#define USE_TERRAIN_PROTO_WORKAROUND USE_TERRAIN_PROTO_WORKAROUND
26
27
28using namespace osgTerrain;
29
30void ModificationManager::addTerrainToManage(osgTerrain::Terrain* terrain)
31{
32        if(terrain)
33                managedTerrain.push_back(terrain);
34}
35
36bool ModificationManager::removeTerrainToManage(osgTerrain::Terrain* terrain)
37{
38        for(unsigned int i=0;i<managedTerrain.size();i++)
39        {
40                if(managedTerrain[i] == terrain)
41                {
42                        managedTerrain.erase(managedTerrain.begin()+i);
43                        return true;
44                }
45        }
46        return false;
47}
48
49void ModificationManager::setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain )
50{
51        for(unsigned int i=0;i<managedTerrain.size();i++)
52        {
53                if(terrain==NULL || terrain==managedTerrain[i])
54                {
55                        if(!geomTechnique)      // Remove the installed geometry technique
56                        {
57                                terrain->setTerrainTechniquePrototype( NULL );
58                                #ifdef USE_TERRAIN_PROTO_WORKAROUND
59                                                osgTerrain::TerrainTile::setTileLoadedCallback(NULL);
60                                #endif
61                        }
62                        else
63                        {
64                                terrain->setTerrainTechniquePrototype( geomTechnique );
65                                #ifdef USE_TERRAIN_PROTO_WORKAROUND
66                                        osg::ref_ptr<osgTerrain::GeometryTechniquePrototypeWorkaroundTLC<osgTerrain::myTerrainTechnique> > tlcb = new osgTerrain::GeometryTechniquePrototypeWorkaroundTLC<osgTerrain::myTerrainTechnique>();
67                                        osgTerrain::TerrainTile::setTileLoadedCallback(tlcb);
68                                #endif
69                        }
70                        return;
71                }       // IF END
72        }       // FOR END
73}
74
Note: See TracBrowser for help on using the repository browser.