OSMSceneCallbacks method

NHunter

11-03-2006 17:34:47

First,Lioric,congratulations for this big great plugin XD

Second...can you explain a bit please how to use the Callbacks methods,i mean,in help file there isnt too much information and i´m a bit lost.
For example ,once the escene has being loaded by OSM,take certains elements like lights created in max for interactive manipulation in real time.

Again,thanks,and sorry for my poor english.

NHunter

13-03-2006 15:33:22

ok,maybe i explain so bad or so generic question is.

Code:
oScene.initialise("probe.osm",&oe);
oScene.createScene();
mSceneMgr = oScene.getSceneManager();

Light* light;
TiXmlElement* pp;
TiXmlElement* d=pp->Attribute("name");

oe.OnLightCreate(Light *light,d);
light->setVisible(false);

of course this code is bad,but i only try to get an idea of how control objects created and loaded by the OSMloader.
in this case i suposse that OnLightCreate return me the last light of the list,but i dont know how i must "receive" her.
Can I explore the Xml by myself and take the attributes this way?

thx.

Lioric

13-03-2006 16:55:33

In the Scene Loader Demo is an example of the osm callback use, in there you will see how easy is to get the events

I will describe some major points:

You need to create an object (in the c++ sense) derived from the 'OSMSceneCallbacks' interface, and implement the methods you requiere for example to be notified when a light is created, you will override the 'OnLightCreate' method

This method will be called every time a new light is loaded and created[\b], with the pointer to the Light (Ogre::Light*), so you can use this ready light in any way you want in your application, and access the light methods as normal

The 'pLightDesc' argument that is passed to that function is for using the custom attibutes, or to access to the base attributes

In your example if you just want to get the name of the created light, you just need to call the 'getName' method of the light directly, i.e pLight->getName(), so in this simple case you will not use 'pLightDesc' argument

In the Demo application you will see that every camera loaded is queried for its name, and if a camera named "FirstCamera" is loaded, the application sets it as the default camera

This is very similar to what you requiere

NHunter

14-03-2006 15:01:58

thx lioric,i didnt see that detail on the Demo sorry :wink:

NHunter

15-03-2006 04:20:32

well...the callback method in the Demo works very very well

sorry if this is a very noob question but when i integred the SAME way in my app,the return of the call goes ALWAYS to the interface (IOSMSceneCallbacks.h),and ignored this code

#include "OgreOSMScene.h"
#include "TutorialFrameListener.h"
#include "ExampleApplication.h"

class oSceneCallBack : public OSMSceneCallbacks
{
public:
void OnLightCreate(Ogre::Light *pLight, TiXmlElement* pLightDesc) {
if(pLight->getName() == "FirstLight")
pLight->setVisible(false);
}
};

It is as if it was ignoring the inheritance and i tried all posibilities (maybe problem with headers,included...etc etc...nothing).
Compile perfect,from the class there is acess to the methods,all looks right,but at execution time,literally ignore it.
Anyone as the same problem? i'm using 1.0.7 source,and at this point,never with problems like this.

thx

Lioric

15-03-2006 15:49:00

Are you creating an instance of the derived object "oSceneCallback" and passing its pointer to the "initialize" method?

NHunter

15-03-2006 16:19:20

yes lioric

OSMScene oScene;
OSMSceneCallbacks oe;
oScene.initialise("probe.osm",&oe);
oScene.createScene();

it must be murphy´s law...... :)
XD

blinkseb

20-03-2006 16:03:53


OSMScene oScene;
OSMSceneCallbacks oe;
oScene.initialise("probe.osm",&oe);
oScene.createScene();


You have to use OSMSceneCallback instead of OSMSceneCallbacks. It should work as you expect !

NHunter

20-03-2006 16:21:50

oh! dawn...XD
thanks blinkseb :oops: