From 9a74373da32b6d666de983fd47f67611ec4dc2c4 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Thu, 9 Jun 2011 05:55:50 +0000 Subject: [PATCH] Support for BGR8 and RGBA8 texture formats added (credits to madlion for finding that :) ). git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7562 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../blender/helpers/v249/TextureHelper.java | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java index e2745de6b..080e6782d 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/helpers/v249/TextureHelper.java @@ -1086,6 +1086,38 @@ public class TextureHelper extends AbstractBlenderHelper { newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f)); newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f)); + } else if (format == Format.RGBA8) { + pixelValue = data.get(); + texPixel[1] = pixelValue >= 0 ? 1.0f - pixelValue / 255.0f : (~pixelValue + 1) / 255.0f; + if(neg) { + texPixel[1] = 1.0f - texPixel[1]; + } + pixelValue = data.get(); + texPixel[2] = pixelValue >= 0 ? 1.0f - pixelValue / 255.0f : (~pixelValue + 1) / 255.0f; + if(neg) { + texPixel[2] = 1.0f - texPixel[2]; + } + data.get(); // ignore alpha + this.blendPixel(resultPixel, materialColor, texPixel, 1.0f, affectFactor, blendType, dataRepository); + newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f)); + newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f)); + newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f)); + } else if (format == Format.BGR8) { + texPixel[2] = texPixel[0]; + pixelValue = data.get(); + texPixel[1] = pixelValue >= 0 ? 1.0f - pixelValue / 255.0f : (~pixelValue + 1) / 255.0f; + if(neg) { + texPixel[1] = 1.0f - texPixel[1]; + } + pixelValue = data.get(); + texPixel[0] = pixelValue >= 0 ? 1.0f - pixelValue / 255.0f : (~pixelValue + 1) / 255.0f; + if(neg) { + texPixel[0] = 1.0f - texPixel[0]; + } + this.blendPixel(resultPixel, materialColor, texPixel, 1.0f, affectFactor, blendType, dataRepository); + newData.put(dataIndex++, (byte) (resultPixel[0] * 255.0f)); + newData.put(dataIndex++, (byte) (resultPixel[1] * 255.0f)); + newData.put(dataIndex++, (byte) (resultPixel[2] * 255.0f)); } else if (format == Format.Luminance8) { this.blendPixel(resultPixel, materialColor, color, texPixel[0], affectFactor, blendType, dataRepository); newData.put((byte) (resultPixel[0] * 255.0f));