From 2979a26984402bdc072ba09b5766576b0e8560dc Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sun, 10 Apr 2011 21:15:33 +0000 Subject: [PATCH] * Added support for up to 8 texture coordinates git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7225 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core/com/jme3/scene/VertexBuffer.java | 32 ++++++++++++++++++- .../jme3/scene/plugins/ogre/MeshLoader.java | 31 ++++++++++++------ 2 files changed, 52 insertions(+), 11 deletions(-) diff --git a/engine/src/core/com/jme3/scene/VertexBuffer.java b/engine/src/core/com/jme3/scene/VertexBuffer.java index 13696fa92..d3c280ca9 100644 --- a/engine/src/core/com/jme3/scene/VertexBuffer.java +++ b/engine/src/core/com/jme3/scene/VertexBuffer.java @@ -134,7 +134,37 @@ public class VertexBuffer extends GLObject implements Savable, Cloneable { /** * Texture coordinate #2 */ - TexCoord2; + TexCoord2, + + /** + * Texture coordinate #3 + */ + TexCoord3, + + /** + * Texture coordinate #4 + */ + TexCoord4, + + /** + * Texture coordinate #5 + */ + TexCoord5, + + /** + * Texture coordinate #6 + */ + TexCoord6, + + /** + * Texture coordinate #7 + */ + TexCoord7, + + /** + * Texture coordinate #8 + */ + TexCoord8, } /** diff --git a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java index 6ec6791f2..1ac1064bb 100644 --- a/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java +++ b/engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java @@ -81,8 +81,22 @@ import static com.jme3.util.xml.SAXUtil.*; public class MeshLoader extends DefaultHandler implements AssetLoader { private static final Logger logger = Logger.getLogger(MeshLoader.class.getName()); + public static boolean AUTO_INTERLEAVE = true; public static boolean HARDWARE_SKINNING = false; + + private static final Type[] TEXCOORD_TYPES = + new Type[]{ + Type.TexCoord, + Type.TexCoord2, + Type.TexCoord3, + Type.TexCoord4, + Type.TexCoord5, + Type.TexCoord6, + Type.TexCoord7, + Type.TexCoord8, + }; + private String meshName; private String folderName; private AssetManager assetManager; @@ -397,14 +411,11 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { throw new SAXException("Texture coord dimensions must be 1 <= dims <= 4"); } - if (i >= 2) { - throw new SAXException("More than 2 texture coordinates not supported"); - } - - if (i == 0) { - vb = new VertexBuffer(Type.TexCoord); + if (i <= 7) { + vb = new VertexBuffer( TEXCOORD_TYPES[i] ); } else { - vb = new VertexBuffer(Type.TexCoord2); + // more than 8 texture coordinates are not supported by ogre. + throw new SAXException("More than 8 texture coordinates not supported"); } fb = BufferUtils.createFloatBuffer(vertCount * dims); vb.setupData(Usage.Static, dims, Format.Float, fb); @@ -439,10 +450,10 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { } private void pushTexCoord(Attributes attribs) throws SAXException { - if (texCoordIdx >= 2) { - return; // TODO: More than 2 texcoords + if (texCoordIdx >= 8) { + return; // More than 8 not supported by ogre. } - Type type = texCoordIdx == 0 ? Type.TexCoord : Type.TexCoord2; + Type type = TEXCOORD_TYPES[texCoordIdx]; VertexBuffer tcvb = mesh.getBuffer(type); FloatBuffer buf = (FloatBuffer) tcvb.getData();