Problem with RenderQueue

dermont

24-04-2007 08:56:49

Does anyone have an example of using RenderQueueListener or CompositorChain::RQListener in python-ogre?.

The following C++ code hides the overlay as expected:

class MyRenderQueueListener : public Ogre::RenderQueueListener
{
void renderQueueStarted ( uint8 queueGroupId, const String & invocation, bool & skipThisInvocation)
{
if (queueGroupId== RENDER_QUEUE_OVERLAY){
skipThisInvocation = true;
}
}
void renderQueueEnded(uint8 queueGroupId,const String & invocation, bool & repeatThisInvocation)
{
if (queueGroupId== RENDER_QUEUE_OVERLAY){
repeatThisInvocation = true;
}
}
};

mSceneMgr->addRenderQueueListener(new MyRenderQueueListener());


The following python does not hide the overlay:

import ogre.renderer.OGRE as ogre
import SampleFramework as sf

class MyRenderQueueListener(ogre.RenderQueueListener):

def renderQueueStarted (self, id , invocation, skipThisInvocation):
if (id == ogre.RENDER_QUEUE_OVERLAY):
print "Queue Start Skip %i %i " % (id,ogre.RENDER_QUEUE_OVERLAY)
skipThisInvocation = True
return False

def renderQueueEnded (self, id , invocation,repeatThisInvocation):
if (id == ogre.RENDER_QUEUE_OVERLAY):
print "Queue End Repeat %i %i" % (id, ogre.RENDER_QUEUE_OVERLAY)
repeatThisInvocation = True


class EnvMapApplication(sf.Application):
def _createScene( self ):
sceneManager = self.sceneManager
camera = self.camera

sceneManager.ambientLight = ogre.ColourValue (0.5, 0.5, 0.5)

light = sceneManager.createLight('MainLight')
light.setPosition (20, 80, 50)

entity = sceneManager.createEntity('head', 'ogrehead.mesh')
entity.setMaterialName("Examples/EnvMappedRustySteel")
self.myRenderQueueListener = MyRenderQueueListener()
self.renderQueueListener = sceneManager.addRenderQueueListener( self.myRenderQueueListener)
sceneManager.getRootSceneNode().createChildSceneNode().attachObject(entity)

if __name__ == '__main__':
try:
application = EnvMapApplication()
application.go()
except ogre.OgreException, e:
print e

andy

24-04-2007 11:39:23

It would seem to be a bug on my part -- I specifically 'dealt' with these functions in generate_code, but didn't get it right as I didn't realise they were actually callbacks..

Could you raise a ticket on python-ogre.org and I'll fix it

Cheers

Andy

saladin

18-06-2007 01:54:08

It would seem to be a bug on my part -- I specifically 'dealt' with these functions in generate_code, but didn't get it right as I didn't realise they were actually callbacks..

Could you raise a ticket on python-ogre.org and I'll fix it

Cheers

Andy


Hi, trying out RC2 here and calling sceneManager.addRenderQueueListener() gave me a python.exe error dialog box even when all I'm adding is the ogre default RenderQueueListener.

Just wondering what's going on there.

andy

18-06-2007 02:49:47

I would think you have to subclass the renderqueue listener and pass that to the addrenderqueuelistener call. I'm less sure that there is a valid "default" listener..

Could you post some code to show what you are doing..

Cheers
Andy

saladin

18-06-2007 03:54:59

I would think you have to subclass the renderqueue listener and pass that to the addrenderqueuelistener call. I'm less sure that there is a valid "default" listener..

Could you post some code to show what you are doing..

Cheers
Andy


Yep sure. Here's the code. Everything seems to work if I comment out the line "self.sceneManager.addRenderQueueListener(stencilOpListener)". U'll need the "cg/glow" material to see the glow. Simply comment the 'setMaterial' line if u just want to reproduce the error.

Cheers.


import ogre.renderer.OGRE as ogre
import SampleFramework as sf
RENDER_QUEUE_OUTLINE_GLOW_OBJECTS = ogre.RENDER_QUEUE_MAIN + 1
LAST_STENCIL_OP_RENDER_QUEUE = RENDER_QUEUE_OUTLINE_GLOW_OBJECTS
STENCIL_VALUE_FOR_OUTLINE_GLOW = 1
STENCIL_FULL_MASK = 0xFFFFFFFF

class StencilOpQueueListener(ogre.RenderQueueListener):
def renderQueueStarted(self, queueGroupId, invocation, skipThisInvocation):
if (queueGroupId == RENDER_QUEUE_OUTLINE_GLOW_OBJECTS):
renderSys = ogre.Root.getSingleton().getRenderSystem()
renderSys.clearFrameBuffer(ogre.FBT_STENCIL)
renderSys.setStencilCheckEnabled(True)
renderSys.setStencilBufferParams(ogre.CMPF_ALWAYS_PASS, STENCIL_VALUE_FOR_OUTLINE_GLOW, STENCIL_FULL_MASK, ogre.SOP_KEEP,
ogre.SOP_KEEP, ogre.SOP_REPLACE, False)

def renderQueueEnded(self, queueGroupId, invocation, repeatThis):
if queueGroupId == LAST_STENCIL_OP_RENDER_QUEUE:
renderSys = ogre.Root.getSingleton().getRenderSystem()
renderSys.setStencilCheckEnabled(False)
renderSys.setStencilBufferParams()

class GlowApplication(sf.Application):

def _createScene(self):
self.sceneManager.setAmbientLight(ogre.ColourValue(0.5, 0.5, 0.5))
l = self.sceneManager.createLight("MainLight")
l.setPosition(20, 80, 50)

outlineGlowEntity = self.sceneManager.createEntity("outlineGlow", "ogrehead.mesh")
outlineGlowEntity.setRenderQueueGroup(RENDER_QUEUE_OUTLINE_GLOW_OBJECTS)
self.sceneManager.getRootSceneNode().createChildSceneNode().attachObject(outlineGlowEntity)

actualOutlineGlowEntity = outlineGlowEntity.clone(outlineGlowEntity.getName() + "_glow")
actualOutlineGlowEntity.setRenderQueueGroup(RENDER_QUEUE_OUTLINE_GLOW_GLOW)
actualOutlineGlowEntity.setMaterialName("cg/glow")
actualOutlineGlowNode = outlineGlowEntity.getParentSceneNode().createChildSceneNode("outlineGlowNode")
actualOutlineGlowNode.attachObject(actualOutlineGlowEntity)

def _createFrameListener(self):
"""Creates the FrameListener."""
sf.Application._createFrameListener(self)
stencilOpListener = StencilOpQueueListener()
self.sceneManager.addRenderQueueListener(stencilOpListener)

if __name__ == '__main__':
try:
application = GlowApplication()
application.go()
except ogre.OgreException, e:
print e

dermont

18-06-2007 04:53:41

I think you should hold a reference to your Listener:

self.stencilOpListener = StencilOpQueueListener()
self.sceneManager.addRenderQueueListener(self.stencilOpListener)

saladin

19-06-2007 00:17:52

I think you should hold a reference to your Listener:

self.stencilOpListener = StencilOpQueueListener()
self.sceneManager.addRenderQueueListener(self.stencilOpListener)


Oh, that's right... otherwise python garbage collects it before it's called again?