David
15-06-2007 01:07:50
I am very, very new to Python and Python-Ogre. What I would like to do is to embed the Python interpreter in a C++ program. I import the Python-Ogre wrapper. What I want to do is pass a reference to the Ogre::Root object that is created in C++ to Python-Ogre and allow the Python-Ogre wrapper access to the same Ogre::Root object that C++ is using. Here is a code snippet of what I thought would work:
Ogre::Root& GetOgreRoot(void)
{
return Ogre::Root::getSingleton();
}
//This part is inside a Boost::Python module
class_<Ogre::Root>("Root")
;
def("GetOgreRoot", GetOgreRoot, return_value_policy<reference_existing_object>());
In Python, I can do the following:
theRoot = mymodule.GetOgreRoot()
which works fine. But when I try to do something like:
scenemgr = theRoot.getSceneManager("...")
I get an error that says object Root does not have an attribute getSceneManager.
Is there any way I can pass a reference back to Python and allow Python-Ogre to 'connect' to the same root I'm using in C++.
Thanks in advance for any help!
David
Ogre::Root& GetOgreRoot(void)
{
return Ogre::Root::getSingleton();
}
//This part is inside a Boost::Python module
class_<Ogre::Root>("Root")
;
def("GetOgreRoot", GetOgreRoot, return_value_policy<reference_existing_object>());
In Python, I can do the following:
theRoot = mymodule.GetOgreRoot()
which works fine. But when I try to do something like:
scenemgr = theRoot.getSceneManager("...")
I get an error that says object Root does not have an attribute getSceneManager.
Is there any way I can pass a reference back to Python and allow Python-Ogre to 'connect' to the same root I'm using in C++.
Thanks in advance for any help!
David