|
|
|
@ -88,10 +88,8 @@ 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, |
|
|
|
@ -101,14 +99,11 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
Type.TexCoord5, |
|
|
|
|
Type.TexCoord6, |
|
|
|
|
Type.TexCoord7, |
|
|
|
|
Type.TexCoord8, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
Type.TexCoord8,}; |
|
|
|
|
private String meshName; |
|
|
|
|
private String folderName; |
|
|
|
|
private AssetManager assetManager; |
|
|
|
|
private MaterialList materialList; |
|
|
|
|
|
|
|
|
|
// Data per submesh/sharedgeom
|
|
|
|
|
private ShortBuffer sb; |
|
|
|
|
private IntBuffer ib; |
|
|
|
@ -121,13 +116,11 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
private int vertCount; |
|
|
|
|
private boolean usesSharedVerts; |
|
|
|
|
private boolean usesBigIndices; |
|
|
|
|
|
|
|
|
|
// Global data
|
|
|
|
|
private Mesh sharedMesh; |
|
|
|
|
private int meshIndex = 0; |
|
|
|
|
private int texCoordIndex = 0; |
|
|
|
|
private String ignoreUntilEnd = null; |
|
|
|
|
|
|
|
|
|
private List<Geometry> geoms = new ArrayList<Geometry>(); |
|
|
|
|
private IntMap<List<VertexBuffer>> lodLevels = new IntMap<List<VertexBuffer>>(); |
|
|
|
|
private AnimData animData; |
|
|
|
@ -178,7 +171,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean isUsingSharedVerts(Geometry geom){ |
|
|
|
|
private boolean isUsingSharedVerts(Geometry geom) { |
|
|
|
|
return geom.getUserData(UserData.JME_SHAREDMESH) != null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -257,7 +250,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
geom = new Geometry(meshName + "-geom-" + (++meshIndex), mesh); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (usesSharedVerts){ |
|
|
|
|
if (usesSharedVerts) { |
|
|
|
|
// this mesh is shared!
|
|
|
|
|
geom.setUserData(UserData.JME_SHAREDMESH, sharedMesh); |
|
|
|
|
} |
|
|
|
@ -398,7 +391,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (i <= 7) { |
|
|
|
|
vb = new VertexBuffer( TEXCOORD_TYPES[i] ); |
|
|
|
|
vb = new VertexBuffer(TEXCOORD_TYPES[i]); |
|
|
|
|
} else { |
|
|
|
|
// more than 8 texture coordinates are not supported by ogre.
|
|
|
|
|
throw new SAXException("More than 8 texture coordinates not supported"); |
|
|
|
@ -534,7 +527,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (v != 0){ |
|
|
|
|
if (v != 0) { |
|
|
|
|
logger.log(Level.WARNING, "Vertex {0} has more than 4 weights per vertex! Ignoring..", vert); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -712,7 +705,7 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
// generate bind pose for mesh
|
|
|
|
|
// ONLY if not using shared geometry
|
|
|
|
|
// This includes the shared geoemtry itself actually
|
|
|
|
|
if (sharedMesh != null){ |
|
|
|
|
if (sharedMesh != null) { |
|
|
|
|
sharedMesh.generateBindPose(!HARDWARE_SKINNING); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -788,6 +781,10 @@ public class MeshLoader extends DefaultHandler implements AssetLoader { |
|
|
|
|
if (key instanceof OgreMeshKey) { |
|
|
|
|
meshKey = (OgreMeshKey) key; |
|
|
|
|
materialList = meshKey.getMaterialList(); |
|
|
|
|
String materialName = meshKey.getMaterialName(); |
|
|
|
|
if (materialList == null && materialName != null) { |
|
|
|
|
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + materialName + ".material")); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
try { |
|
|
|
|
materialList = (MaterialList) assetManager.loadAsset(new OgreMaterialKey(folderName + meshName + ".material")); |
|
|
|
|