Page 1 of 1

New IMeshTextureLoader interface

Posted: Sun Mar 02, 2014 1:21 am
by CuteAlien
I've added today a rather large patch to svn: http://sourceforge.net/p/irrlicht/code/4703/
This adds a new interface called IMeshTextureLoader which can be used by MeshLoaders to find textures:
http://sourceforge.net/p/irrlicht/code/ ... reLoader.h

This affects for now the following meshloaders: 3DS, B3D, CSM, Collada, DMF, LMTS, LWO, MY3d, OBJ, OCT, Ogre, SMF, X.
Not using the new interface are: MS3D, CIrrMeshFileLoader, MDL, MD2, MD3 and BSP. Those continue to work as they did. I hope I'll get to those as well some day, but they are a little more tricky than the rest.

The idea behind the interface is:
a) Unify code. We had over a dozen independent implementation doing the same stuff in different ways before and nearly each one was incomplete.
b) Replacing old texture-path attributes like B3D_TEXTURE_PATH with one function: IMeshTextureLoader::setTexturePath. So now meshloaders like .X can also use custom texture paths. The attributes will be deprecated soon.
c) Allowing to set custom textureloaders. That can be used for all kind of stuff. For example you can call the old textureloader and when it fails you can now add some deliberate error-handling. Or you can set the textureloader to 0 and prevent textureloading for a format completely (useful for servers).

Unfortunately I don't have test-models for most meshloaders, so I can't do too much testing myself. Which means I would welcome if people test this patch. Also certainly all feedback is welcome - especially if I maybe forget some situations.

Re: New IMeshTextureLoader interface

Posted: Sun Mar 02, 2014 1:42 pm
by Darktib
That's a really good idea, one of the important details that was missing from Irrlicht !

How is the engine using these functions: getRecentTextureName, wasRecentTextureInCache ?

Re: New IMeshTextureLoader interface

Posted: Sun Mar 02, 2014 2:53 pm
by CuteAlien
getRecentTextureName is used by one loader that saves the name which was used on loading. I didn' dig deeper why it keeps that around. wasRecentTextureInCache is used by one loader (I think obj) to do some processing with certain textures when they are loaded the first time. Basically I added them so I could keep the old code intact.

edit: Now that you mentioned it... getRecentTextureName can maybe be kicked as the texture itself should probably know it's name. I'll take another look at that!

Re: New IMeshTextureLoader interface

Posted: Mon Mar 03, 2014 9:30 am
by Nadro
These changes looks really nice. I'll try to find some models on my HDD and test it.

Re: New IMeshTextureLoader interface

Posted: Mon Mar 03, 2014 1:10 pm
by CuteAlien
I reworked it once more and now it looks a lot better :-) The getRecentTextureName and wasRecentTextureInCache functions could both be kicked out. And ITexture has now a new getSource function which can be used to check if the texture came from cache or file.

Re: New IMeshTextureLoader interface

Posted: Mon Mar 03, 2014 5:34 pm
by CuteAlien
One more update - I had a big bug that prevented the new userpaths to work for several loaders (B3D, CSM, LMTS, MY3D, OBJ). Fixed in new trunk version (4710).