ISceneNodel custom data

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

ISceneNodel custom data

Post by zielin »

Hello,

I can't find any mechanism that allows storing custom data per ISceneNode. IAttributeExchangingObject which is base class for ISceneNode, contains only method for serialization and deserialization of parameters like rotation, position scale etc. but there is not any method for custom data. I understand its main purpose is saving and loading scenes from different file formats. But, If user could read/write any data for any ISceneNode it would give features for easy integration with physics library, netwotk library etc. Storing this metadata inside irrlicht XML file will give great tool for storing custom node data. My second idea is to create some metadata registry with ISceneNode ID as key and some std::map with parameters as value. Main advantage of this solution is that it doesn't modify any existing API. What do You think about this?
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: ISceneNodel custom data

Post by CuteAlien »

Yeah, there is no mechanism for custom data is scenenodes. So using a map (or any other kind of lookup) is also the way I do stuff. Thought you have to be a little bit careful as ID's are also used in collision (for purely historical reasons...). So if you need that as well you have to be careful. 2 other choices are using names (can be slow) or pointers (in which case you have to be careful when releasing/creating pointers as pointer addresses can be re-used).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: ISceneNodel custom data

Post by zielin »

Using callbacks during scene node destruction may provide mechanism for removing unused pointers from map, so storing pointers as key would be a good solution.
However Irrlicht should provide some functions like setProperty(name, value) and getProperty(name) on ISceneNode for general purpose properties. Irrlicht XML could be used as storage for many non-grpahics properties for meshes.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: ISceneNodel custom data

Post by Mel »

If you feel confidant in your skills, you could add all what you need to the ISceneNode source, recompile, and have all those by yourself, as far as you don't touch anything vital to Irrlicht (such as removing/altering crucial methods), anything goes :) But it is true that Irrlicht could use some justice in that custom property setting matter
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
zielin
Posts: 20
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: ISceneNodel custom data

Post by zielin »

Yes, I wrote some setters and getters and extended data seerialization and deserialization, so values could be saved into XML irrlicht file.
I'll publish code after I refactor it.
Post Reply