Hi, I found the interactive cosole from Hypnos. That looks very interessting. I’m very impressed. Is this the only way to develop with panda interactive in python? I personally like it to start a python interpreter in emacs and keep it alive the whole day . Then just “replace” new classes while the programm is running. I’v tried this with panda, but not to my satisfaction gg.
Here is a simple example of what I try to do:
from direct.showbase.ShowBase import ShowBase
from direct.task.Task import Task
from direct.stdpy.threading2 import Thread
from pandac.PandaModules import Thread as PandaThread
class Character(object):
def __init__(self):
self.model = loader.loadModel("panda")
self.model.setScale(.2,.2,.2)
self.model.reparentTo(camera)
self.model.setPos(0,8,-1)
def walk(self):
print "walk"
# def walk_fast(self):
# print "walk fast"
class MainApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
base.setFrameRateMeter(True)
self.hero = Character()
def sayHello(self):
print "Hello"
class tt(Thread):
def __init__(self):
Thread.__init__(self)
self.app = MainApp()
print "Support panda threading: " , PandaThread.isThreadingSupported()
self.setName("tt")
def run(self):
self.app.run()
print "Helper Thread done :-)"
This is what I expected:
1.) open emacs and start a python interpreter (C-c C-z).
2.) evaluate Buffer (C-c C-C)
3.) Start panda (in python interpreter)
t = tt()
Known pipe types:
glxGraphicsPipe
(all display modules loaded.)
Support panda threading: 1
t.start()
4.) implement new method in Character: walk_fast()
5.) evaluate Buffer again (=> load to running python interpreter)
6.) “reload” Class and test new method
t.app.hero.class = Character # Use new class
t.app.hero.walk_fast()
walk fastOr move a object in the console
t.app.hero.model.setPos(-1,-1,-1)
7.) and so on, …
The console output is as expected . Sadly MainApp stucks. The Framemeter is at 0.00. When I join the Thread in the interpreter it MyApp starts. But I can’t type anything… You can give join a timeout. Then MainApp runs properly until the timeout gg.
t.join(5)
Is there a better way to develop interactive? Have I missunderstood ShowBase?