Added ViewPoint support into NodeVistor/CullStack/CullVisitor/LOD/PagedLOD etc to facilate

management of LOD settings for RTT cameras.
This commit is contained in:
Robert Osfield
2006-12-15 17:27:18 +00:00
parent d88b996df1
commit 982a4db9e2
13 changed files with 116 additions and 79 deletions

View File

@@ -36,6 +36,8 @@ class OSG_EXPORT CollectOccludersVisitor : public osg::NodeVisitor, public osg::
virtual void reset();
virtual float getDistanceToEyePoint(const Vec3& pos, bool withLODScale) const;
virtual float getDistanceToViewPoint(const Vec3& pos, bool withLODScale) const;
virtual float getDistanceFromEyePoint(const Vec3& pos, bool withLODScale) const;
virtual void apply(osg::Node&);

View File

@@ -134,9 +134,15 @@ class OSG_EXPORT CullStack : public osg::CullSettings
inline osg::RefMatrix& getProjectionMatrix();
inline osg::Matrix getWindowMatrix();
inline const osg::RefMatrix& getMVPW();
inline const osg::Vec3& getReferenceViewPoint() const { return _referenceViewPoints.back(); }
inline void pushReferenceViewPoint(const osg::Vec3& viewPoint) { _referenceViewPoints.push_back(viewPoint); }
inline void popReferenceViewPoint() { _referenceViewPoints.pop_back(); }
inline const osg::Vec3& getEyeLocal() const { return _eyePointStack.back(); }
inline const osg::Vec3& getViewPointLocal() const { return _viewPointStack.back(); }
inline const osg::Vec3 getUpLocal() const
{
const osg::Matrix& matrix = *_modelviewStack.back();
@@ -149,6 +155,8 @@ class OSG_EXPORT CullStack : public osg::CullSettings
return osg::Vec3(-matrix(0,2),-matrix(1,2),-matrix(2,2));
}
protected:
void pushCullingSet();
@@ -168,7 +176,9 @@ class OSG_EXPORT CullStack : public osg::CullSettings
ViewportStack _viewportStack;
typedef fast_back_stack<Vec3> EyePointStack;
EyePointStack _referenceViewPoints;
EyePointStack _eyePointStack;
EyePointStack _viewPointStack;
CullingStack _clipspaceCullingStack;
CullingStack _projectionCullingStack;

View File

@@ -207,6 +207,10 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
* Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.*/
virtual osg::Vec3 getEyePoint() const { return Vec3(0.0f,0.0f,0.0f); }
/** Get the view point in local coordinates.
* Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.*/
virtual osg::Vec3 getViewPoint() const { return getEyePoint(); }
/** Get the distance from a point to the eye point, distance value in local coordinate system.
* Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
* If the getDistanceFromEyePoint(pos) is not implemented then a default value of 0.0 is returned.*/
@@ -217,6 +221,12 @@ class OSG_EXPORT NodeVisitor : public virtual Referenced
* If the getDistanceFromEyePoint(pos) is not implemented than a default value of 0.0 is returned.*/
virtual float getDistanceFromEyePoint(const Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
/** Get the distance from a point to the view point, distance value in local coordinate system.
* Note, not all NodeVisitor implement this method, it is mainly cull visitors which will implement.
* If the getDistanceToViewPoint(pos) is not implemented then a default value of 0.0 is returned.*/
virtual float getDistanceToViewPoint(const Vec3& /*pos*/, bool /*useLODScale*/) const { return 0.0f; }
virtual void apply(Node& node) { traverse(node);}
virtual void apply(Geode& node) { apply((Node&)node); }

View File

@@ -60,9 +60,13 @@ class OSGUTIL_EXPORT CullVisitor : public osg::NodeVisitor, public osg::CullStac
virtual void reset();
virtual osg::Vec3 getEyePoint() const { return getEyeLocal(); }
virtual osg::Vec3 getViewPoint() const { return getViewPointLocal(); }
virtual float getDistanceToEyePoint(const osg::Vec3& pos, bool withLODScale) const;
virtual float getDistanceFromEyePoint(const osg::Vec3& pos, bool withLODScale) const;
virtual float getDistanceToViewPoint(const osg::Vec3& pos, bool withLODScale) const;
virtual void apply(osg::Node&);
virtual void apply(osg::Geode& node);
virtual void apply(osg::Billboard& node);