Python-Ogre as game scripting interface to C++ Ogre?


02-10-2007 18:18:46

My friends and I are new to this kind of stuff and frankly, we have no idea if the following is possible or not.

Just curious but do you think it's possible to use P-O as a game scripting interface to C++ based Ogre?

We're thinking like this:
1. Script most of our game in P-O for rapid prototyping and development.
2. Translate P-O scripts to standard Ogre C++ code for speed after the prototyping and testing phases.
3. Continue to use P-O as a scripting language to allow for in game tweaking and configuration without having to alter the source and re-compile. Similar to what Lua, AngleScript, etc are used for.

Any thoughts!


[EDIT] I altered my original post by adding the word "game" to the title and question.


02-10-2007 19:21:23

That is exactly how you could go about it. You might even find that you don't want to waste time porting your entire python framework to C++ and just leave the bottlenecks in C++. This would allow you to code more features, quicker than you could in C++. Thats a pretty big factors for part-time/side projects where quick progress makes them more fun to work on. Remember you have to write (and get working) those several thousands lines of Python before you get to the point where you even start thinking of C++.


02-10-2007 23:39:19

Ok, thx G_E for the reply... looks like we're on the right track... 8)

So, as not to "put the cart before the horse", we'll get our framework up and running then look at the critical performance areas and see what needs to be done...

And we'll examine the P-O / Ogre interface possibilities. I'm sure I'll be back here asking questions... :wink:



09-10-2007 13:13:09

I'm also curious of the ways of interplay of py and c++ written parts in Python-Ogre apps. We've been succesfully using Python for many kinds of things in our small company, starting with pygame but later soya3d, Blender and Ogre too., often involving connecting to different control devices or sensors or network data for interactive installations and such. But now we've started making standalone games too.

Recently we have also done projects with Ogre in C++ and Mogre (had a .net dependency), but I'm prototyping the next steps in plain Python (having a mock-up py engine that fakes enough of the future ogre-run engine for unit tests to work :). We have not decided whether the thing will remain mogre, or be ported to normal Ogre, and if so, whether it'll be made a C++ ogre app possibly with Python scripting, or a Python-Ogre app.

In the case of Python-Ogre, I'd like to know from before that if we encounter some places where the speed of native code is needed, that it can be plugged in easily enough. Like if there is some special case where we need to iterate thru a lot of objects and do some operation on them. I hope that existing intersection / collision / physics code can do with that kind of needs, but am thinking of possible special cases related to our game logic.

I know that in python normally it is pretty easy to write a part in c, just use the py c api to make a module and use it. I suspect it is pretty much the same with Python-Ogre .. but if/as that module needs to deal with Ogre datatypes, it needs to be built against Ogre itself too .. basically like the modules in the Python-Ogre package themselves, right? I guess will need to take a look at that, but if there is some small example somewhere or other hints, do tell :)

I guess also for the sake of maintaining and easy of deployment it would be good for such possible new c++ -written python-ogre code to be general enough to go back into Python-Ogre, but I don't know if it is always possible or if some special hard-coded logic is sometimes needed for performance reasons.

looking forward to seeing how it happens,


09-10-2007 19:26:30

The best way to speed up your game would be to make your own Boost.Python extensions which are built against the same version of Ogre, Python and Boost as Python-Ogre is. You don't have to use Boost.Python to do the binding of you extensions module, but you will definitely have to link against the same libraries as described above.

If you want more answers, ask more questions.


10-10-2007 03:19:34

If there is interest I'll publish the OgreMain.lib (and boost if need be) for each version I make of Python-Ogre so you can use this to link to (I don't change the Ogre headers so these come from the Ogre SDK)..

This way you can make your own python module for anything you think requires a speed up -- and, as previously mentioned, don't worry about this to start with -- do everything in Python, and then determine if there is a performance issue and deal with it.

Bottom line, adding an additional C++ (or C) module to Python-Ogre is easy..



12-10-2007 15:37:09

If there is interest I'll publish the OgreMain.lib (and boost if need be) for each version I make of Python-Ogre so you can use this to link to (I don't change the Ogre headers so these come from the Ogre SDK)..

Thx Andy! When the time comes, that would be an excellent resource to have available... 8)