source: experimental/TerrainTest/ellipsoidTechnique.cpp @ 274

Last change on this file since 274 was 274, checked in by Torben Dannhauer, 14 years ago
  • Property svn:eol-style set to native
File size: 2.2 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 "ellipsoidTechnique.h"
18
19
20ellipsoidTechnique::ellipsoidTechnique()
21{
22        _height = 0.0;
23}
24
25ellipsoidTechnique::~ellipsoidTechnique()
26{
27}
28
29void ellipsoidTechnique::modifyHeightfield(region& modificationROI, osg::HeightField* h, region tileExtends)
30{
31        //OSG_NOTIFY( osg::ALWAYS ) << "ellipsoidTechnique::modifyHeightfield()" << std::endl;
32        //OSG_NOTIFY( osg::ALWAYS ) << "LAT: " << tileExtends._lat_min << " | " << tileExtends._lat_max << std::endl;
33        //OSG_NOTIFY( osg::ALWAYS ) << "LON: " << tileExtends._lon_min << " | " << tileExtends._lon_max << std::endl;
34
35        // calculate colum start/end and row start/end of affected vertices
36        int startX=0, startY=0, endX=h->getNumColumns(), endY=h->getNumRows();
37
38       
39        // Determine loop variables..
40        if(tileExtends._lat_min<modificationROI._lat_min)
41                startY = round((modificationROI._lat_min - tileExtends._lat_min) / h->getYInterval());
42        if(tileExtends._lat_max>modificationROI._lat_max)
43                endY = round((modificationROI._lat_max - tileExtends._lat_min) / h->getYInterval());
44
45        if(tileExtends._lon_min<modificationROI._lon_min)
46                startX = round((modificationROI._lon_min - tileExtends._lon_min) / h->getXInterval());
47        if(tileExtends._lon_max>modificationROI._lon_max)
48                endX = round((modificationROI._lon_max - tileExtends._lon_min) / h->getXInterval());
49
50
51        // Modify height value of affected vertices
52        for(int x=startX;x<endX;x++)
53        {
54                for(int y=startY;y<endY;y++)
55                {
56                        h->setHeight( x, y, _height);
57                }
58        }
59}
60
Note: See TracBrowser for help on using the repository browser.