* Added support for up to 8 texture coordinates

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7225 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent 53da7c4de4
commit 2979a26984
  1. 32
      engine/src/core/com/jme3/scene/VertexBuffer.java
  2. 31
      engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java

@ -134,7 +134,37 @@ public class VertexBuffer extends GLObject implements Savable, Cloneable {
/** /**
* Texture coordinate #2 * 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,
} }
/** /**

@ -81,8 +81,22 @@ import static com.jme3.util.xml.SAXUtil.*;
public class MeshLoader extends DefaultHandler implements AssetLoader { public class MeshLoader extends DefaultHandler implements AssetLoader {
private static final Logger logger = Logger.getLogger(MeshLoader.class.getName()); private static final Logger logger = Logger.getLogger(MeshLoader.class.getName());
public static boolean AUTO_INTERLEAVE = true; public static boolean AUTO_INTERLEAVE = true;
public static boolean HARDWARE_SKINNING = false; 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 meshName;
private String folderName; private String folderName;
private AssetManager assetManager; 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"); throw new SAXException("Texture coord dimensions must be 1 <= dims <= 4");
} }
if (i >= 2) { if (i <= 7) {
throw new SAXException("More than 2 texture coordinates not supported"); vb = new VertexBuffer( TEXCOORD_TYPES[i] );
}
if (i == 0) {
vb = new VertexBuffer(Type.TexCoord);
} else { } 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); fb = BufferUtils.createFloatBuffer(vertCount * dims);
vb.setupData(Usage.Static, dims, Format.Float, fb); 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 { private void pushTexCoord(Attributes attribs) throws SAXException {
if (texCoordIdx >= 2) { if (texCoordIdx >= 8) {
return; // TODO: More than 2 texcoords 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); VertexBuffer tcvb = mesh.getBuffer(type);
FloatBuffer buf = (FloatBuffer) tcvb.getData(); FloatBuffer buf = (FloatBuffer) tcvb.getData();

Loading…
Cancel
Save