Changeset 848

Show
Ignore:
Timestamp:
01/17/08 23:26:01
Author:
robert
Message:

Added computation of skirt heights for osgTerrain::Terrain code path

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/vpb/Destination.cpp

    r844 r848  
    12231223    if (!shapeDrawable) return 0; 
    12241224 
    1225     hf->setSkirtHeight(shapeDrawable->getBound().radius()*0.01f); 
     1225    hf->setSkirtHeight(shapeDrawable->getBound().radius()*_dataSet->getSkirtRatio()); 
    12261226 
    12271227    osg::StateSet* stateset = createStateSet(); 
     
    13561356    } 
    13571357 
     1358 
    13581359    osg::HeightField* hf = _terrain->_heightField.get(); 
    1359  
    1360     // need to work out what the skirt should be... 
    1361     hf->setSkirtHeight(0.01f); 
     1360    osg::EllipsoidModel* em = _dataSet->getEllipsoidModel(); 
    13621361        
    13631362    // set up the locator place the data all in the correction position 
    13641363    osgTerrain::Locator* locator = new osgTerrain::Locator; 
    1365     locator->setEllipsoidModel(_dataSet->getEllipsoidModel()); 
     1364    locator->setEllipsoidModel(em); 
    13661365     
    13671366    if (_dataSet->getDestinationCoordinateSystemNode()) 
     
    13701369        locator->setCoordinateSystem(_dataSet->getDestinationCoordinateSystemNode()->getCoordinateSystem()); 
    13711370    } 
     1371     
     1372     
     1373    double radius = (_extents._max-_extents._min).length()*0.5; 
    13721374     
    13731375    if (_dataSet->getConvertFromGeographicToGeocentric())  
     
    13781380                                       osg::DegreesToRadians(_extents.xMax()),  
    13791381                                       osg::DegreesToRadians(_extents.yMax())); 
     1382 
     1383        if (em) 
     1384        { 
     1385            double midLong = hf->getOrigin().x() + hf->getXInterval()*((double)(hf->getNumColumns()-1))*0.5; 
     1386            double midLat = hf->getOrigin().y() + hf->getYInterval()*((double)(hf->getNumRows()-1))*0.5; 
     1387 
     1388            double X,Y,Z = hf->getOrigin().z(); 
     1389            em->convertLatLongHeightToXYZ(osg::DegreesToRadians(midLat),osg::DegreesToRadians(midLong),Z, X,Y,Z); 
     1390            osg::Vec3d center_position(X,Y,Z); 
     1391 
     1392            Z = hf->getOrigin().z(); 
     1393            em->convertLatLongHeightToXYZ(osg::DegreesToRadians(hf->getOrigin().y()),osg::DegreesToRadians(hf->getOrigin().x()),Z, X,Y,Z); 
     1394            osg::Vec3d origin(X,Y,Z); 
     1395             
     1396            radius = (origin-center_position).length(); 
     1397        }             
     1398 
    13801399    } 
    13811400    else 
     
    13891408        // locator->setCoordinateSystemType(osgTerrain::Locator::GEOGRAPHIC); 
    13901409    } 
     1410 
     1411    // need to work out what the skirt should be... 
     1412    hf->setSkirtHeight(radius*_dataSet->getSkirtRatio()); 
    13911413 
    13921414    // create the terrain node that we'll hang the height field off