1 | #include "ModificationVisitor.h" |
---|
2 | |
---|
3 | using namespace osgTerrain; |
---|
4 | |
---|
5 | ModificationVisitor::ModificationVisitor(std::string extensionToSet) : _extensionToSet(extensionToSet) |
---|
6 | { |
---|
7 | setTraversalMode( osg::NodeVisitor::TRAVERSE_ALL_CHILDREN ); |
---|
8 | } |
---|
9 | |
---|
10 | void ModificationVisitor::apply( osg::Node& node ) |
---|
11 | { |
---|
12 | //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: Node found: " << node.className() << std::endl; |
---|
13 | |
---|
14 | if(std::string(node.className())=="TerrainTile") |
---|
15 | { |
---|
16 | //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: Tile found" << std::endl; |
---|
17 | osgTerrain::TerrainTile* tile = dynamic_cast<osgTerrain::TerrainTile*>(&node); |
---|
18 | if(tile) |
---|
19 | modifyTile(tile); |
---|
20 | } |
---|
21 | |
---|
22 | traverse( node ); |
---|
23 | } |
---|
24 | |
---|
25 | void ModificationVisitor::apply( osg::PagedLOD& pNode ) |
---|
26 | { |
---|
27 | //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD found: " << pNode.className() << std::endl; |
---|
28 | |
---|
29 | for( unsigned int i=0;i<pNode.getNumFileNames();i++) |
---|
30 | { |
---|
31 | //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD Child #" << i << std::endl; |
---|
32 | if(pNode.getFileName(i)!="") |
---|
33 | { |
---|
34 | //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD Child Name pre: " << pNode.getFileName(i) << std::endl; |
---|
35 | pNode.setFileName(i, pNode.getFileName(i)+_extensionToSet ); |
---|
36 | //OSG_NOTIFY( osg::ALWAYS ) << "ModVisitor: pagedLOD Child Name post: " << newFileName << std::endl; |
---|
37 | } |
---|
38 | } |
---|
39 | |
---|
40 | traverse( pNode ); |
---|
41 | } |
---|
42 | |
---|
43 | void ModificationVisitor::modifyTile(osgTerrain::TerrainTile* tile) |
---|
44 | { |
---|
45 | OSG_NOTIFY( osg::ALWAYS ) << "ModificationVisitor::modifyTile()" << std::endl; |
---|
46 | OpenThreads::Thread::microSleep( 500000 ); |
---|
47 | |
---|
48 | HeightFieldLayer* hfl = dynamic_cast<HeightFieldLayer*>(tile->getElevationLayer()); |
---|
49 | osg::HeightField* h = hfl->getHeightField(); |
---|
50 | OSG_NOTIFY( osg::ALWAYS ) << "Origin: " << h->getOrigin()[0] <<" | "<<h->getOrigin()[1]<<" | "<<h->getOrigin()[2] << std::endl; |
---|
51 | OSG_NOTIFY( osg::ALWAYS ) << "X-Intervall: " << h->getXInterval() << std::endl; |
---|
52 | OSG_NOTIFY( osg::ALWAYS ) << "Y-Intervall: " << h->getYInterval() << std::endl; |
---|
53 | |
---|
54 | |
---|
55 | // Determine if tile touches ROI |
---|
56 | |
---|
57 | // calculate colum start/end and row start/end of affected vertices |
---|
58 | |
---|
59 | // modify height value of affected vertices |
---|
60 | } |
---|