Multiple meshes in .dae - only one shows up

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Jallen
Posts: 46
Joined: Tue Jun 19, 2007 5:28 pm
Location: Hampshire, England

Multiple meshes in .dae - only one shows up

Post by Jallen »

Hi. How am I able to get multiple meshes from a dae file, or load a dae file as one big mesh? I want people to be able to export from sketchup and just load it into my program, so sanitising the input isn't a solution for me. I need to be able to take the dae file as it is and load it all for use.

Here's my current code which only gets one of the meshes in the file:

Code: Select all

levelmesh = smgr->getMesh("maps/Tester/test.dae");
	if(!levelmesh)
	{
		// display some sort of error or something here
		device->drop();
		return;
	}

	levelnode = smgr->addAnimatedMeshSceneNode(levelmesh);
	if(!levelnode)
	{
		// display some sort of error or something here
		device->drop();
		return;
	}

	smgr->setAmbientLight(video::SColor(255, 128, 128, 128));
	levelnode->setMaterialFlag(video::E_MATERIAL_FLAG::EMF_LIGHTING, true);

	smgr->addCameraSceneNodeFPS();
Thanks.

edit:
I read some stuff on the docs about collada in getMesh and I tried doing this before loading the mesh.

Code: Select all

smgr->getParameters()->setAttribute(irr::scene::COLLADA_CREATE_SCENE_INSTANCES, true);
When doing this before my previous code, nothing shows up at all.

So I'm still stuck :P

Oh and I forgot to mention, the meshes in the dae all have textures assigned to them. Some share the same but there are about 5 in the file in total.

Thanks
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Can you upload the dae file? What does the console say? Are all items correctly recognized? IIRC, you must make sure that all objects are instanced in the scene. The scene parameter is meant to instantiate all other objects as well (if enabled), but I did not really implement it so far. It was only supported by the old Collada 1.2 loader. Also note that animated meshes are not loaded at all.
Jallen
Posts: 46
Joined: Tue Jun 19, 2007 5:28 pm
Location: Hampshire, England

Post by Jallen »

hybrid wrote:Can you upload the dae file? What does the console say? Are all items correctly recognized? IIRC, you must make sure that all objects are instanced in the scene. The scene parameter is meant to instantiate all other objects as well (if enabled), but I did not really implement it so far. It was only supported by the old Collada 1.2 loader. Also note that animated meshes are not loaded at all.
Here's the file:
http://dl.dropbox.com/u/5062494/Tester.zip

It's a win32 application and I'm using winmain, so I have no idea how to get the console window to show D:

I don't understand what you mean by "you must make sure that all objects are instanced in the scene" - Is there some way perhaps get an IAnimatedMesh for each mesh in the file that I am missing?

Thanks.
Jallen
Posts: 46
Joined: Tue Jun 19, 2007 5:28 pm
Location: Hampshire, England

Post by Jallen »

Code: Select all

smgr->getParameters()->setAttribute(irr::scene::COLLADA_CREATE_SCENE_INSTANCES, true);

	smgr->getMesh("maps/Tester/test.dae");
	scene::IMeshCache* cache = smgr->getMeshCache();

	for(int i = 0; i < cache->getMeshCount(); i++)
	{
		smgr->addAnimatedMeshSceneNode(cache->getMeshByIndex(i));
	}
Ok this worked for me, but they aren't textured.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I actually meant that you need the collada scene to include all meshes in order to show up. It actually has the whole scene, though. I guess it's a problem with too many nodes and node_instances in the scene. I'll have a look at it later on. The textures seem to be correctly recognized, but probably they are not created unless the node is really instanced in the scene. I'll try to fix the scene parameter to create the texture even for non-instanced meshes if it's set to true.
Jallen
Posts: 46
Joined: Tue Jun 19, 2007 5:28 pm
Location: Hampshire, England

Post by Jallen »

