how to use ISceneManager::registerSceneNodeFactory() ?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

how to use ISceneManager::registerSceneNodeFactory() ?

Post by koller202 »

i want to register irrklangScenenode

how to use this command i ask niko for this

http://www.ambiera.com/cgi-bin/forum/Bl ... 182924476/
________
Free gift cards
Last edited by koller202 on Thu Feb 17, 2011 1:10 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You need to create an instance of a class derived from ISceneNodeFactory and pass a pointer to it to the scene manager. Like so...

Code: Select all

audio::ISoundEngine* engine = audio::createIrrKlangDevice();

ISceneNodeFactory* factory = new audio::CIrrKlangSceneNodeFactory(engine, smgr);
  smgr->registerSceneNodeFactory(factory);
factory->drop();
Travis
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

Code: Select all

	ISoundEngine* engine = createIrrKlangDevice();
//	audio::ISoundEngine* engine = audio::createIrrKlangDevice(); 

ISceneNodeFactory* factory = new CIrrKlangSceneNodeFactory(engine, smgr); 
  smgr->registerSceneNodeFactory(factory); 
factory->drop();
	smgr->loadScene("../../media/sound.irr");
thank you vitek it work!!

but i have one more question
in irredit i heard 3d sound ( far decrease sound )

but load irr in irricht i heard 2d sound

irredit can put 3d sound ?
________
MACUMBA DICUSSION
Last edited by koller202 on Thu Feb 17, 2011 1:10 am, edited 1 time in total.
koller202
Posts: 143
Joined: Tue May 08, 2007 4:53 am
Location: Thailand

Post by koller202 »

oh i can do it

Code: Select all

engine->setListenerPosition(core::vector3df(camera->getAbsolutePosition().X,camera->getAbsolutePosition().Y,camera->getAbsolutePosition().Z), core::vector3df(camera->getAbsolutePosition().X,camera->getAbsolutePosition().Y,camera->getAbsolutePosition().Z));
put in main update loop

thank you
________
Cocaine Rehab Forum
Last edited by koller202 on Thu Feb 17, 2011 1:10 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

You might look at the sound listener and sound emitter nodes that I posted a while back. At the very least you might want to look at the listener node.

It automatically updated the listener 3d position as it moved around the scene. You would need to update it to work with Irrlicht 1.3.1 and write your own factory class, but that would be trivial.

Travis.
plotti
Posts: 21
Joined: Thu Oct 18, 2007 9:58 am

Post by plotti »

I am also using the CIrrKlangSceneNodeFactory.

I am using this code:

Code: Select all

	//Initialize Sound Factory to load sound in level
	ISceneNodeFactory* soundfactory = new CIrrKlangSceneNodeFactory(engine, smgr);
	smgr->registerSceneNodeFactory(soundfactory); 
	soundfactory->drop(); 
And am getting this error:
1>.\irrlichtdev.cpp(167) : error C2259: 'CIrrKlangSceneNodeFactory': Instanz von abstrakter Klasse kann nicht erstellt werden

In english: Instance of abstract class cannot be created.

Any suggestions?
________
Video Reviews
Last edited by plotti on Tue Feb 22, 2011 8:14 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

If I remember correctly, the error message should describe the problem in more detail.

The error is probably because the signature [name, parameter types, or return type] of one ore more member function of the base class has changed in Irrlicht and it needs to be updated in the IrrKlangSceneNodeFactory code.

Yes, that it it. Here is the declaration for scene node factories in Irrlicht...

Code: Select all

virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0);
virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0);
virtual u32 getCreatableSceneNodeTypeCount() const;
virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(u32 idx) const;
virtual const c8* getCreateableSceneNodeTypeName(u32 idx) const;
virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type) const;
Here are the functions implemented by the CIrrKlangSceneNodeFactory derived class.

Code: Select all

virtual ISceneNode* addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent=0);
virtual ISceneNode* addSceneNode(const c8* typeName, ISceneNode* parent=0);
virtual s32 getCreatableSceneNodeTypeCount();
virtual const c8* getCreateableSceneNodeTypeName(s32 idx);
virtual ESCENE_NODE_TYPE getCreateableSceneNodeType(s32 idx);
virtual const c8* getCreateableSceneNodeTypeName(ESCENE_NODE_TYPE type);
You need to update the IrrKlang code to match the Irrlicht declarations.

Travis
plotti
Posts: 21
Joined: Thu Oct 18, 2007 9:58 am

Post by plotti »

hi vitek thanks a lot for your help.
I updated the information and it compiled.

Another problem I have now I changed one line in the implementation:

Code: Select all

ISceneNode* CIrrKlangSceneNodeFactory::addSceneNode(ESCENE_NODE_TYPE type, ISceneNode* parent)
{
	if (!parent)
		parent = Manager->getRootSceneNode();

	if (type == IRRKLANG_SCENE_NODE_ID)
	{			
		CSoundEmitterSceneNode* emitter = new CSoundEmitterSceneNode(parent, Manager, -1);		
		node->drop();
		return node; 
	}

	return 0;
}
which was:

