// Copyright (C) 2002-2005 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 "held_ptr.hpp" #include "Math.hpp" using namespace boost::python; namespace PyOSG { class Drawable : public osg::Drawable { public: Drawable() : osg::Drawable() {} ~Drawable() {} Drawable(const Drawable& geometry,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) {} virtual osg::Object* cloneType() const { return NULL; } virtual osg::Object* clone(const osg::CopyOp& copyop) const { return NULL; } virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast(obj)!=NULL; } virtual const char* libraryName() const { return "osg"; } virtual const char* className() const { return "Drawable"; } virtual void drawImplementation(osg::State & state) const {} virtual osg::BoundingBox computeBound() const { return osg::BoundingBox();} }; class PyDrawable : public Drawable { public : PyDrawable(PyObject * p) : Drawable(), _self(p) { Py_XINCREF(_self); } ~PyDrawable() {} virtual void drawImplementation(osg::State & state) const { try { call_method(_self, "drawImplementation", ptr(&state)); return; } catch(...) { handle_exception(); PyErr_Print(); throw_error_already_set(); return; } } virtual osg::BoundingBox computeBound() const { if (PyObject_HasAttrString(_self, "computeBound") ) { try { return call_method(_self, "computeBound"); } catch(...) { handle_exception(); PyErr_Print(); throw_error_already_set(); return osg::BoundingBox(); } } else { return osg::Drawable::computeBound(); } return osg::BoundingBox(); } private : PyObject * _self; }; void init_Drawable2() { class_, bases, boost::noncopyable > ("Drawable_base") #if 0 .def("getParent", (osg::Node *(osg::Drawable::*)(unsigned int))&osg::Drawable::getParent, return_internal_reference<>()) .def("getNumParents", &osg::Drawable::getNumParents) .def("setStateSet", &osg::Drawable::setStateSet) .def("getStateSet", (osg::StateSet * ( osg::Drawable::*)()) &osg::Drawable::getStateSet, return_internal_reference<>()) .def("getOrCreateStateSet", (osg::StateSet * ( osg::Drawable::*)()) &osg::Drawable::getOrCreateStateSet, return_internal_reference<>()) .def("dirtyBound", &osg::Drawable::dirtyBound) .def("getBound", &osg::Drawable::getBound, return_value_policy()) .def("setShape", &osg::Drawable::setShape) .def("getShape", (osg::Shape *(osg::Drawable::*)())&osg::Drawable::getShape, return_internal_reference<>()) .def("setSupportsDisplayList", &osg::Drawable::setSupportsDisplayList) .def("setUseDisplayList", &osg::Drawable::setUseDisplayList) .def("getUseDisplayList", &osg::Drawable::getUseDisplayList) .def("dirtyDisplayList", &osg::Drawable::dirtyDisplayList) .def("draw", &osg::Drawable::draw) .def("compile", &osg::Drawable::compile) .def("setAppCallback", &osg::Drawable::setAppCallback) .def("setCullCallback", &osg::Drawable::setCullCallback) .def("setDrawCallback", &osg::Drawable::setDrawCallback) #endif // .add_property("_bbox", &Drawable::read_bbox) // .add_property("_bbox", &Drawable::read_bbox, &Drawable::write_bbox) // .add_property("_bbox", &Drawable::bbox, &Drawable::bbox) // make_getter(&Drawable::read_bbox(), return_internal_reference<>()) // make_setter(&Drawable::write_bbox, return_internal_reference<>())) // .add_property("_bbox_computed", &Drawable::read_bbox_computed, &Drawable::write_bbox_computed) ; } } // namespace PyOSG