Page 1 of 1

Best way to add multiple models [SOLVED]

Posted: Fri Dec 02, 2011 3:15 pm
by TJBaldy
I did a quick search before posting this and didn't find anything that was specific to my question.

OK so I'm new to Irrlicht, new to c++ in fact.

My question is how would be best to load different models in to my scene? I currently have about five different 3D models loaded into my scene hovering above a terrain I created from the terrain tutorial. At the moment I'm using the method from tutorial 1 where you create a mesh then a node for the mesh, then an if statement for each node. So how would be best to do it? Also, how would I go about using the same model and loading it multiple times across the terrain (e.g a tree).

Thanks for everyones replies in advance :D

Tom

Re: Best way to add multiple models.

Posted: Fri Dec 02, 2011 3:49 pm
by CuteAlien
You can have multiple nodes working with the same mesh. So you need to load the mesh just once and then can use it all over the place. Maybe check this page on Wiki if you're new to this stuff: http://www.irrlicht3d.org/wiki/index.ph ... ommonTerms

For larger scenes you will no longer load each model one-by-one in code, but instead use some scene-format. You can for example use the .irr format which allows you to create scene in irrEdit which you can load then with a single command.

Re: Best way to add multiple models.

Posted: Fri Dec 02, 2011 3:52 pm
by hybrid
Well, sounds really like a basic programming question. You can refine all those steps into a function and call that function with the mesh file name, returning the scene node. This would save code duplication. Other possibility is to create a scene file somewhere and load a whole scene with one call. This is only applicable if you can create the scene file prior to all this of course.
Loading the same mesh multiple times does not create a significant overhead. Irrlicht has a mesh cache which avoid mesh duplication. You could be a little more efficient by storing the mesh pointer and adding scene nodes from that mesh multiple times. But since you don't call this method thousands of times it's ok to go first the first approach.
Ahh, CuteAlien was faster, but I'll still post my text...

Re: Best way to add multiple models.

Posted: Mon Dec 05, 2011 6:45 pm
by TJBaldy
Thanks for the replies guys. I've managed to work out how to add multiple objects of the same item by playing around with the code. I added three tree objects using the same mesh :). My project is part of a University Degree and the course is about using a game engine so unfortunately I can't just go and create a scene using some software and then load it up with code.

Re: Best way to add multiple models.

Posted: Tue Dec 06, 2011 11:28 am
by randomMesh
the course is about using a game engine so unfortunately I can't just go and create a scene using some software and then load it up with code.
Irrlicht is NOT a game engine, it's a 3D engine. There's a huge difference.
And you can compose your scene with irrEdit and load it in Irrlicht easily.

Re: Best way to add multiple models.

Posted: Tue Dec 06, 2011 7:52 pm
by shadowghost21
It's not hard to make into a game engine. You just need to write all that code yourself :) Irrlicht is pretty simple to work with and has some nice wrappers and data structures, one I am particularly in love with ATM is array<T> <3

Re: Best way to add multiple models.

Posted: Mon Jan 09, 2012 2:21 pm
by TJBaldy
Yeh I meant 3D engine... Thanks again for everyone's help :D