New IMeshTextureLoader interface

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

New IMeshTextureLoader interface

Post 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.
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
Darktib
Posts: 167
Joined: Sun Mar 23, 2008 8:25 pm
Location: France

Re: New IMeshTextureLoader interface

Post 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 ?
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: New IMeshTextureLoader interface

Post 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!
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
Nadro
Posts: 1648
Joined: Sun Feb 19, 2006 9:08 am
Location: Warsaw, Poland

Re: New IMeshTextureLoader interface

Post by Nadro »

These changes looks really nice. I'll try to find some models on my HDD and test it.
Library helping with network requests, tasks management, logger etc in desktop and mobile apps: https://github.com/GrupaPracuj/hermes
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: New IMeshTextureLoader interface

Post 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.
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
CuteAlien
Admin
Posts: 9628
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: New IMeshTextureLoader interface

Post 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).
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
Post Reply