fixed: compile issue
[opensg.git] / Tools / osgBench / python_wrapper.cpp
blob02c71bf3dc25eec18a07a113f11766973aa9da41
1 #include <boost/python.hpp>
3 #include <OpenSG/OSGConfig.h>
4 #include <OpenSG/OSGBaseFunctions.h>
6 #include <OpenSG/OSGGraphOp.h>
7 #include <OpenSG/OSGGraphOpFactory.h>
8 #include <OpenSG/OSGGraphOpSeq.h>
10 #include "Nodes.h"
11 #include "TestWindow.h"
12 #include "Test.h"
15 void doExit()
17 OSG::osgExit();
21 OSG::GraphOp* createGraphOp(const char* name)
23 return OSG::GraphOpFactory::the().create(name);
26 OSG::GraphOpSeq* createGraphOpSeq(const char* ops)
28 OSG::GraphOpSeq *seq = new OSG::GraphOpSeq;
30 seq->setGraphOps(ops);
32 return seq;
36 void traverse(OSG::GraphOp& g, NodeBase& b)
38 OSG::NodePtr p = b.getNode();
39 g.traverse(p);
42 void traverseSeq(OSG::GraphOpSeq& g, NodeBase& b)
44 OSG::NodePtr p = b.getNode();
45 g.run(p);
49 BOOST_PYTHON_MODULE(osgbench)
51 using namespace boost::python;
53 class_<NodeBase>("NodeBase")
54 .def("dump", &NodeBase::dump)
55 .def("save", &NodeBase::save)
56 .def("iter", &NodeBase::iter)
57 .def("geometries", &NodeBase::geometries)
58 .def("transforms", &NodeBase::transforms)
59 .def("clone", &NodeBase::clone)
62 class_<Group, bases<NodeBase> >("Group")
63 .def("addChild", &Group::addChild)
64 .def("subChild", &Group::subChild)
67 class_<Transform, bases<Group> >("Transform")
68 .def("setTranslation", &Transform::setTranslation)
71 class_<Geometry, bases<NodeBase> >("Geometry")
72 .def("translate", &Geometry::translate)
73 .def("scale", &Geometry::scale)
74 .def("setDlistCache", &Geometry::setDlistCache)
77 class_<NodeIterator>("NodeIterator")
78 .def("next", &NodeIterator::next)
79 .def("__iter__", &NodeIterator::__iter__)
82 class_<TypedNodeIterator<Geometry> >("GeometryNodeIterator")
83 .def("next", &TypedNodeIterator<Geometry>::next)
84 .def("__iter__", &TypedNodeIterator<Geometry>::__iter__)
87 class_<TypedNodeIterator<Transform> >("TransformNodeIterator")
88 .def("next", &TypedNodeIterator<Transform>::next)
89 .def("__iter__", &TypedNodeIterator<Transform>::__iter__)
92 class_<Image>("Image")
93 .def("write", &Image::write)
94 .def("clone", &Image::clone)
95 .def("diff", &Image::diff)
98 def("makeBox", &makeBox);
99 def("makeTorus", &makeTorus);
100 def("makeSphere", &makeSphere);
101 def("makePlane", &makePlane);
102 def("makeShared", &makeShared);
103 def("addRef", &addRef);
104 def("subRef", &subRef);
105 def("loadScene", &loadScene);
108 void (TestWindow::*twSetScene)(NodeBase&) = &TestWindow::setScene;
109 void (TestWindow::*twSetCamera)(OSG::Real32,OSG::Real32,OSG::Real32,
110 OSG::Real32,OSG::Real32,OSG::Real32,
111 OSG::Real32,OSG::Real32,OSG::Real32) =
112 &TestWindow::setCamera;
114 class_<TestWindow>("TestWindow")
115 .def("setSize", &TestWindow::setSize)
116 .def("setFullscreen", &TestWindow::setFullscreen)
117 .def("setViewport", &TestWindow::setViewport)
118 .def("getWidth", &TestWindow::getWidth)
119 .def("getHeight", &TestWindow::getHeight)
120 .def("getScene", &TestWindow::getScene)
121 .def("setScene", twSetScene)
122 .def("setCamera", twSetCamera)
123 .def("open", &TestWindow::open)
124 .def("close", &TestWindow::close)
125 .def("redraw", &TestWindow::redraw)
126 .def("setNearFar", &TestWindow::setNearFar)
127 .def("setFov", &TestWindow::setFov)
128 .def("showAll", &TestWindow::showAll)
132 void (Test::*tSetScene)(NodeBase&) = &Test::setScene;
133 void (Test::*taddFAU)
134 (OSG::Real32 fromx, OSG::Real32 fromy, OSG::Real32 fromz,
135 OSG::Real32 atx, OSG::Real32 aty, OSG::Real32 atz,
136 OSG::Real32 upx, OSG::Real32 upy, OSG::Real32 upz)
137 = &Test::addFromAtUp;
139 class_<Test>("Test")
140 .def("setScene", tSetScene)
141 .def("setWindow", &Test::setWindow)
142 .def("setHeadlight", &Test::setHeadlight)
143 .def("setNearFar", &Test::setNearFar)
144 .def("clear", &Test::clear)
145 .def("setNFrames", &Test::setNFrames)
146 .def("setMinTime", &Test::setMinTime)
147 .def("addFromAtUp", taddFAU)
148 .def("addFromOri", &Test::addFromOri)
149 .def("makeOrbit", &Test::makeOrbit)
150 .def("makePirouette", &Test::makePirouette)
151 .def("addFov", &Test::addFov)
152 .def("setStatistics", &Test::setStatistics)
153 .def("run", &Test::run)
154 .def("snapshot", &Test::snapshot)
155 .def("getFPS", &Test::getFPS)
156 .def("getTime", &Test::getTime)
157 .def("getNRenderedFrames", &Test::getNRenderedFrames)
158 .def("getStatValue", &Test::getStatValue)
159 .def("setVerbose", &Test::setVerbose)
160 .def("setIgnoreGeometry", &Test::setIgnoreGeometry)
161 .def("useRenderTraversal", &Test::useRenderTraversal)
164 class_<OSG::GraphOp, boost::noncopyable>("GraphOp", no_init)
165 .def("traverse", &traverse)
168 class_<OSG::GraphOpSeq, boost::noncopyable>("GraphOpSeq", no_init)
169 .def("traverseSeq", &traverseSeq)
172 def("createGraphOp", &createGraphOp,
173 return_value_policy<manage_new_object>());
175 def("createGraphOpSeq", &createGraphOpSeq,
176 return_value_policy<manage_new_object>());
178 // Module Initialization
180 OSG::osgInit(0, NULL);
182 Py_AtExit(doExit);