embeding data in .irr files

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.
Post Reply
wiznoe
Posts: 8
Joined: Wed Jun 18, 2008 4:40 am
Location: Jogja, Indonesia

embeding data in .irr files

Post by wiznoe »

hi all,
how to embed data such as level name, score, etc in .irr file?
Can I do that in irredit?
via smgr->saveScene()?
if there is away to do that, how to read them after file is saved?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

why not call the scene the name of the level it's representing and why would you want to put score into the .irr file? the player's score? that's got nothing to do with the scene, that should be saved to a seperate file entirely that you decide how to structure.
Image Image Image
pera
Posts: 460
Joined: Wed May 14, 2008 1:05 pm
Location: Novi Sad, Serbia
Contact:

Post by pera »

you can make class (CLevel) that inherits ISceneUserDataSerializer,
that class should have to functions:
createUserData
OnReadUserData
when you call smgr->saveScene() createUserData is called for every scene node. you can store your data with one of the nodes, for example, if sceneNode->ID == 56, save embedded data.

Then later when you load your scene, OnreadUserData is called, simply check again if sceneNode->Id is 56, and read your data from it.

In irr file they will be stored like this:

<userData>
<attributes>
<string name="Homepage" value="www.mystic-peanut.com" />
</attributes>
</userData>

search "ISceneUserDataSerializer" for more info.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

The functions would actually be:

Code: Select all

//! Writes attributes of the scene node.
		virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options=0);

		//! Reads attributes of the scene node.
		virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options=0);
And yeah you could store extra data in the scene like this, it's a bit weird but doable. You'd have to write a scene node plugin for your CLevel to be able to store the data into the .irr file via IrrEdit though. Or write your own little app that would write it for you or edit the .irr file by hand i guess.
Image Image Image
Post Reply