source: experimental/TerrainTest/ModificationManager.cpp @ 276

Last change on this file since 276 was 276, checked in by Torben Dannhauer, 13 years ago
File size: 2.0 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#define USE_TERRAIN_PROTO_WORKAROUND USE_TERRAIN_PROTO_WORKAROUND
20
21
22void ModificationManager::addTerrainToManage(osgTerrain::Terrain* terrain)
23{
24        if(terrain)
25                managedTerrain.push_back(terrain);
26}
27
28bool ModificationManager::removeTerrainToManage(osgTerrain::Terrain* terrain)
29{
30        for(unsigned int i=0;i<managedTerrain.size();i++)
31        {
32                if(managedTerrain[i] == terrain)
33                {
34                        managedTerrain.erase(managedTerrain.begin()+i);
35                        return true;
36                }
37        }
38        return false;
39}
40
41void ModificationManager::setGeometryTechniquePrototype( osgTerrain::GeometryTechnique* geomTechnique, osgTerrain::Terrain* terrain )
42{
43        if(!geomTechnique)      // Remove the installed geometry technique
44        {
45                terrain->setTerrainTechniquePrototype( NULL );
46#ifdef USE_TERRAIN_PROTO_WORKAROUND
47                osgTerrain::TerrainTile::setTileLoadedCallback(NULL);
48#endif
49                return;
50        }
51
52
53        terrain->setTerrainTechniquePrototype( geomTechnique );
54#ifdef USE_TERRAIN_PROTO_WORKAROUND
55        osg::ref_ptr<osgTerrain::GeometryTechniquePrototypeWorkaroundTLC> tlcb = new osgTerrain::GeometryTechniquePrototypeWorkaroundTLC();
56        osgTerrain::TerrainTile::setTileLoadedCallback(tlcb);
57#endif
58
59
60}
61
Note: See TracBrowser for help on using the repository browser.