From b8618eba26f57789398c9a75668f7bb360613039 Mon Sep 17 00:00:00 2001 From: "Kae..pl" Date: Fri, 9 Sep 2011 17:19:18 +0000 Subject: [PATCH] Support for generating UV coordinates for 3D textures if they are not manually created. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@8231 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../textures/UVCoordinatesGenerator.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/engine/src/blender/com/jme3/scene/plugins/blender/textures/UVCoordinatesGenerator.java b/engine/src/blender/com/jme3/scene/plugins/blender/textures/UVCoordinatesGenerator.java index b3743d269..d2963dab3 100644 --- a/engine/src/blender/com/jme3/scene/plugins/blender/textures/UVCoordinatesGenerator.java +++ b/engine/src/blender/com/jme3/scene/plugins/blender/textures/UVCoordinatesGenerator.java @@ -108,18 +108,17 @@ public class UVCoordinatesGenerator { inputData = BufferUtils.getFloatArray(mesh.getFloatBuffer(VertexBuffer.Type.Position)); break; case TEXCO_UV: - if (textureDimension == 2) { - FloatBuffer uvCoordinatesBuffer = BufferUtils.createFloatBuffer(mesh.getVertexCount() << 1); - Vector2f[] data = new Vector2f[] { new Vector2f(0, 1), new Vector2f(0, 0), new Vector2f(1, 0) }; - for (int i = 0; i < mesh.getVertexCount(); ++i) { - Vector2f uv = data[i % 3]; - uvCoordinatesBuffer.put(uv.x); - uvCoordinatesBuffer.put(uv.y); + FloatBuffer uvCoordinatesBuffer = BufferUtils.createFloatBuffer(mesh.getVertexCount() * textureDimension); + Vector2f[] data = new Vector2f[] { new Vector2f(0, 1), new Vector2f(0, 0), new Vector2f(1, 0) }; + for (int i = 0; i < mesh.getVertexCount(); ++i) { + Vector2f uv = data[i % 3]; + uvCoordinatesBuffer.put(uv.x); + uvCoordinatesBuffer.put(uv.y); + if(textureDimension == 3) { + uvCoordinatesBuffer.put(0); } - result.setupData(Usage.Static, textureDimension, Format.Float, uvCoordinatesBuffer); - } else { - } + result.setupData(Usage.Static, textureDimension, Format.Float, uvCoordinatesBuffer); break; case TEXCO_NORM: inputData = BufferUtils.getFloatArray(mesh.getFloatBuffer(VertexBuffer.Type.Normal));