// Copyright (C) 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 "held_ptr.hpp" using namespace boost::python; namespace { osg::Node * asNode(osgSim::SphereSegment * ss) { return dynamic_cast(ss); } osg::Geode * asGeode(osgSim::SphereSegment * ss) { return dynamic_cast(ss); } tuple getArea(osgSim::SphereSegment * self) { list area; osg::Vec3 vec; float azRange, elevRange; self->getArea(vec, azRange, elevRange); area.append(vec); area.append(azRange); area.append(elevRange); return make_tuple(area); } } namespace PyOSGSim { void init_SphereSegment() { def("asNode", &asNode, return_value_policy()); def("asGeode", &asGeode, return_value_policy()); class_, bases > spheresegment("SphereSegment", "A SphereSegment is a Geode to represent an portion of a sphere (potentially\n" "the whole sphere). The sphere is aligned such that the line through the\n" "sphere's poles is parallel to the z axis. The sphere segment\n" "may be rendered various components switched on or off:\n" "\n" " - The specified area of the sphere surface.\n" "\n" " - An edge line around the boundary of the specified area\n" " of the sphere surface.\n" "\n" " - Four spokes, where a spoke is the line from\n" " the sphere's centre to a corner of the rendered area.\n" "\n" " - Four planar areas, where the planar areas are formed\n" " between the spokes.\n" "\n" "Caveats:\n" "\n" " - It's worth noting that the line through the sphere's poles is\n" " parallel to the z axis. This has implications when specifying the\n" " area to be rendered, and specifying areas where the centre of\n" " the rendered area is the Z axis may lead to unexpected\n" " geometry.\n" "\n" " - It's possible to render the whole sphere by specifying elevation\n" " and azimuth ranges round the full 360 degrees. When doing\n" " so you may consider switching the planes, spokes, and edge lines\n" " off, to avoid rendering artefacts, e.g. the upper and lower\n" " planes will be coincident.\n" "\n", no_init); spheresegment .def(init<>()) .def(init()) #if 0 "Construct by angle ranges. Note that the azimuth 'zero' is the Y axis; specifying\n" "an azimuth range from azMin -osg::PI/2.0f to azMax osg::PI/2.0f will cover the\n" "'top half' of the circle in the XY plane. The elev angles are 'out' of the 'zero'\n" "XY plane with +ve angles above the plane, and -ve angles below.\n" "@param centre sphere centre\n" "@param radius radius of sphere\n" "@param azMin azimuth minimum\n" "@param azMin azimuth maximum\n" "@param elevMin elevation minimum\n" "@param elevMax elevation maximum\n" "@param density number of units to divide the azimuth and elevation ranges into\n" ) #endif .def(init()) #if 0 "Construct by vector.\n" "@param centre sphere centre\n" "@param radius radius of sphere\n" "@param vec vector pointing from sphere centre to centre point\n" " of rendered area on sphere surface\n" "@param azRange azimuth range in radians (with centre along vec)\n" "@param elevRange elevation range in radians (with centre along vec)\n" "@param density number of units to divide the azimuth and elevation ranges into\n" ) #endif .def("setCentre", &osgSim::SphereSegment::setCentre, "Set the centre point of the SphereSegment\n" ) .def("getCentre", &osgSim::SphereSegment::getCentre, return_value_policy(), "Get the centre point of the SphereSegment\n") .def("setRadius", &osgSim::SphereSegment::setRadius, "Set the radius of the SphereSegment\n") .def("getRadius", &osgSim::SphereSegment::getRadius, "Get the radius of the SphereSegment\n") .def("setArea", (void (osgSim::SphereSegment::*)(const osg::Vec3&, float, float)) &osgSim::SphereSegment::setArea, "Set the area of the sphere segment\n" "\n" "@param vec vector pointing from sphere centre to centre point\n" " of rendered area on sphere surface\n" "@param azRange azimuth range in radians (with centre along vec)\n" "@param elevRange elevation range in radians (with centre along vec)\n" ) .def("getArea", &getArea, "Get the area of the sphere segment\n" "@param vec vector pointing from sphere centre to centre point\n" " of rendered area on sphere surface (normalized)\n" "@param azRange azimuth range in radians (with centre along vec)\n" "@param elevRange elevation range in radians (with centre along vec)\n" ) .def("setArea", (void (osgSim::SphereSegment::*)(float, float, float, float)) &osgSim::SphereSegment::setArea, "Set the area of the sphere segment\n" "@param azMin azimuth minimum\n" "@param azMin azimuth maximum\n" "@param elevMin elevation minimum\n" "@param elevMax elevation maximum\n" ) /** Get the area of the sphere segment @param azMin azimuth minimum @param azMin azimuth maximum @param elevMin elevation minimum @param elevMax elevation maximum */ // void getArea(float &azMin, float &azMax, float &elevMin, float &elevMax) const; .def("setDensity", &osgSim::SphereSegment::setDensity, "Set the density of the sphere segment\n" ) .def("getDensity", &osgSim::SphereSegment::getDensity, "Get the density of the sphere segment\n" ) .def("setDrawMask", &osgSim::SphereSegment::setDrawMask, "Specify the DrawMask.\n" "@param dm Bitmask specifying which parts of the sphere segment should be drawn.\n" "@see DrawMask\n" ) .def("getDrawMask", &osgSim::SphereSegment::getDrawMask, "Get the DrawMask\n" ) .def("setSurfaceColor", &osgSim::SphereSegment::setSurfaceColor, "Set the color of the surface.\n" ) .def("getSurfaceColor", &osgSim::SphereSegment::getSurfaceColor, "Get the color of the surface.\n" ) .def("setSpokeColor", &osgSim::SphereSegment::setSpokeColor, "Set the color of the spokes.\n" ) .def("getSpokeColor", &osgSim::SphereSegment::getSpokeColor, "Get the color of the spokes.\n" ) .def("setEdgeLineColor", &osgSim::SphereSegment::setEdgeLineColor, "Set the color of the edge line.\n" ) .def("getEdgeLineColor", &osgSim::SphereSegment::getEdgeLineColor, "Get the color of the edge line.\n" ) .def("setSideColor", &osgSim::SphereSegment::setSideColor, "Set the color of the planes.\n" ) .def("getSideColor", &osgSim::SphereSegment::getSideColor, "Get the color of the planes.\n" ) .def("setAllColors", &osgSim::SphereSegment::setAllColors, "Set color of all components.\n" ) ; } }