hybrid wrote:I actually meant that you need the collada scene to include all meshes in order to show up. It actually has the whole scene, though. I guess it's a problem with too many nodes and node_instances in the scene. I'll have a look at it later on. The textures seem to be correctly recognized, but probably they are not created unless the node is really instanced in the scene. I'll try to fix the scene parameter to create the texture even for non-instanced meshes if it's set to true.
Ok cool. If you develop a fix will I have to wait for irrlicht 1.8 before I can use it? D:

(fixing the problem with too many nodes or making it so that textures are created on non-instanciated meshes are both fine for me as I just want my complete textured scene)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Whether it will be part of Irrlicht 1.8 or 1.7.3 depends on the actual cause of this problem. Collada loader tends to be quite complicated, though, so it will be probably in 1.8 just for sure. You can always get the latest patches from SVN, though, and build your own Irrlicht version based on that code. Only if you require using an unmodified stable release, you will have to wait a little longer.
Jallen
Posts: 46
Joined: Tue Jun 19, 2007 5:28 pm
Location: Hampshire, England

Post by Jallen »

hybrid wrote:Whether it will be part of Irrlicht 1.8 or 1.7.3 depends on the actual cause of this problem. Collada loader tends to be quite complicated, though, so it will be probably in 1.8 just for sure. You can always get the latest patches from SVN, though, and build your own Irrlicht version based on that code. Only if you require using an unmodified stable release, you will have to wait a little longer.
Ok, thanks for all the help! :D
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, I now remembered this bug, as it happened before. But, as I already said last time, Irrlicht is working correctly. The problem is the XML tag order in the dae file. This is not conforming to the Collada specification. The Collada specs define the tag order in such a way that you usually don't need to look ahead of the current element. However, in your file the node instantiations come before the node library, and the materials come much later, where they are not added back to the existing nodes. It would be pretty much work to fix this, and I'd like to rely on a correct file content instead.
the thing is that probably most collada apps use the official collada parser, which is likely using DOM and can access all the elements in random access. But we can not, and hence you should probably contact Google first, and ask if they cannot export conforming collada files.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Post by ACE247 »

Sounds like I have a similar Issue, or maybe this is somewere in the doc's but I missed it. I've got say one mesh.obj file with a building mesh in it. One in its whole state and one in its destroyed state. Both as different groups, how can I only have one show at a time? Get Group? and Toggle invisible?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

No, this is a completely different story. Both meshes will load into only one mesh (because .obj files are simply defined as being one mesh). The groups will be kept in different meshbuffers, but there's not just one per group. You can have many buffers, one for each material. Separate groups would have their own buffers for each material then. Since it's not easily changeable on the fly, you should instead load two .obj files and switch meshes.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Post by ACE247 »

I was hopping you'd say otherwise. Maybe Irrlicht needs support for mesh groups then. Edit: -dumb bit removed-
Last edited by ACE247 on Wed Jan 12, 2011 7:17 pm, edited 1 time in total.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Well, just do it then. You can use setMesh(a) and setMesh(b) to switch between the two.
ACE247
Posts: 704
Joined: Tue Mar 16, 2010 12:31 am

Post by ACE247 »

Sorry for that. I noticed... Allthough there is still a quick flicker when switching meshes, and it gets a bit annoying. Edit: Solved by preloading both meshes into buffer instead of only when needed. :roll:

[No thread hijack intended]
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Ok, coming back to the OT here I seem to have wrongly accused SketchUp to produce illegal dae files. However, the fixed order that is required for the elements of the COLLADA tag (thte root tag) does apply to all *BUT* the library tags. So I have to change most of the guts of the collada reader in order to catch up with 1.4 and 1.5 Collada files. We're not the only ones who are hit by this (pretty useless, annoying, and time consuming) freedom in the Collada specs. So while the collada parsing was already slow before, I cannot really suggest to use this format for any game-related stuff (except with heavy preloading and a good loading screen :wink: ). Anyway, I'll try to fix this in the future.
Post Reply