ISceneNodel custom data

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.

ISceneNodel custom data

Postby zielin » Sun Oct 15, 2017 8:19 pm

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?
zielin
 
Posts: 17
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: ISceneNodel custom data

Postby CuteAlien » Sun Oct 15, 2017 10:01 pm

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.freenode.net
Code snippets, patches&stuff: http://www.michaelzeilfelder.de/irrlicht.htm
Free racer created with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
User avatar
CuteAlien
Admin
 
Posts: 8365
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany

Re: ISceneNodel custom data

Postby zielin » Sun Oct 15, 2017 11:03 pm

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.
zielin
 
Posts: 17
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland

Re: ISceneNodel custom data

Postby Mel » Thu Oct 19, 2017 9:55 am

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
User avatar
Mel
Competition winner
 
Posts: 2224
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: ISceneNodel custom data

Postby zielin » Fri Oct 20, 2017 7:57 am

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.
zielin
 
Posts: 17
Joined: Thu Aug 02, 2012 5:45 am
Location: Poland


Return to Open Discussion and Dev Announcements

Who is online

Users browsing this forum: No registered users and 1 guest