Object creation during game runtime.

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
soldier_
Posts: 2
Joined: Wed Oct 26, 2005 10:23 am

Object creation during game runtime.

Post by soldier_ »

Hi everyone!
I have a question on Irrlicht scene management system.
I have downloaded the Newton-irrlicht tutorial and took a look at the source code. In the demo application you have some boxes falling down from the sky. During the application if you make a mouse click a box appears in front of you. I took a look at the box creation code and I have noticed this:

NewtonCube *CGame::MakeCube(vector3df loc)
{
NewtonCube *tmp = new NewtonCube;

tmp->mesh = smgr->getMesh("data/smallcube.3ds");

I am confused about the last line. The application loads the mesh from the hard disk each time a new object is being created? Does't this slow down the application?
Guest

Post by Guest »

i guess the models are shared in memory if they are used more than once (would be stupid if it wouldnt be like this :D )
Podunk
Posts: 8
Joined: Sat Oct 08, 2005 12:42 am

Post by Podunk »

whatever you guess, soldier is saying that the code IS loading the mesh from a file every time the object is instantiated.

To answer your question, yes it is slower.
I R noob.
Please don't harp on me for asking noobie questions in the noob forum :P
WToma
Posts: 70
Joined: Tue Aug 09, 2005 8:38 am
Location: Szeged, Hungary

Post by WToma »

the code IS loading the mesh from a file every time the object is instantiated
When you call getMesh for the first time with a filename, it loads the mesh from the file. But if you call it more times, it will return the same object. So meshes are shared among mesh scene nodes. To physically load a mesh every time use the meshbuffer (new in 0.12).
(Anyway, I still need a function that copies a mesh optionally with its materials without loading it again from file.)
Toma
"This is not a bug, this is a feature!"
Guest

Post by Guest »

Thanks for your input. I have a better picture now on how mesh loading works.
soldier_
Posts: 2
Joined: Wed Oct 26, 2005 10:23 am

Post by soldier_ »

^^that was me
Post Reply