|
|
@ -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(); |
|
|
|