Exemplo n.º 1
0
float
HeightFieldUtils::getHeightAtNormalizedLocation(const HeightFieldNeighborhood& hood,
        double nx, double ny,
        ElevationInterpolation interp)
{
    osg::ref_ptr<osg::HeightField> hf;
    double nx2, ny2;
    hood.getNeighborForNormalizedLocation(nx, ny, hf, nx2, ny2);
    double px = osg::clampBetween(nx2, 0.0, 1.0) * (double)(hf->getNumColumns() - 1);
    double py = osg::clampBetween(ny2, 0.0, 1.0) * (double)(hf->getNumRows() - 1);
    return getHeightAtPixel( hf.get(), px, py, interp );
}
Exemplo n.º 2
0
bool
HeightFieldUtils::getHeightAtNormalizedLocation(const HeightFieldNeighborhood& hood,
                                                double nx, double ny,
                                                float& output,
                                                ElevationInterpolation interp)
{
    osg::HeightField* hf = 0L;
    //osg::ref_ptr<osg::HeightField> hf;
    double nx2, ny2;
    if ( hood.getNeighborForNormalizedLocation(nx, ny, hf, nx2, ny2) )
    {
        double px = osg::clampBetween(nx2, 0.0, 1.0) * (double)(hf->getNumColumns() - 1);
        double py = osg::clampBetween(ny2, 0.0, 1.0) * (double)(hf->getNumRows() - 1);
        output = getHeightAtPixel( hf, px, py, interp );
        return true;
    }
    return false;
}