On 6/1/06, Robert Osfield <[EMAIL PROTECTED]> wrote:
HI Serge,

On 6/1/06, Serge Lages <[EMAIL PROTECTED]> wrote:
> Hi all,
> I would like to know how to retrieve in a traverse method the current
> near and far value when these values are setted automatically by osg.
> It must be simple but I can't manage to find it. :/

Are we talking about a cull traversal?  If so cast to
osgUtil::CullVisitor and get the computed near and far values from it.
 However, the computerd near and far values changes the cull traversal
goes though so its not final till whole scene graph is traversed.  The
methods are:


        inline value_type getCalculatedNearPlane() const { return
_computed_znear; }

        inline value_type getCalculatedFarPlane() const { return
_computed_zfar; }

If you just want to change the clamping of the projection matrix then
again the CullVisitor is the place to look, and it has a callback
machansim that you can use to implement you own clamping of the
projection matrix.  The callback related codes are inhertited from
osg::CullSettings:

        /** Callback for overriding the CullVisitor's default clamping
of the projection matrix to computed near and far values.
          * Note, both Matrixf and Matrixd versions of
clampProjectionMatrixImplementation must be implemented as the
CullVisitor
          * can target either Matrix data type, configured at compile time.*/
        struct ClampProjectionMatrixCallback : public osg::Referenced
        {
            virtual bool
clampProjectionMatrixImplementation(osg::Matrixf& projection, double&
znear, double& zfar) const = 0;
            virtual bool
clampProjectionMatrixImplementation(osg::Matrixd& projection, double&
znear, double& zfar) const = 0;
        };

        /** set the ClampProjectionMatrixCallback.*/
        void setClampProjectionMatrixCallback(ClampProjectionMatrixCallback*
cpmc) { _clampProjectionMatrixCallback = cpmc; }
        /** get the non const ClampProjectionMatrixCallback.*/
        ClampProjectionMatrixCallback*
getClampProjectionMatrixCallback() { return
_clampProjectionMatrixCallback.get(); }
        /** get the const ClampProjectionMatrixCallback.*/
        const ClampProjectionMatrixCallback*
getClampProjectionMatrixCallback() const { return
_clampProjectionMatrixCallback.get(); }

Thank you very much Robert, I better understand how it works know.

--
Serge Lages
http://www.magrathea-engine.org
_______________________________________________
osg-users mailing list
[email protected]
http://openscenegraph.net/mailman/listinfo/osg-users
http://www.openscenegraph.org/

Reply via email to