From Ulrich Hertlein, "attached are patches to osgTerrain that fix some typos and add a bit of documentation.

"
This commit is contained in:
Robert Osfield 2010-12-08 10:34:29 +00:00
parent ebeed76643
commit 3d67b7a7eb
4 changed files with 54 additions and 19 deletions

View File

@ -31,7 +31,7 @@ namespace osgTerrain {
extern OSGTERRAIN_EXPORT void extractSetNameAndFileName(const std::string& compoundstring, std::string& setname, std::string& filename);
/** Create a compound string in the form set:setname:filename, or just filename if setname is "".*/
extern OSGTERRAIN_EXPORT std::string createCompondSetNameAndFileName(const std::string& setname, const std::string& filename);
extern OSGTERRAIN_EXPORT std::string createCompoundSetNameAndFileName(const std::string& setname, const std::string& filename);
class OSGTERRAIN_EXPORT Layer : public osg::Object
{
@ -44,7 +44,10 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
META_Object(osgTerrain, Layer);
/** Set the name of this layer. */
void setSetName(const std::string& setname) { setName(setname); }
/** Get the name of this layer. */
const std::string& getSetName() const { return getName(); }
/** Set the file name of the data associated with this layer. */
@ -54,7 +57,7 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
virtual const std::string& getFileName() const { return _filename; }
/** Return the compound name of the layer in the form set::name::filename string.*/
std::string getCompoundName() const { return createCompondSetNameAndFileName(getName(), getFileName()); }
std::string getCompoundName() const { return createCompoundSetNameAndFileName(getName(), getFileName()); }
void setLocator(Locator* locator) { _locator = locator; }
Locator* getLocator() { return _locator.get(); }
@ -66,29 +69,37 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
void setMaxLevel(unsigned int maxLevel) { _maxLevel = maxLevel; }
unsigned int getMaxLevel() const { return _maxLevel; }
/** Set the data validation operator. */
void setValidDataOperator(ValidDataOperator* validDataOp) { _validDataOperator = validDataOp; }
/** Get the data validation operator. */
ValidDataOperator* getValidDataOperator() { return _validDataOperator.get(); }
/** Get the const data validation operator. */
const ValidDataOperator* getValidDataOperator() const { return _validDataOperator.get(); }
/** Get the number of columns. */
virtual unsigned int getNumColumns() const { return 0; }
/** Get the number of rows. */
virtual unsigned int getNumRows() const { return 0; }
void setDefaultValue(const osg::Vec4& value) { _defaultValue = value; }
const osg::Vec4& getDefaultValue() const { return _defaultValue; }
/** Set the minification texture filter to use when do texture associated with this layer.*/
/** Set the minification texture filter to use when a texture is associated with this layer.*/
void setMinFilter(osg::Texture::FilterMode filter) { _minFilter = filter; }
/** Get the minification texture filter to use when do texture associated with this layer.*/
/** Get the minification texture filter to use when a texture is associated with this layer.*/
osg::Texture::FilterMode getMinFilter() const { return _minFilter; }
/** Set the magniification texture filter to use when do texture associated with this layer.*/
/** Set the magnification texture filter to use when a texture is associated with this layer.*/
void setMagFilter(osg::Texture::FilterMode filter) { _magFilter = filter; }
/** Get the magnification texture filter to use when do texture associated with this layer.*/
/** Get the magnification texture filter to use when a texture is associated with this layer.*/
osg::Texture::FilterMode getMagFilter() const { return _magFilter; }
@ -102,7 +113,13 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
virtual bool transform(float /*offset*/, float /*scale*/) { return false; }
/**
* Get the layer value at position i,j.
* @param[in] i X-axis (or column) index.
* @param[in] j Y-axis (or row) index.
* @param[out] value Returned layer value.
* @return true if value is valid, else false
*/
virtual bool getValue(unsigned int /*i*/, unsigned int /*j*/, float& /*value*/) const { return false; }
virtual bool getValue(unsigned int /*i*/, unsigned int /*j*/, osg::Vec2& /*value*/) const { return false; }
virtual bool getValue(unsigned int /*i*/, unsigned int /*j*/, osg::Vec3& /*value*/) const { return false; }
@ -133,6 +150,15 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
}
/**
* Compute column,row indices from normalized coordinates.
* @param[in] ndc_x Normalized X-axis coordinate.
* @param[in] ndc_y Normalized Y-axis coordinate.
* @param[out] i Returned X-axis (or column) index.
* @param[out] j Returned Y-axis (or row) index.
* @param[out] ir Returned X-axis fraction.
* @param[out] jr Returned Y-axis fraction.
*/
inline void computeIndices(double ndc_x, double ndc_y, unsigned int& i, unsigned int& j, double& ir, double& jr)
{
ndc_x *= double(getNumColumns()-1);
@ -143,7 +169,13 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
jr = ndc_y - double(j);
}
/**
* Calculate the interpolated layer value at the given normalized coordinates.
* @param[in] ndc_x Normalized X-axis coordinate.
* @param[in] ndc_y Normalized Y-axis coordinate.
* @param[out] value Returned layer value.
* @return true if value is valid, else false
*/
inline bool getInterpolatedValue(double ndc_x, double ndc_y, float& value)
{
unsigned int i,j;
@ -239,10 +271,10 @@ class OSGTERRAIN_EXPORT Layer : public osg::Object
}
/** increment the modified count."*/
virtual void dirty() {};
virtual void dirty() {}
/** Set the modified count value. */
virtual void setModifiedCount(unsigned int /*value*/) {};
virtual void setModifiedCount(unsigned int /*value*/) {}
/** Get modified count value. */
virtual unsigned int getModifiedCount() const { return 0; }
@ -467,13 +499,16 @@ class OSGTERRAIN_EXPORT CompositeLayer : public Layer
void clear();
void setSetName(const std::string& setname) { setName(setname); }
const std::string& getSetName() const { return getName(); }
/** Set the set name of layer 'i'. */
void setSetName(unsigned int i, const std::string& setname) { _layers[i].setname = setname; if (_layers[i].layer.valid()) _layers[i].layer->setName(setname); }
/** Get the set name of layer 'i'. */
const std::string& getSetName(unsigned int i) const { return _layers[i].layer.valid() ? _layers[i].layer->getName() : _layers[i].setname; }
/** Set the file name of the data associated with layer 'i'. */
void setFileName(unsigned int i, const std::string& filename) { _layers[i].filename = filename; if (_layers[i].layer.valid()) _layers[i].layer->setFileName(filename); }
/** Get the file name of the data associated with layer 'i'. */
const std::string& getFileName(unsigned int i) const { return _layers[i].layer.valid() ? _layers[i].layer->getFileName() : _layers[i].filename; }
void setCompoundName(unsigned int i, const std::string& compoundname);

View File

@ -52,7 +52,7 @@ class OSGTERRAIN_EXPORT Terrain : public osg::CoordinateSystemNode
/** If set to true the boundaries between adjacent tiles should be equalized.
* Note, it is only possible to equalizae boundaries when the TerrainTile's contain properly assigned TileID's,
* databases built with VirtualPlanetBuilder-0.9.11 and older do not set the TileID, so databases must be
* built with later versions of VirtualPlanetBuilder to take advatange of boundary equalization. */
* built with later versions of VirtualPlanetBuilder to take advantage of boundary equalization. */
void setEqualizeBoundaries(bool equalizeBoundaries);
/** If true the boundaries between adjacent tiles will be equalized. */

View File

@ -45,7 +45,7 @@ void osgTerrain::extractSetNameAndFileName(const std::string& compoundstring, st
filename = compoundstring.substr(secondcolonpos+1, std::string::npos);
}
std::string osgTerrain::createCompondSetNameAndFileName(const std::string& setname, const std::string& filename)
std::string osgTerrain::createCompoundSetNameAndFileName(const std::string& setname, const std::string& filename)
{
if (setname.empty()) return filename;
return std::string("set:")+setname+std::string(":")+filename;
@ -620,7 +620,7 @@ void CompositeLayer::setCompoundName(unsigned int i, const std::string& compound
std::string CompositeLayer::getCompoundName(unsigned int i) const
{
return createCompondSetNameAndFileName(_layers[i].setname, _layers[i].filename);
return createCompoundSetNameAndFileName(_layers[i].setname, _layers[i].filename);
}
void CompositeLayer::addLayer(const std::string& compoundname)

View File

@ -68,7 +68,7 @@ bool HeightFieldLayer_writeLocalData(const osg::Object& obj, osgDB::Output& fw)
if (!layer.getFileName().empty())
{
std::string str = osgTerrain::createCompondSetNameAndFileName(layer.getName(), layer.getFileName());
std::string str = osgTerrain::createCompoundSetNameAndFileName(layer.getName(), layer.getFileName());
fw.indent()<<"file "<< str << std::endl;
}
else