Code: Select all

CIrrKlangSceneNode* node = new CIrrKlangSceneNode(SoundEngine, parent, Manager, -1);
before since I am using the CSoundEmitterSceneNode and CSoundListenerNode implementation.

As far as I see i need to somehow get that sound attached to the soundengine or something...

It seems the Constructor of the irrKlangSceneNode is alreade pre-setting the values:

Code: Select all


	setAutomaticCulling(scene::EAC_OFF);
	MinDistance = 20.0f; // a usual good value for irrlicht engine applications
	MaxDistance = -1.0f;
	PlayMode = EPM_RANDOM;
	TimeMsDelayFinished = 0;
	DeleteWhenFinished = false;
	MaxTimeMsInterval = 5000;
	MinTimeMsInterval = 1000;
	Sound = 0;
	PlayedCount = 0;

	if (SoundEngine)
		SoundEngine->grab();

So I guess I have to pre-set them too, although for exmaple the min and max distance somehow should be present in the soundnote, and not set again to some default values.

EDIT: Sorry my fault. The IrrKlangSceneNode has those serialize functions and deserialize to read in the parameters etc...

I wonder how I can bring those two into the CSoundEmitterSoundNode thing?

ANOTHER EDIT: I think I will simply include those two, since they seem to be for different purposes, somehow. With one I can load the sounds from the map and with the other I can attach sounds to things during execution time.
________
Yamaha Mio History
Last edited by plotti on Tue Feb 22, 2011 8:14 am, edited 1 time in total.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

The code I wrote is different than what niko wrote. The sound emitter scene node doesn't use the sound engine, so it doesn't need a pointer to it. You, as the application developer, will use the engine to create audio::ISound instances. You then associate those sounds with the sound emitter scene node.

As for setting the defaults, you would need to setup the sound before you create the scene node, so most of them don't matter.

If you have any intention of using irrEdit to make scenes or serialize your scenes, I suggest you use the IrrKlangSceneNode stuff that niko provides. If you need the sound listener scene node functionality, you can easily add it to work with niko's code.

Travis
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

Where does

Code: Select all

audio
derive from?

Is it custom or built into the irrklang?, I tried to open the first topics link but it's void now so I can only imagine it's to do with that links code as I can't can't seem to find audio anywere and dont know where it's derived from, and because of that I can run this code.

Code: Select all

audio::  //...
Thus I can't create an irrKlangSceneNode, can someone please clarify it for me.
-System error
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

BUMP*

So I can' uset :

Code: Select all

CIrrKlangSceneNodeFactory(engine, smgr);CIrrKlangSceneNodeFactory(engine, smgr);
etc because I don't know where CIrrKlangSceneNodeFactory is derived from, help please.
-System error
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

That code doesn't do anything on its own. The namespace audio used to be where the IrrKlang scene node and scene node factory were. Those declarations do not seem to be in a namespace anymore, so you can remove the audio:: mention from the code posted above.

Oh, and it wouldn't hurt to take some time to get familliar with C++.

Travis
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

My C, C++ knowledge is fine thanks \: it's this part of the API i'm strugling with, perhaps you mis-understood me:

I have used the code:

Code: Select all

//Initialize Sound Factory to load sound in level 
scene::ISceneNodeFactory* soundfactory = new CIrrKlangSceneNodeFactory(engine, smgr); 
smgr->registerSceneNodeFactory(soundfactory); 
soundfactory->drop();  
And I get this error:
1>.\Main.cpp(327) : error C2061: syntax error : identifier 'CIrrKlangSceneNodeFactory'
Thus, 'CIrrKlangSceneNodeFactory' can not be found in any classes (namespace isn't their like you said) etc, that's were I'm having the trouble and can't find a replacement... should I just create my own that takes an argument if the irrklang engine initialization/definition and scene manager?

I hope their is an alternative.
-System error
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Systemerror wrote:My C, C++ knowledge is fine thanks \:
Then why would you expect to get such a compiler error? Perhaps the type CIrrKlangSceneNodeFactory hasn't been declared? Did you include the appropriate header file?
Systemerror wrote:Thus, 'CIrrKlangSceneNodeFactory' can not be found in any classes (namespace isn't their like you said) etc, that's were I'm having the trouble and can't find a replacement... should I just create my own that takes an argument if the irrklang engine initialization/definition and scene manager?
You're proposing you add your own declaration for the type? I don't know why you think that would be a good idea.

If the type CIrrKlangSceneNodeFactory isn't declared in any of the headers you have, perhaps you should find the header (and source) that declares (and defines) the type. I'd guess that the best place to look would be here.

Travis
Systemerror
Posts: 98
Joined: Fri Oct 03, 2008 1:25 pm
Location: UK
Contact:

Post by Systemerror »

I have irrKlang thanks and it's included in my source, it plays sounds, I am just having trouble solving this particular problem.
-System error
Post Reply