smgr->clear() prevents smgr->loadScene() ??

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.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

smgr->clear() prevents smgr->loadScene() ??

Post by JP »

I'm trying to clear my current scene and load a new one in straight away so i basically have the following:

smgr->clear();

smgr->loadScene(filename);

But this prevents the new scene actually being loaded... If i comment out clear() then the new scene loads fine (but of course the old scene is still present).

Has anyone come across this before? I checked the docs and it doesn't say i have to call any other functions in between or anything...

(i'm using 1.3.1 by the way)
Image Image Image
hybrid
Admin
Posts: 14144
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Could you check (debug) why it refuses to load? Any messages on the console? Does it crash or just not load (or not show) the scene?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

:? clear() then loadScene() Works For Me in the latest SVN version, at least with simple scenes.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

loadScene() returns true to suggest it's loaded fine but then nothing shows up... there's no crash or anything...

There's no messages to the console either.
Image Image Image
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Maybe you need some kind of update in between?

eg:

smgr->clear();
device->run();
smgr->drawAll();
smgr->loadScene();
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I did think of that... i'll give it a try...

I'll also probably try updating to 1.4 and see if it works any better!
Image Image Image
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Well that didn't help at all...

I'm considering, as a temporary fix, creating a new smgr each time a new scene needs to be loaded and 'forcing' that to be treated as the main smgr (it's a shame you can't actually set the main smgr instead of having to pass on events to it, but i guess it's not too much extra work).

updating to 1.4 is definetly on my list of things to do but i don't particularly want to tackle that right now as it's not the simplest of jobs, as i found out last time i attempted the update :lol:
Image Image Image
Boca
Posts: 12
Joined: Tue Mar 04, 2008 4:35 pm
Location: Spain

Post by Boca »

I have the same problem but with 1.4 version. :roll: I'm going to add a smgr for diferents scenes. :?
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

That's weird.
I added this code:

Code: Select all

if(device->getTimer()->getTime() == 2000)
{
	smgr->clear();
	smgr->loadScene("../../media/example.irr");
}
To example 08.SpecialFX:
v1.4: After clear() I see the textures are loaded (in the console) but nothing on screen, black window.

SVN Revision 1354 (trunk): Same.

P.S

Code: Select all

while(device->run())
	if (device->isWindowActive())
	{
		driver->beginScene(true, true, 0);

		smgr->drawAll();

		driver->endScene();

		int fps = driver->getFPS();

		if (lastFPS != fps)
		{
			core::stringw str = L"Irrlicht Engine - SpecialFX example [";
			str += driver->getName();
			str += "] FPS:";
			str += fps;

			device->setWindowCaption(str.c_str());
			lastFPS = fps;
		}

		if(device->getTimer()->getTime() == 2000)
		{
			smgr->clear();
			smgr->loadScene("../../media/example.irr");
		}
	}
Then I guess you did found something JP..
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
MasterGod
Posts: 2061
Joined: Fri May 25, 2007 8:06 pm
Location: Israel
Contact:

Post by MasterGod »

rogerborg wrote::? clear() then loadScene() Works For Me in the latest SVN version, at least with simple scenes.
Which code did you use?

Edit:
You say "at least with simple scenes", well, it happens with example.irr which is a very simple scene...
Last edited by MasterGod on Thu May 22, 2008 2:48 pm, edited 1 time in total.
Image
Dev State: Abandoned (For now..)
Requirements Analysis Doc: ~87%
UML: ~0.5%
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Ahh well i'm glad i'm not the only one and that i've stumbled upon a bug of some sort.... although i'm surprised it hasn't come up before seeing as lots of people seem to be struggling with it now...

And i guess i can put off updating to 1.4 seeing as that doesn't seem to solve anything!
Image Image Image
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

MasterGod wrote:
rogerborg wrote::? clear() then loadScene() Works For Me in the latest SVN version, at least with simple scenes.
Which code did you use?

Edit:
You say "at least with simple scenes", well, it happens with example.irr which is a very simple scene...
Example 01. I just put in a smgr->saveScene() before the main loop, ran it, then replaced it with a smgr->clear() and smgr->loadScene(), again before the main loop (with the return values checked). That said, I'm just assuming that what I'm seeing is the results of the loaded scene; it's possible that both the clear() and loadScene() failed. ;)
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

Are you certain that the problem isn't that the camera was wiped out and not re-created [or at least cached and re-inserted into the scene graph]?

The example.irr scene file doesn't have a camera in it, and most applications create a camera in the main loop, so you might run into problems if you don't setup a camera after clearing the scene.

Travis
Boca
Posts: 12
Joined: Tue Mar 04, 2008 4:35 pm
Location: Spain

Post by Boca »

The error is caused because of "smgr->clear()".
I quitted "smgr->clear()" and it ran.
But, if I quit "loadScene()" (already loaded a scene) and I put "smgr->clear()", it´s blocked. :?
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You know what Vitek.... You might have cracked it there!

I completely forgot about the camera being part of the scene so smgr->clear() would remove it and it's not actually part of the scene that's loaded in so then the smgr just won't render anything!

I'll give that a go but i'm fairly sure that's the problem!

EDIT: Sorted, thanks very much Vitek, you get the gold star. Everyone else will have to make do with a sliver star... to share between you... you did good, but not quite good enough!

But seriously, thanks everyone who chipped in to help out! I really appreciate it!
Image Image Image
Post Reply