source: experimental/TerrainTest/ellipsoidTechnique.cpp @ 417

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