[PATCH] loadScene and saveScene with parent (loadSubScene)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
Post Reply
wts
Posts: 5
Joined: Thu Nov 12, 2009 8:04 am

[PATCH] loadScene and saveScene with parent (loadSubScene)

Post by wts »

Hi,
I've modified loadScene adding a ISceneNode* as parameter.
It's useful to create ripetitive scenes.

This is the patch:
https://sourceforge.net/tracker/?func=d ... tid=540679
Last edited by wts on Sat Jan 02, 2010 6:30 pm, edited 2 times in total.
CuteAlien
Admin
Posts: 9930
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks, I think it's probably a good idea.
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
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

yes, nice idea... :)
but there is one thing that's not so good:

Code: Select all

-  virtual bool loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer=0) = 0;
+  virtual bool loadScene(const io::path& filename, ISceneNode* parent=0, ISceneUserDataSerializer* userDataSerializer=0) = 0;
this changes can break older codes !!!
you should set "ISceneNode* parent=0" as last parameter, so older codes will work without changing the code...
or make a new (overwritten) function... ;)

and another nice addition would be to make the saveScene function similar... ;)
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
wts
Posts: 5
Joined: Thu Nov 12, 2009 8:04 am

Post by wts »

Acki wrote:this changes can break older codes !!!
you should set "ISceneNode* parent=0" as last parameter, so older codes will work without changing the code...
I thought it, but watching the doc i notice that ISceneNode*parent is ever the first default parameter, and I think it's more likely that ISceneUserDataSerializer* is passed as NULL
Acki wrote:or make a new (overwritten) function... ;)
Something like this?

Code: Select all

bool CSceneManager::loadScene(const io::path& filename, ISceneUserDataSerializer* userDataSerializer)
{
return loadScene(filename, 0, userDataSerializer);
}
Acki wrote:and another nice addition would be to make the saveScene function similar... ;)
I'm working on it :wink:
wts
Posts: 5
Joined: Thu Nov 12, 2009 8:04 am

Post by wts »

Hi,
I've modified previous patch:
- readSceneNode now doesn't create a new emptynode
- added functions for backward compatibility
- added saveScene with 'ISceneNode* parent' parameter

Note:
saveScene doesn't use parent's attributes (position, orientation scale, ecc) but root's

Feedback is highly appreciated!

Bye^2
Post Reply