Updates for improvements to osgdem, such as adding support for skirt
and border into osg::HeightField, handling of computation of neigherbouring tiles in osgdem's DestinationGraph.
This commit is contained in:
@@ -423,7 +423,9 @@ class SG_EXPORT HeightField : public Shape
|
||||
_rows(0),
|
||||
_origin(0.0f,0.0f,0.0f),
|
||||
_dx(1.0f),
|
||||
_dy(1.0f) {}
|
||||
_dy(1.0f),
|
||||
_skirtHeight(0.0f),
|
||||
_borderWidth(0) {}
|
||||
|
||||
HeightField(const HeightField& mesh,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
|
||||
Shape(mesh,copyop),
|
||||
@@ -432,6 +434,8 @@ class SG_EXPORT HeightField : public Shape
|
||||
_origin(mesh._origin),
|
||||
_dx(mesh._dx),
|
||||
_dy(mesh._dy),
|
||||
_skirtHeight(mesh._skirtHeight),
|
||||
_borderWidth(mesh._borderWidth),
|
||||
_heights(mesh._heights) {}
|
||||
|
||||
META_Shape(osg, HeightField)
|
||||
@@ -455,6 +459,28 @@ class SG_EXPORT HeightField : public Shape
|
||||
inline void setYInterval(float dy) { _dy = dy; }
|
||||
inline float getYInterval() const { return _dy; }
|
||||
|
||||
|
||||
/** Set the height of the skirt to render around the edge of HeightField.
|
||||
* The skirt is used as a means of disguising edge boundaries between adjacent HeightField, particular
|
||||
* of ones with different resolutions.*/
|
||||
void setSkirtHeight(float skirtHeight) { _skirtHeight = skirtHeight; }
|
||||
|
||||
/** Get the height of the skirt to render around the edge of HeightField.*/
|
||||
float getSkirtHeight() const { return _skirtHeight; }
|
||||
|
||||
/** Set the width in number of cells in from the edge that the height field should be rendered from.
|
||||
* This exists to allow gradient and curvature continutity to be maintained between adjacent HeightField, where
|
||||
* the border cells will overlap adjacent HeightField.*/
|
||||
void setBorderWidth(unsigned int borderWidth) { _borderWidth = borderWidth; }
|
||||
|
||||
/** Get the width in number of cells in from the edge that the height field should be rendered from.*/
|
||||
unsigned int getBorderWidth() const { return _borderWidth; }
|
||||
|
||||
inline void setRotation(const Quat& quat) { _rotation = quat; }
|
||||
inline const Quat& getRotation() const { return _rotation; }
|
||||
inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
|
||||
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
|
||||
|
||||
|
||||
inline void setHeight(unsigned int c,unsigned int r,float value)
|
||||
{
|
||||
@@ -474,25 +500,31 @@ class SG_EXPORT HeightField : public Shape
|
||||
HeightList& getHeightList() { return _heights; }
|
||||
const HeightList& getHeightList() const { return _heights; }
|
||||
|
||||
inline Vec3 getVertex(unsigned int c,unsigned int r) const
|
||||
{
|
||||
return Vec3(_origin.x()+getXInterval()*(float)c,
|
||||
_origin.y()+getYInterval()*(float)r,
|
||||
_origin.z()+_heights[c+r*_columns]);
|
||||
}
|
||||
|
||||
Vec3 getNormal(unsigned int c,unsigned int r) const;
|
||||
|
||||
inline void setRotation(const Quat& quat) { _rotation = quat; }
|
||||
inline const Quat& getRotation() const { return _rotation; }
|
||||
inline Matrix getRotationMatrix() const { return Matrix(_rotation); }
|
||||
inline bool zeroRotation() const { return _rotation.zeroRotation(); }
|
||||
|
||||
protected:
|
||||
|
||||
~HeightField() {}
|
||||
|
||||
unsigned int _columns,_rows;
|
||||
unsigned int _columns,_rows;
|
||||
|
||||
osg::Vec3 _origin;
|
||||
float _dx;
|
||||
float _dy;
|
||||
osg::Vec3 _origin;
|
||||
float _dx;
|
||||
float _dy;
|
||||
|
||||
Quat _rotation;
|
||||
HeightList _heights;
|
||||
float _skirtHeight;
|
||||
unsigned int _borderWidth;
|
||||
|
||||
Quat _rotation;
|
||||
HeightList _heights;
|
||||
|
||||
};
|
||||
|
||||
typedef HeightField Grid;
|
||||
|
||||
@@ -56,6 +56,11 @@ class Vec3
|
||||
_v[0]=x; _v[1]=y; _v[2]=z;
|
||||
}
|
||||
|
||||
inline void set( const Vec3& rhs)
|
||||
{
|
||||
_v[0]=rhs._v[0]; _v[1]=rhs._v[1]; _v[2]=rhs._v[2];
|
||||
}
|
||||
|
||||
inline float& operator [] (int i) { return _v[i]; }
|
||||
inline float operator [] (int i) const { return _v[i]; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user