More questions regarding scenenodes

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
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

More questions regarding scenenodes

Post by odenter »

After I asked how to handle GameObjects and their SceneNodes, i've got a new problem.
I thought I create all SceneNodes at startup and let irrlicht do the rest. But it looks like that this isn't working.

I've load a Model and want to create 150000 SceneNodes with this Model. But I get a exception after 238 scenenodes in a debug build and 245 scenenodes in a release build. Looks like I hit the 2 GB barrier.

Code: Select all

 
//That's some code to show how I create the SceneNodes
irr::core::vector3df starPosition = itStars->first;
GameObjects::PTR_STARSYSTEM star = itStars->second;
irr::scene::ISceneNode * sceneNodeStar = Helper::IrrlichtHelper::GetInstance()->Device()->getSceneManager()->addOctreeSceneNode(genericMesh->getMesh(0));
sceneNodeStar->setPosition(starPosition);
sceneNodeStar->setMaterialFlag(irr::video::EMF_LIGHTING, false);
sceneNodeStar->setMaterialFlag(irr::video::EMF_NORMALIZE_NORMALS, false);
sceneNodeStar->setDebugDataVisible(irr::scene::EDS_OFF);
sceneNodeStar->setParent(sceneNodeRoot);
GameObjectHelper::GetInstance().AttachObjectToSceneNode(sceneNodeStar, star);
sceneNodeRoot->addChild(sceneNodeStar);
 
// light per star
irr::scene::ISceneNode *sceneNodeLight = sceneManager->addLightSceneNode(0, starPosition + irr::core::vector3df(200, 200, 200), irr::video::SColorf(1.0f, 1.0f, 1.0f), 2000);
sceneManager->setAmbientLight(irr::video::SColorf(0.3f, 0.3f, 0.3f));
 
When each node is created irrlicht says my Model has 39600 polys.

Maybe I misunderstood the scenegraph but I thought I just create all nodes and irrlicht does the rest. So how do I get 150000 scenenodes working without switching to x64 build? 150000 is more like a test 1500 Stars * (max) 10 Planets per Star + (Ship's Spacestations and other fancy stuff)

Do I have to create scenenodes and delete them depending on what is visible by the user? Sounds wrong to me.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: More questions regarding scenenodes

Post by hendu »

150k draw calls = you will have 0.05 fps. On a supercomputer.
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Re: More questions regarding scenenodes

Post by odenter »

hendu wrote:150k draw calls = you will have 0.05 fps. On a supercomputer.
I don't want to draw 150k Objects at once. But I'll want to have that much objects or more in total. So I have to create and destroy scenenodes the whole time?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: More questions regarding scenenodes

Post by hendu »

Yes. You are asking for something the hw cannot handle, and no amount of magic will save you. The result would be just as bad in Unity or UE4.

Try to have less than 1k scene nodes at all times. Only the close objects should be real nodes, everything far away should be drawn by one background node.
AReichl
Posts: 270
Joined: Wed Jul 13, 2011 2:34 pm

Re: More questions regarding scenenodes

Post by AReichl »

silly question here:

sceneNodeStar->setParent(sceneNodeRoot);
...
sceneNodeRoot->addChild(sceneNodeStar);

is that really required? Looks to me like "shooting through your chest into your foot".
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: More questions regarding scenenodes

Post by CuteAlien »

No, setParent and addChild do the same, so you only need to call one of them.
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
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Re: More questions regarding scenenodes

Post by odenter »

Mh ok.
That means one scenenode equals one draw call?

But with my example sphere mesh I just can create 238 scenenodes at once before going out of userspace memory (32bit). Are 40k polys per mesh are many? I've no experience with that.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: More questions regarding scenenodes

Post by hendu »

You ran out of memory because you created Octree nodes. Normal nodes don't take much RAM.
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Re: More questions regarding scenenodes

Post by odenter »

Ok thanks.
Looks like that I've to play around a bit and try some things. I was hoping that I can create all scenenodes at start. Now I've to rewrite some things. Currently I'm sick, so I think next week I can go on.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: More questions regarding scenenodes

Post by hendu »

Well, to be exact, you can create them all at once and then detach them from the scene graph, but at your scale that would be really wasting memory.
odenter
Posts: 48
Joined: Thu Oct 21, 2004 10:35 am
Location: Bremen (Germany)

Re: More questions regarding scenenodes

Post by odenter »

hendu wrote:Well, to be exact, you can create them all at once and then detach them from the scene graph, but at your scale that would be really wasting memory.
I've had already other memory issues and switched to a x64 build. :roll:
I'll create a 2d grid, position of my objects just differ on 2 axis, and create scenenodes for all visible objects in the current active and surrounding cell's of my grid and then create/destroy scenenodes. I think that should work fine.
Post Reply