Getting Error trying to implement Listeners in PLSM2

kartweel

13-11-2006 13:39:58

I've been looking at the Paging Landscape SceneManager and it looks great. In using it I have hit a bit of a stump in implementing the listeners. I can't for the life of me figure out how in the Demo Application the listeners are used. As far as I can tell they aren't called, so I am not sure how to implement them in my application.

In my application I have tried "new CustomPagingLandScapeListener(mSceneMgr)" (from PagingLandScape2TerrainListener.h), but when calling mSceneMgr->setOption() to register the listeners it gives me an access violation. The error is: Unhandled exception at 0x0a8de3f1 in OgreTute.exe: 0xC0000005: Access violation reading location 0x00000004.

I take it I am doing something wrong, but I can't figure out what. It looks like it is trying to jump to some code miles off where it should be.

I haven't used delegates in c++ before so I am not sure if I am doing something wrong there, but I thought in copying the demo app it should be right.

Thanks

Kartweel

er

13-11-2006 15:38:03

for example loadTile event:

PagingLandscapeDelegate * loadTileDelegate;
loadTileDelegate = new PagingLandscapeDelegate();
loadTileDelegate->bind(this,&SomeObject::tileLoaded); // Function to be called
SceneManager->setOption("addLoadTileListener",loadTileDelegate);

SomeObject::tileLoaded(PagingLandscapeEvent* event)
{
// do here what you want when tile is loaded
}


see here little longer example

If this what you are after

kartweel

14-11-2006 03:05:56

What you have written is what I have.

SceneManager->setOption("addLoadTileListener",loadTileDelegate);

When this line executes I get the access violation. I have tried quite a few variations and rewritten several times. I'll try a different version of PLSM and see how that goes.

I read somewhere about statically linking to PLSM for the listeners to work, but I also read in a changelog that it was no longer required.

Thanks

er

14-11-2006 17:32:46

Umh .. I just remembered having similar problems ... just can't remember what was causing it. Faint memory of calling things too early or something.

And no need for statically linking.

kartweel

17-11-2006 08:20:56

Hmm.. I got the CVS version of PLSM2 and no joy. I started again from scratch (on linux using eclipse instead of vs2003) and it is working fine on there.

So must be something to do with my build configuration on windows.

I'll post again when I figured it out