* Prevent exception when loading OBJ file without normals or texcoords

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9228 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Sha..om 13 years ago
parent 92b97d38d8
commit b99e5a9bfb
  1. 6
      engine/src/core-plugins/com/jme3/scene/plugins/OBJLoader.java

@ -454,9 +454,11 @@ public final class OBJLoader implements AssetLoader {
if (hasNormals){ if (hasNormals){
normBuf = BufferUtils.createFloatBuffer(vertIndexMap.size() * 3); normBuf = BufferUtils.createFloatBuffer(vertIndexMap.size() * 3);
m.setBuffer(VertexBuffer.Type.Normal, 3, normBuf);
} }
if (hasTexCoord){ if (hasTexCoord){
tcBuf = BufferUtils.createFloatBuffer(vertIndexMap.size() * 2); tcBuf = BufferUtils.createFloatBuffer(vertIndexMap.size() * 2);
m.setBuffer(VertexBuffer.Type.TexCoord, 2, tcBuf);
} }
IndexBuffer indexBuf = null; IndexBuffer indexBuf = null;
@ -517,9 +519,7 @@ public final class OBJLoader implements AssetLoader {
} }
m.setBuffer(VertexBuffer.Type.Position, 3, posBuf); m.setBuffer(VertexBuffer.Type.Position, 3, posBuf);
m.setBuffer(VertexBuffer.Type.Normal, 3, normBuf); // index buffer and others were set on creation
m.setBuffer(VertexBuffer.Type.TexCoord, 2, tcBuf);
// index buffer was set on creation
m.setStatic(); m.setStatic();
m.updateBound(); m.updateBound();

Loading…
Cancel
Save