Could "twisted" use with ogre?

sammyogre

11-12-2007 02:46:38

Hi all,

There is a python of network module "twisted". Could it use in OGRE?

Thanks in advance

bharling

11-12-2007 09:44:04

Of course!

thats the beautiful thing about python-ogre, ANY python module can be used with it, just *import* it into your game. Much simpler than trying to combine it all in c++

Tubez

11-12-2007 12:04:35

Mind you , the twisted book does not have an octopus on the cover for nothing, Twisted is a multi-tentacled beast that will swallow up your application. In that view, you probably want to run your own rendering loop with RederOneFrame() instead of using StartRendering(), so you can hand control of the main loop to Twisted.

Btw, if you are on #python in freenode for Twisted help, make sure you use the word "threading" a lot. They really like that :twisted:

SirGolan

11-12-2007 16:22:18

You can definitely use Twisted with Python-Ogre. I've been doing so for quite some time now. If you are familiar with Twisted, I can tell you the best way I've found to run Ogre with it-- start a Cooperator (via twisted.internet.task.coiterate) that calls root.renderOneFrame() and any input related things. Actually, here's some example code:


class RendererIterator:
"""
Just a simple class to iterate the renderer
"""
def __init__(self, root, window, mouse, keyboard):
self.root = root
self.window = window
self.mouse = mouse
self.keyboard = keyboard


def __iter__(self):
return self


def next(self):
self.window.messagePump()
self.root.renderOneFrame()
self.keyboard.capture()
self.mouse.capture()

from twisted.internet.task import coiterate

# Initialize Ogre here before coiterating
coiterate(RendererIterator(root, window, mouse, keyboard))


BTW, it's a tangle of Pythons on the cover. :wink:

Tubez

14-12-2007 11:08:16

Damn, you are right. My point still stands though :P