28-11-2010 03:28:01

I was going through Nullsoft's SSAO Compositor Demo and one of the classes(structs) he creates subclasses CompositorInstance.Listenener:
struct ssaoListener: public Ogre::CompositorInstance::Listener

CompositorInstance.Listener is static in Mogre and, as far as I know, C# does not allow you to subclass a static class. The other problem, which I just realized, is that addListener is not a part of the CompositorInstance in Mogre but it is in Ogre. Have I missed something?

Full shadowListener from his demo:
struct shadowListener: public Ogre::SceneManager::Listener
// this is a callback we'll be using to set up our shadow camera
void shadowTextureCasterPreViewProj(Ogre::Light *light, Ogre::Camera *cam, size_t)
// basically, here we do some forceful camera near/far clip attenuation
// yeah. simplistic, but it works nicely. this is the function I was talking
// about you ignoring above in the Mgr declaration.
float range = light->getAttenuationRange();
// we just use a small near clip so that the light doesn't "miss" anything
// that can shadow stuff. and the far clip is equal to the lights' range.
// (thus, if the light only covers 15 units of objects, it can only
// shadow 15 units - the rest of it should be attenuated away, and not rendered)

// these are pure virtual but we don't need them... so just make them empty
// otherwise we get "cannot declare of type Mgr due to missing abstract
// functions" and so on
void shadowTexturesUpdated(size_t) {}
void shadowTextureReceiverPreViewProj(Ogre::Light*, Ogre::Frustum*) {}
void preFindVisibleObjects(Ogre::SceneManager*, Ogre::SceneManager::IlluminationRenderStage, Ogre::Viewport*) {}
void postFindVisibleObjects(Ogre::SceneManager*, Ogre::SceneManager::IlluminationRenderStage, Ogre::Viewport*) {}
} shadowCameraUpdater;

Initialization of listener:

//Ogre::CompositorInstance *ssao initialized above.
void initSSAO()
ssao = Ogre::CompositorManager::getSingleton().addCompositor(mgr.vp, "ssao");


28-11-2010 03:41:36

Instead of a listener you have to use the NotifyMaterialSetup, NotifyMaterialRender and NotifyResourcesCreated events of CompositorInstance.


28-11-2010 03:46:20

Bugger, beat me to my own response. Yeah apparently I can't grok a simple readme and I missed the Ogre to Mogre introduction page where it spells out exactly what I need changed. My apologies.