TextureLoader2

It would be nice if I could load textures from arbitary input stream without having to faff around with adding TextureStreamLocators, create - add, remove.

If I do have to mess about with these locators things it would be handy if the interface for locating a texture allowed me to throw an exception to indicate that it wasn’t possible to locate the texture (as of now I’ve just thrown a runtime exception since missing resources normally mean you’ve screwed something up pre-production).

Kev

That should be really, really easy to do. Just hack TextureLoader2 to add a method load(InputStream is) and look at the code to just copy/paste the interesting part (when an InputStream is created).

Do you have CVS write access ? William Denniss could give you that it’d be really easier for you if you intend to contribute regularly to Xith3D.

yes, but don’t duplicate code. Move the code block from

        if(inSize > 0 && inData != null) {
            for(int i=0 ; i<textureStreamLoaders.size() && tex==null ; ++i) {

to

        }
        
        if(tex == null) {
            tex = defectTexture;
        }

to it’s own function and call that from the original place.

NO. Don’t throw any exceptions if they are not an exception (and an Invalid format or texture not found is NOT an exception) - just return null.
Exceptions in this place would be just too slow.

But in which situation do you have an InputStream but don’t know the format (or pixels) of it ? Normaly textures are referenced by a name - and even in the case of inline Collada images a temporary Map<String, InputStream> based TextureStreamLocator would also do the lookup work for you :slight_smile:

Matthias