// 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 "Math.hpp" using namespace boost::python; namespace { void osgPlane_setitem(osg::Plane * self, int idx, float val) { (*self)[idx] = val; } } // namespace namespace PyOSG { void init_Plane() { class_("Plane", "A plane class. It can be used to represent an infinite plane.") .def(init<>()) .def(init()) .def(init()) .def(init()) .def(init()) .def("set", (void (osg::Plane::*)(float, float, float, float))&osg::Plane::set) .def("set", (void (osg::Plane::*)(const osg::Plane&)) &osg::Plane::set) .def("set", (void (osg::Plane::*)(const osg::Vec4&))&osg::Plane::set) .def("set", (void (osg::Plane::*)(const osg::Vec3&, float))&osg::Plane::set) .def("set", (void (osg::Plane::*)(const osg::Vec3&, const osg::Vec3&, const osg::Vec3& ))&osg::Plane::set) .def("set", (void (osg::Plane::*)(const osg::Vec3&, const osg::Vec3&))&osg::Plane::set) .def("flip", &osg::Plane::flip, "flip/reverse the orientation of the plane.") .def("makeUnitLength", &osg::Plane::makeUnitLength) .def("calculateUpperLowerBBCorners", &osg::Plane::calculateUpperLowerBBCorners, "calculate the upper and lower bounding box corners to be used\n" "in the intersect(BoundingBox&) method for speeding calculations.\n") .def("valid", &osg::Plane::valid) .def("asVec4", (osg::Vec4& (osg::Plane::*)()) &osg::Plane::asVec4, return_internal_reference<>()) .def("getNormal", &osg::Plane::getNormal) .def("distance", &osg::Plane::distance, "calculate the distance between a point and the plane.") .def("transform", &osg::Plane::transform, "Transform the plane by matrix. Note, this operations carries out\n" "the calculation of the inverse of the matrix since to transforms\n" "planes must be multiplied my the inverse transposed. This\n" "make this operation expensive. If the inverse has been already\n" "calculated elsewhere then use transformProvidingInverse() instead.\n" "See http://www.worldserver.com/turk/computergraphics/NormalTransformations.pdf") .def("transformProvidingInverse", &osg::Plane::transformProvidingInverse, "Transform the plane by provide a pre inverted matrix.\n" "see transform for details.") .def("intersect", (int (osg::Plane::*)(const osg::BoundingSphere&) const) &osg::Plane::intersect, // OSG_091 .def("intersect", (const int (osg::Plane::*)(const osg::BoundingSphere&) const) &osg::Plane::intersect, "intersection test between plane and bounding sphere.\n" "return 1 if the bs is completely above plane,\n" "return 0 if the bs intersects the plane,\n" "return -1 if the bs is completely below the plane.\n") .def("intersect", (int (osg::Plane::*)(const osg::BoundingBox&) const) &osg::Plane::intersect, "intersection test between plane and bounding box.\n" "return 1 if the bs is completely above plane,\n" "return 0 if the bs intersects the plane,\n" "return -1 if the bs is completely below the plane.\n") .def("__getitem__", (float &(osg::Plane::*)(unsigned int)) &osg::Plane::operator[], return_value_policy()) .def("__setitem__", osgPlane_setitem) ; } } // namespace // TODO #if 0 inline Plane& operator = (const Plane& pl) inline bool operator == inline bool operator != inline bool operator < inline const Vec4& asVec4() const { return _fv; } /** intersection test between plane and vertex list return 1 if the bs is completely above plane, return 0 if the bs intersects the plane, return -1 if the bs is completely below the plane.*/ inline const int intersect(const std::vector& vertices) const #endif