Ogre Python libraries

Arjan

04-05-2011 03:19:51

Hello,

I'm building a game engine based on Ogre and I'd like to use the Python-Ogre bindings. It is a very nice library, but the problem is that I would also like to have access to the Ogre root in my own python modules written in C++. In order to do this, I need the Ogre libraries that were linked with the Python-Ogre bindings so I can link them in my C++ DLLs. However, I cannot find these anywhere. Does anyone know where they are? I am using the latest version of the bindings (1.7.2-r1131).

Thanks!
Arjan

Mohican

07-05-2011 03:38:47

I would not recommend what you are trying to do.
Linking ogre libraries is not gonna give you access to the ogre objects instances you created in python-ogre.
You would have to pass pointers of your object instances, and that quickly becomes messy...

Inside your C++ functions, why not call plain python modules that use __builtin__ to access the Ogre root reference?

There is some interesting info on the subject here: http://www.codeproject.com/KB/cpp/embedpython_1.aspx

Arjan

10-05-2011 09:17:58

Hi,

Thanks for your detailed reply. Although I agree with you in principle, there are a couple of other considerations:

- Actually, you do get access to the ogre instances in the different python modules, there is no need to pass pointers around. This is because Ogre is loaded from a DLL, just like the different Python modules. Since the Ogre DLL is loaded only once, the different Python modules share the same singleton instance of for example Root. I tested this and it works just fine.

- Sometimes it might actually be useful to access Ogre directly in C++. For example, you could imagine that the renderOnFrame call could be in a loop written in C++ instead of passing to Python all the time. Also, some lowlevel modules need access to vertices and modify them directly (e.g. a clothing simulation package) which would be more efficient in C++. However, my ultimate goal is to not have to do that and simply access Ogre only from Python and do any interaction with modules written in C++ through interfaces and events.

- The most important point for me is that we are a team of developers working on a real-time simulation engine. This engine already contains a lot of libraries that are heavily dependent on Ogre, since they were ported from a C++ based Ogre application. If I introduce PythonOgre, it means that suddenly all of these libraries are broken, and it will take a long time to rewrite everything. I would prefer to be able to still use Ogre from C++, so that we can rewrite these libraries one-by-one while already having the benefits of PythonOgre, so that we can work in parallel. But in order to do this, I need the Ogre libraries that were linked with the Python-Ogre bindings.

dermont

10-05-2011 10:00:53

Hi,
- Actually, you do get access to the ogre instances in the different python modules, there is no need to pass pointers around. This is because Ogre is loaded from a DLL, just like the different Python modules. Since the Ogre DLL is loaded only once, the different Python modules share the same singleton instance of for example Root. I tested this and it works just fine.

Actually in most cases there shouldn't be any problems passing pointers around (including singletons) in addition to sharing singleton instances in python.

One caveat would be creating Singletons such as root in C++ otherwise you may run into problems.

Hi,

- The most important point for me is that we are a team of developers working on a real-time simulation engine. This engine already contains a lot of libraries that are heavily dependent on Ogre, since they were ported from a C++ based Ogre application. If I introduce PythonOgre, it means that suddenly all of these libraries are broken, and it will take a long time to rewrite everything. I would prefer to be able to still use Ogre from C++, so that we can rewrite these libraries one-by-one while already having the benefits of PythonOgre, so that we can work in parallel. But in order to do this, I need the Ogre libraries that were linked with the Python-Ogre bindings.


If you are planning to make such extensive use of python-ogre, in your case, you would probably be better off building python-ogre on Windows yourself.

There was discussions in the past regarding supplying the underlying libs, maybe you could post on the developers mailing list or PM Andy.

http://groups.google.com/group/python-ogre-developers