ColladaImporter and ResourceLocators

Hiya



I love the new ResourceLocator system, it really makes it easy to juggle around with resources as you see fit. However, there seems to be a slight issue in the way the ColladaImporter handles the abstract resource locations from the Collada files - it always strips the paths down to the filename only, making it difficult to distinguish between for instance "textures/goblin/male/head.png" and "textures/animals/dog/head.png" since they are both requested from the locators as "head.png".



Is it somehow possible to override this behaviour? Is it even intended? Is it a bug?



Attached below is the relevant code from ColladaImporter:



/**
     * processImage takes an image type and places the necessary information in
     * the resource library.
     *
     * @param image
     *            the image to process.
     * @throws Exception
     *             thrown if there is a problem with the imagetype.
     */
    private void processImage(imageType image) throws Exception {
        if (image.hasdata()) {
            if (!squelch) {
                logger.warning("Raw data images not supported.");
            }
        }
        if (image.hasinit_from()) {
            put(image.getid().toString(), getFileName(image.getinit_from()
                    .toString()));
        }
    }

    /**
     * getFileName takes a String object stripping off any directory information
     * returning only the substring that follows the last '/' or ''.
     *
     * @param fullName
     *            the fileName to strip.
     * @return the stripped file name.
     */
    private String getFileName(String fullName) {
        int a = fullName.lastIndexOf('/') + 1;
        int b = fullName.lastIndexOf('\') + 1;
        int index = Math.max(a, b);
        return fullName.substring(index);
    }

Hey jbk,

That's unintended behavior now (especially since RLT will strip path incrementally for you.)  I'll fix it.

renanse said:

Hey jbk,
That's unintended behavior now (especially since RLT will strip path incrementally for you.)  I'll fix it.

Thanks a lot!