formatting of MeshLoader before an upcomming change

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10538 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
rem..om 12 years ago
parent eb5525e581
commit 1e2dc1486b
  1. 39
      engine/src/ogre/com/jme3/scene/plugins/ogre/MeshLoader.java

@ -148,17 +148,17 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
public void endDocument() { public void endDocument() {
} }
private void pushIndex(int index){ private void pushIndex(int index) {
if (ib != null){ if (ib != null) {
ib.put(index); ib.put(index);
}else{ } else {
sb.put((short)index); sb.put((short) index);
} }
} }
private void pushFace(String v1, String v2, String v3) throws SAXException { private void pushFace(String v1, String v2, String v3) throws SAXException {
// TODO: fan/strip support // TODO: fan/strip support
switch (mesh.getMode()){ switch (mesh.getMode()) {
case Triangles: case Triangles:
pushIndex(parseInt(v1)); pushIndex(parseInt(v1));
pushIndex(parseInt(v2)); pushIndex(parseInt(v2));
@ -178,12 +178,11 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
// Old code for buffer sharer // Old code for buffer sharer
//return geom.getUserData(UserData.JME_SHAREDMESH) != null; //return geom.getUserData(UserData.JME_SHAREDMESH) != null;
// } // }
private void startFaces(String count) throws SAXException { private void startFaces(String count) throws SAXException {
int numFaces = parseInt(count); int numFaces = parseInt(count);
int indicesPerFace = 0; int indicesPerFace = 0;
switch (mesh.getMode()){ switch (mesh.getMode()) {
case Triangles: case Triangles:
indicesPerFace = 3; indicesPerFace = 3;
break; break;
@ -218,9 +217,9 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
// load as native jme3 material instance // load as native jme3 material instance
try { try {
mat = assetManager.loadMaterial(matName); mat = assetManager.loadMaterial(matName);
} catch (AssetNotFoundException ex){ } catch (AssetNotFoundException ex) {
// Warning will be raised (see below) // Warning will be raised (see below)
if (!ex.getMessage().equals(matName)){ if (!ex.getMessage().equals(matName)) {
throw ex; throw ex;
} }
} }
@ -268,7 +267,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
// for (Entry<VertexBuffer> entry : sharedBufs) { // for (Entry<VertexBuffer> entry : sharedBufs) {
// mesh.setBuffer(entry.getValue()); // mesh.setBuffer(entry.getValue());
// } // }
}else{ } else {
usesSharedMesh.add(false); usesSharedMesh.add(false);
} }
@ -302,15 +301,15 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
} }
/** /**
* Normalizes weights if needed and finds largest amount of weights used * Normalizes weights if needed and finds largest amount of weights used for
* for all vertices in the buffer. * all vertices in the buffer.
*/ */
private void endBoneAssigns() { private void endBoneAssigns() {
// if (mesh != sharedMesh && isUsingSharedVerts(geom)) { // if (mesh != sharedMesh && isUsingSharedVerts(geom)) {
// return; // return;
// } // }
if (!actuallyHasWeights){ if (!actuallyHasWeights) {
// No weights were actually written (the tag didn't have any entries) // No weights were actually written (the tag didn't have any entries)
// remove those buffers // remove those buffers
mesh.clearBuffer(Type.BoneIndex); mesh.clearBuffer(Type.BoneIndex);
@ -521,12 +520,12 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
VertexBuffer originalIndexBuffer = mesh.getBuffer(Type.Index); VertexBuffer originalIndexBuffer = mesh.getBuffer(Type.Index);
vb = new VertexBuffer(VertexBuffer.Type.Index); vb = new VertexBuffer(VertexBuffer.Type.Index);
if (originalIndexBuffer.getFormat() == Format.UnsignedInt){ if (originalIndexBuffer.getFormat() == Format.UnsignedInt) {
// LOD buffer should also be integer // LOD buffer should also be integer
ib = BufferUtils.createIntBuffer(faceCount * 3); ib = BufferUtils.createIntBuffer(faceCount * 3);
sb = null; sb = null;
vb.setupData(Usage.Static, 3, Format.UnsignedInt, ib); vb.setupData(Usage.Static, 3, Format.UnsignedInt, ib);
}else{ } else {
sb = BufferUtils.createShortBuffer(faceCount * 3); sb = BufferUtils.createShortBuffer(faceCount * 3);
ib = null; ib = null;
vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb); vb.setupData(Usage.Static, 3, Format.UnsignedShort, sb);
@ -593,7 +592,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
AssetKey assetKey = new AssetKey(folderName + name + ".xml"); AssetKey assetKey = new AssetKey(folderName + name + ".xml");
try { try {
animData = (AnimData) assetManager.loadAsset(assetKey); animData = (AnimData) assetManager.loadAsset(assetKey);
} catch (AssetNotFoundException ex){ } catch (AssetNotFoundException ex) {
logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{assetKey, key}); logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{assetKey, key});
animData = null; animData = null;
} }
@ -853,7 +852,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{materialKey, key}); logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{materialKey, key});
} }
} }
}else{ } else {
// Make sure to reset it to null so that previous state // Make sure to reset it to null so that previous state
// doesn't leak onto this one // doesn't leak onto this one
materialList = null; materialList = null;
@ -862,12 +861,12 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
// If for some reason material list could not be found through // If for some reason material list could not be found through
// OgreMeshKey, or if regular ModelKey specified, load using // OgreMeshKey, or if regular ModelKey specified, load using
// default method. // default method.
if (materialList == null){ if (materialList == null) {
OgreMaterialKey materialKey = new OgreMaterialKey(folderName + meshName + ".material"); OgreMaterialKey materialKey = new OgreMaterialKey(folderName + meshName + ".material");
try { try {
materialList = (MaterialList) assetManager.loadAsset(materialKey); materialList = (MaterialList) assetManager.loadAsset(materialKey);
} catch (AssetNotFoundException e) { } catch (AssetNotFoundException e) {
logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{ materialKey, key }); logger.log(Level.WARNING, "Cannot locate {0} for model {1}", new Object[]{materialKey, key});
} }
} }
@ -888,7 +887,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader {
r = new InputStreamReader(info.openStream()); r = new InputStreamReader(info.openStream());
xr.parse(new InputSource(r)); xr.parse(new InputSource(r));
} finally { } finally {
if (r != null){ if (r != null) {
r.close(); r.close();
} }
} }

Loading…
Cancel
Save