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

Last change on this file since 285 was 279, checked in by Torben Dannhauer, 14 years ago
File size: 2.3 KB
RevLine 
[277]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
26
27using namespace osgTerrain;
28
29void ModificationManager::addTerrainToManage(osgTerrain::Terrain* terrain)
30{
31        if(terrain)
32                managedTerrain.push_back(terrain);
33}
34
35bool ModificationManager::removeTerrainToManage(osgTerrain::Terrain* terrain)
36{
37        for(unsigned int i=0;i<managedTerrain.size();i++)
38        {
39                if(managedTerrain[i] == terrain)
40                {
41                        managedTerrain.erase(managedTerrain.begin()+i);
42                        return true;
43                }
44        }
45        return false;
46}
47
48void ModificationManager::setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain )
49{
50        for(unsigned int i=0;i<managedTerrain.size();i++)
51        {
52                if(terrain==NULL || terrain==managedTerrain[i])
53                {
54                        if(!geomTechnique)      // Remove the installed geometry technique
55                        {
56                                terrain->setTerrainTechniquePrototype( NULL );
57                                #ifdef USE_TERRAIN_PROTO_WORKAROUND
58                                                osgTerrain::TerrainTile::setTileLoadedCallback(NULL);
59                                #endif
60                        }
61                        else
62                        {
63                                terrain->setTerrainTechniquePrototype( geomTechnique );
64                                #ifdef USE_TERRAIN_PROTO_WORKAROUND
65                                        osg::ref_ptr<osgTerrain::GeometryTechniquePrototypeWorkaroundTLC<osgTerrain::myTerrainTechnique> > tlcb = new osgTerrain::GeometryTechniquePrototypeWorkaroundTLC<osgTerrain::myTerrainTechnique>();
66                                        osgTerrain::TerrainTile::setTileLoadedCallback(tlcb);
67                                #endif
68                        }
69                        return;
70                }       // IF END
71        }       // FOR END
72}
73
Note: See TracBrowser for help on using the repository browser.