That sounds difficult... so I've implemented a workaround: I parse the .mtl file myself and add the color for each image with the following code:
Then I add the image under the name of the mtl-material to the TextureManager, and I create my own transient .mtl file where each texture has the name of the mtl-material and give that to the Loader.
The result looks the same like in poser.
But I think there is a little bug in Loader.createOBJObject, at the moment it is:
if it were
then I wouldn't need to create a transient .mtl file.
Code Select
BufferedImage result = new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_RGB);
int cr = color.getRed();
int cg = color.getGreen();
int cb = color.getBlue();
for (int y = 0; y < image.getHeight(); ++y) {
for (int x = 0; x < image.getWidth(); ++x) {
int v = image.getRGB(x, y);
int r = (v >> 16) & 0xFF;
int g = (v >> 8) & 0xFF;
int b = (v >> 0) & 0xFF;
r = r * cr / 255;
g = g * cg / 255;
b = b * cb / 255;
v = ((255 & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | ((b & 0xFF) << 0);
result.setRGB(x, y, v);
}
}
Then I add the image under the name of the mtl-material to the TextureManager, and I create my own transient .mtl file where each texture has the name of the mtl-material and give that to the Loader.
The result looks the same like in poser.
But I think there is a little bug in Loader.createOBJObject, at the moment it is:
Code Select
tid = tm.getTextureID("mtlName");
if it were
Code Select
tid = tm.getTextureID(mtlName);
then I wouldn't need to create a transient .mtl file.