Some advice please.


20-07-2009 17:35:14

Hi, Im relatively new to Ogre, and completely new to python, so please overlook my ignorance on some of these matters.

I've been working on an a framework using Ogre and c++, essentially it allows me to create numerous other application in the same languages and then render them offscreen onto a texture, thats then diplayed in the framework itself. So for example, i may have a game on one material, and web page on another etc.

It was recently suggested that the ability to code these applications using python would be a benefit, and then having these applications interpretted from within the framework and so I've started running through python tutorials et al.

What Im wanting to know is if this is possible, since if it isn't, its a distinct waste of time that I could be spending elsewhere. My framework provides the scenemanager for rendering the applications, as well as a scenenode to work with etc. Is it possibly to interpret a python script that takes these variables as paramters and render an "application" from that script? (so as the most basic example, having a python-ogre app simply create a square on screen, then interpret this script in my framework and have it render that square in the frameworks scenegraph)

Apologies if this sounds like deranged ramblings, if you need more details as to what it is Im after, I'll happily try and word it better.


20-07-2009 18:56:55

Well the only tricky part for me it seems would be rendering of the python app into an offscreen window and capturing it's content to a .bmp or other format. If that's possible then certainly the rest is as well.

I'm no expert in Python either but if Python can't do this stuff it certainly is possible to wrap the python code in C to be able to do it.

Anyone confirm?


21-07-2009 01:45:26

Hmmm, thats not quite as pretty as I was hoping it would be. Again my knowledge of python is limited, but I was under the impression that by included an interpreter in a c++ program (boost for example), you could actually run a python script within the application itself. I know from the python doc, that you can make functions visible from the c++ to the python.

I was hoping then, that it was possible to also make object visible from the c++ to the python, and manipulate those objects within the python script. Ideally, the python would only need to setup the scene and define functions for the mouse/key callbacks. Of course, Im still looking into it all myself, was just hoping for a brief pointer as to whether or not its doable. I guess the method you outline means it is one way or another, so thats good.

Perhaps I should clarify slightly. The "offscreen rendering" I mentioned currently isnt to an external window, it renders in the frameworks own renderwindow, just in a seperate scenemanager with visibility masks defining whats shown. This render is then saved to a render to texture, and defined as a material, which is then applied to an object visibly rendered to the user by the main scenemanager. These extra applications are currently written in c++ and Ogre, but the obvious downsides are that a) the code has to be re-compiled to add new applications, and b) doing this requires the user to include my libraries and header, and i was hoping for a little more abstraction from this.

You idea would work presumably, render to textures can be saved to an image format with a single ogre function (unless im mistaken), which could then be accessed from the main application, but it just seems a little messy. I was kinda hoping python turns out to be the gem I hope it is. Kinda like how lua is used to render UI elements in games, wow being the example that springs to mind.



21-07-2009 02:23:57

If you were to write the whole thing in python, you need to find a GUI library (wx, Pt, GTK etc) that can give you its window's pixel buffer and put it in a pixel format ogre understands and wrap it in a texture.

If, however, you already have a custom SceneManager written in C++ which renders applications into textures, all you need is to create a python wrapper for your interface functions. If that's the case, just follow the python C++ extension tutorials or use Boost or py++.

I'd love to help further, but I'd need to know more about what you're trying to do. :|