// 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 "Drawable.hpp" #include "Math.hpp" using namespace boost::python; namespace { struct TFApply { void operator()(const osg::Vec3& v1, const osg::Vec3& v2, const osg::Vec3& v3, bool) const { try { call_method(_functor, "apply", v1, v2, v3); } catch(...) { handle_exception(); PyErr_Print(); throw_error_already_set(); } } void setFunctor(PyObject * object) { _functor = object; } PyObject * _functor; }; typedef osg::TriangleFunctor TFunctor; class VertexFunctor : public osg::PrimitiveFunctor { public: VertexFunctor() {} virtual ~VertexFunctor() {} virtual void setVertexArray(unsigned int count,const osg::Vec2* vertices) {} virtual void setVertexArray(unsigned int count,const osg::Vec3* vertices) {} virtual void setVertexArray(unsigned int count,const osg::Vec4* vertices) {} virtual void drawArrays(GLenum mode,GLint first,GLsizei count) {} virtual void drawElements(GLenum mode,GLsizei count,const GLubyte* indices) {} virtual void drawElements(GLenum mode,GLsizei count,const GLushort* indices) {} virtual void drawElements(GLenum mode,GLsizei count,const GLuint* indices) {} virtual void begin(GLenum mode) {} virtual void vertex(const osg::Vec2& vert) {} virtual void vertex(const osg::Vec3& vert) {} virtual void vertex(const osg::Vec4& vert) {} virtual void vertex(float x,float y) {} virtual void vertex(float x,float y,float z) {} virtual void vertex(float x,float y,float z, float w) {} virtual void end() {} }; } // namespace namespace PyOSG { void init_TriangleFunctor() { class_("TriangleFunctor", no_init) .def(init<>()) ; class_("VertexFunctor", no_init) .def(init<>()) ; } } // namespace PyOSG