// Copyright (C) 2002-2003 Gideon May (gideon@computer.org) // // Permission to copy, use, sell and distribute this software is granted // provided this copyright notice appears in all copies. // Permission to modify the code and to distribute modified code is granted // provided this copyright notice appears in all copies, and a notice // that the code was modified is included with the copyright notice. // // This software is provided "as is" without express or implied warranty, // and with no claim as to its suitability for any purpose. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "NodeVisitor.hpp" using namespace boost::python; namespace { osgUtil::CullVisitor * asCullVisitor(osg::NodeVisitor * nv) { return dynamic_cast(nv); } } // namespace namespace PyOSGUtil { void init_CullVisitor() { def("asCullVisitor", &asCullVisitor, return_value_policy()); // This is not possible since register_castNodeVisitor is defined in osg.pyd, and for this to // work we would need to link in this library. Don't want to do that yet. // PyOSG::register_castNodeVisitor("asCullVisitor", asCullVisitor); class_, boost::noncopyable > cullvisitor("CullVisitor", no_init); scope cullvisitor_scope(cullvisitor); cullvisitor .def("reset", &osgUtil::CullVisitor:: reset) .def("getDistanceToEyePoint", &osgUtil::CullVisitor:: getDistanceToEyePoint) .def("getDistanceFromEyePoint", &osgUtil::CullVisitor:: getDistanceFromEyePoint) .def("setClearNode", &osgUtil::CullVisitor:: setClearNode) .def("getClearNode", &osgUtil::CullVisitor:: getClearNode, return_internal_reference<>()) #if 0 /** Switch the creation of Impostors on or off. * Setting active to false forces the CullVisitor to use the Impostor * LOD children for rendering. Setting active to true forces the * CullVisitor to create the appropriate pre-rendering stages which * render to the ImpostorSprite's texture.*/ .def("setImpostorsActive", &osgUtil::CullVisitor:: setImpostorsActive) /** Get whether impostors are active or not. */ .def("getImpostorsActive", &osgUtil::CullVisitor:: getImpostorsActive) /** Set the impostor error threshold. * Used in calculation of whether impostors remain valid.*/ .def("setImpostorPixelErrorThreshold", &osgUtil::CullVisitor:: setImpostorPixelErrorThreshold) /** Get the impostor error threshold.*/ .def("getImpostorPixelErrorThreshold", &osgUtil::CullVisitor:: getImpostorPixelErrorThreshold) /** Set whether ImpsotorSprite's should be placed in a depth sorted bin for rendering.*/ .def("setDepthSortImpostorSprites", (void (osgUtil::CullVisitor::*)(bool)) &osgUtil::CullVisitor:: setDepthSortImpostorSprites) /** Get whether ImpsotorSprite's are depth sorted bin for rendering.*/ .def("getDepthSortImpostorSprites", (bool (osgUtil::CullVisitor::*)(void) const) &osgUtil::CullVisitor:: setDepthSortImpostorSprites) #endif /** Set the number of frames that an ImpsotorSprite's is kept whilst not being beyond, * before being recycled.*/ .def("setNumberOfFrameToKeepImpostorSprites", &osgUtil::CullVisitor:: setNumberOfFrameToKeepImpostorSprites) /** Get the number of frames that an ImpsotorSprite's is kept whilst not being beyond, * before being recycled.*/ .def("getNumberOfFrameToKeepImpostorSprites", &osgUtil::CullVisitor:: getNumberOfFrameToKeepImpostorSprites) // .def("setComputeNearFarMode", &osgUtil::CullVisitor:: setComputeNearFarMode) // .def("getComputeNearFarMode", &osgUtil::CullVisitor:: getComputeNearFarMode) /** Push state set on the current state group. * If the state exists in a child state group of the current * state group then move the current state group to that child. * Otherwise, create a new state group for the state set, add * it to the current state group then move the current state * group pointer to the new state group. */ .def("pushStateSet", &osgUtil::CullVisitor:: pushStateSet) /** Pop the top state set and hence associated state group. * Move the current state group to the parent of the popped * state group. */ .def("popStateSet", &osgUtil::CullVisitor:: popStateSet) .def("setRenderStage", &osgUtil::CullVisitor:: setRenderStage) .def("getRenderStage", &osgUtil::CullVisitor:: getRenderStage, return_internal_reference<>()) .def("getCurrentRenderBin", &osgUtil::CullVisitor:: getCurrentRenderBin, return_internal_reference<>()) .def("setCurrentRenderBin", &osgUtil::CullVisitor:: setCurrentRenderBin) .def("getCalculatedNearPlane", &osgUtil::CullVisitor:: getCalculatedNearPlane) .def("getCalculatedFarPlane", &osgUtil::CullVisitor:: getCalculatedFarPlane) // .def("updateCalculatedNearFar", (void (osgUtil::CullVisitor::*)(const osg::Matrix&, const osg::Drawable&)) &osgUtil::CullVisitor:: updateCalculatedNearFar) // FIXME .def("updateCalculatedNearFar", (bool (osgUtil::CullVisitor::*)(const osg::Matrix&, const osg::BoundingBox&))&osgUtil::CullVisitor:: updateCalculatedNearFar) .def("updateCalculatedNearFar", (void (osgUtil::CullVisitor::*)(const osg::Vec3&))&osgUtil::CullVisitor:: updateCalculatedNearFar) /** Add a drawable to current render graph.*/ .def("addDrawable", &osgUtil::CullVisitor:: addDrawable) /** Add a drawable and depth to current render graph.*/ .def("addDrawableAndDepth", &osgUtil::CullVisitor:: addDrawableAndDepth) /** Add an attribute which is positioned related to the modelview matrix.*/ .def("addPositionedAttribute", &osgUtil::CullVisitor:: addPositionedAttribute) /** reimplement CullStack's popProjectionMatrix() adding clamping of the projection matrix to the computed near and far.*/ .def("popProjectionMatrix", &osgUtil::CullVisitor:: popProjectionMatrix) .def("setState", &osgUtil::CullVisitor:: setState) .def("getState", (osg::State *(osgUtil::CullVisitor::*)())&osgUtil::CullVisitor:: getState, return_internal_reference<>()) ; // Was causing a conflict with osg.CullSettings // # define OSG_ENUM_MODE(VALUE) \ // (mode.value(#VALUE, osgUtil::CullVisitor::VALUE), \ // cullvisitor.def(#VALUE, object(osgUtil::CullVisitor::VALUE))) // enum_ mode("ComputeNearFarMode"); // OSG_ENUM_MODE( DO_NOT_COMPUTE_NEAR_FAR); // OSG_ENUM_MODE( COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES); // OSG_ENUM_MODE( COMPUTE_NEAR_FAR_USING_PRIMITIVES); } }