srekel2
17-10-2005 23:19:34
I've tried to make a progressbar by using the ResourceGroupListener that comes with OGRE, but I've failed to get it to work. I've tried a lot of tricks and I'm guessing that there's either a really simple solution that I've overlooked, or it's not bound in PyOgre yet.
It seems part of the problem is that ResourceGroupListener is an abstract class (IIRC), so when I do
class VWResourceListener(ogre.ResourceGroupListener):
def resourceLoadStarted(*args):
"""resourceLoadStarted(self, ResourcePtr resource)"""
for x in args:
print x
and then
resListener = VWResourceListener()
ogre.ResourceGroupManager.getSingleton().addResourceGroupListener(resListener)
I get.. well, I don't get any error messages (at least not as often) since I built PyOgre from the SVN, it just crashes now. But it used to crash with the message "Expected ResourceGroupListener, got VWResourceListener", or something along those lines.
And I can't add
ogre.ResourceGroupListener.__init__(self)
because as I said, it's abstract.
I tried changing it to ResourceGroupListenerPtr and ogre.ResourceGroupListenerPointer and even doing
def __init__(self):
self.__class__ = ogre.ResourceGroupListenerPointer
But nothing works. Any ideas?
When you create a subclass for a python callback (director) you need to add a call to the constructor of the parent class:
class VWResourceListener(ogre.ResourceGroupListener):
def __init__(self):
ogre.ResourceGroupListener.__init__(self)
def resourceLoadStarted(*args):
"""resourceLoadStarted(self, ResourcePtr resource)"""
for x in args:
print x
I'm not sure if this will fix all of your problems. I have not fully looked over your code, but start here.
*Cough* Actually no, you don't need that. Python always call __init__ on the new object but resolve it using the normal inheritance rules (remember: everything in Python is virtual) so if __init__ does not exists the one from the parent class is called.
I suppose the problem is that we didn't enabled directors for that class. I have the change made but I can't access berlios SVN right now. I'll commit a little bit later.
srekel2
18-10-2005 12:35:35
Thanks, I'll try it when I get home.
*Cough* Actually no, you don't need that. Python always call __init__ on the new object but resolve it using the normal inheritance rules (remember: everything in Python is virtual) so if __init__ does not exists the one from the parent class is called.
I suppose the problem is that we didn't enabled directors for that class. I have the change made but I can't access berlios SVN right now. I'll commit a little bit later.
Whoops. Glad fog is around. =)
I commited the change right now but I didn't have the tine to write some code to check it. @srekel, Please tell us if it worked or I'll try something in Shy in the next few days.
srekel2
18-10-2005 23:47:17
Cool, I'll try to look at it right away. Thanks.
EDIT:
It now crashes while doing
ogre.ResourceGroupManager.getSingleton().loadResourceGroup("General")
Here's everything I do (resource initializing is done before this):
resListener = VWResourceListener()
print type(resListener)
print 123
ogre.ResourceGroupManager.getSingleton().addResourceGroupListener(resListener)
print 234
ogre.ResourceGroupManager.getSingleton().loadResourceGroup("General")
This is the listener:
class VWResourceListener(ogre.ResourceGroupListener):
"""
>>> dir(ogre.ResourceGroupListener)
['__class__', '__del__', '__delattr__', '__dict__', '__doc__', '__getattribute__
', '__hash__', '__init__', '__module__', '__new__', '__reduce__', '__reduce_ex__
', '__repr__', '__setattr__', '__str__', '__weakref__', 'resourceGroupLoadEnded'
, 'resourceGroupLoadStarted', 'resourceGroupScriptingEnded', 'resourceGroupScrip
tingStarted', 'resourceLoadEnded', 'resourceLoadStarted', 'scriptParseEnded', 's
criptParseStarted', 'worldGeometryStageEnded', 'worldGeometryStageStarted']
"""
def resourceGroupScriptingStarted(*args):
print 1
"""resourceGroupScriptingStarted(self, String groupName, size_t scriptCount)"""
return _ogre.ResourceGroupListener_resourceGroupScriptingStarted(*args)
def scriptParseStarted(*args):
print 1
"""scriptParseStarted(self, String scriptName)"""
return _ogre.ResourceGroupListener_scriptParseStarted(*args)
def scriptParseEnded(*args):
print 1
"""scriptParseEnded(self)"""
return _ogre.ResourceGroupListener_scriptParseEnded(*args)
def resourceGroupScriptingEnded(*args):
print 1
"""resourceGroupScriptingEnded(self, String groupName)"""
return _ogre.ResourceGroupListener_resourceGroupScriptingEnded(*args)
def resourceGroupLoadStarted(*args):
print 1
"""resourceGroupLoadStarted(self, String groupName, size_t resourceCount)"""
return _ogre.ResourceGroupListener_resourceGroupLoadStarted(*args)
def resourceLoadStarted(*args):
print 1
"""resourceLoadStarted(self, ResourcePtr resource)"""
print "RESLOADSTART"
for x in args:
print x
return _ogre.ResourceGroupListener_resourceLoadStarted(*args)
def resourceLoadEnded(*args):
print 1
"""resourceLoadEnded(self)"""
return _ogre.ResourceGroupListener_resourceLoadEnded(*args)
def worldGeometryStageStarted(*args):
print 1
"""worldGeometryStageStarted(self, String description)"""
return _ogre.ResourceGroupListener_worldGeometryStageStarted(*args)
def worldGeometryStageEnded(*args):
print 1
"""worldGeometryStageEnded(self)"""
return _ogre.ResourceGroupListener_worldGeometryStageEnded(*args)
def resourceGroupLoadEnded(*args):
print 1
"""resourceGroupLoadEnded(self, String groupName)"""
return _ogre.ResourceGroupListener_resourceGroupLoadEnded(*args)
That may very well not be how it should be written, but I guess at least one "1" should get printed before the crash, but nope.
Oh, and the "print type(resListener)" prints out this:
<class 'MenuListener.VWResourceListener'>
which looks a bit strange to me. Oh, wait. MenuListener is the class I'm writing the code in, duh!
I'll add a resource loading progress bar to Shy later today and then enter debug mode. If I don't report back in 24h feel free to push me with a bbq fork.
Sorry, latecomer here. What's Shy? =)
That's great. Nice work. =)
srekel2
20-10-2005 23:09:20
/me prods fog
..and goes to bed. night!
He's working on it. I think it might have been more troublesome than he first thought. =)
I returned yesterday night from the SMAU, the biggest ITC fair here in Italy. I am working on this.
Srekel
06-11-2005 20:34:51
I returned yesterday night from the SMAU, the biggest ITC fair here in Italy. I am working on this.
Any update on this? I've looked in the changelog but didn't find much since the 18th.
mthorn
19-01-2006 19:36:54
I too was having a problem with the ResourceGroupListener. It seems if you make a local reference:
def _createResourceListener(self):
resourceGroupListener = ResourceGroupListener()
ogre.ResourceGroupManager.getSingleton().addResourceGroupListener(resourceGroupListener)
It fails. I suppose the reference goes away quickly. Instead, make it a property:
def _createResourceListener(self):
self.resourceGroupListener = ResourceGroupListener()
ogre.ResourceGroupManager.getSingleton().addResourceGroupListener(self.resourceGroupListener)
And it works.