Having a python interpreter


08-11-2010 09:39:17

Hi all,

Maybe you can help me!

I'm using the Ogre C++ SDK and I still want to embed a python interpreter in a different thread, this is mainly good for prototyping.

These are my requirements:

1. I want to be able to manipulate entities while the game is running.
import ogre
ball = ogre.getObjectByName("Ball")

2. Want to be able to register a callback per frame

3. Want to be able to register a callback for OIS events

And that's about it, I don't want to code my whole game in Python but I still want python capabilities for prototyping.
I thought about reusing the code of Python-Ogre, is it available for download?

Also, do you have any more guidelines for this? I know how to embed python in external applications.

Thanks for your help,
- Stn


09-11-2010 01:41:45

I've been down that road before, though not with Ogre, but with Crystal Space before I started using Ogre. You can try going that way (I can't say if you can do that with Ogre because I've never tried), but I'd suggest considering doing one of the following instead:
  1. Make a Python wrapper module for your C++ game objects or anything else that you want to manipulate from Python.[/*:m]
  2. Make the Python wrapper module for your game objects and use Python-Ogre (or Ogre) only from within your Python code.[/*:m]
  3. Write the game in Python. If you are afraid of it being slow, keep in mind that you can always convert slow parts to C++ and use them as modules in Python. As an example, MV3D's client is all Python (except libraries like Python-Ogre) and the performance bottleneck is Ogre rendering, not the Python.[/*:m][/list:u]
    One thing to note is that I'd avoid putting the Python interpreter in its own thread unless you are going with the first option above. Allowing Python (or C++) access to modify Ogre things from another thread sounds like a recipe for disaster to me.

    Oh, btw, yes, Python-Ogre code is available from the SF site: http://sourceforge.net/projects/python-ogre/

    Hope that helps.