import com.jme3.util.BufferUtils;
import com.jme3.util.TempVars;
import java.io.IOException;
+import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
import org.lwjgl.opengl.GL11;
VertexBuffer skintb;
Skin skinArray[];
SkeletonControl skeletonControl;
-
+ HashMap<String, Texture> textureMap = new HashMap<String, Texture>();
public PMDLoaderGLSLSkinning2() {
}
public PMDLoaderGLSLSkinning2(AssetManager assetManager, PMDModel model) {
// go.add(mesh);
mesh.setInterleaved();
}
-// go.optimize();
+// go.optimize3();
createSkinCommonVertData();
for (PMDMaterial pmdMaterial : meshConverter.getSkinMeshData().getIndexMap().keySet()) {
PMDSkinMesh mesh = createSkinMesh(pmdMaterial);
}
wb.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Float, wfb);
ib.setupData(VertexBuffer.Usage.Static, 1, VertexBuffer.Format.UnsignedShort, isb);
- bib.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Short, bisb);
+ bib.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.UnsignedShort, bisb);
mesh.setBuffer(vb);
mesh.setBuffer(nb);
mat = createMaterial(m, true);
geom.setMaterial(mat);
geom.setGlslSkinningMaterial(mat);
- mat.setInt("NumBones", mesh.boneIndexArray.length);
+// mat.setInt("NumBones", mesh.boneIndexArray.length);
mat = createMaterial(m, false);
geom.setNoSkinningMaterial(mat);
}
}
if (skinning) {
-// mat.setInt("NumBones", meshConverter.getMaxBoneSize());
+ mat.setInt("NumBones", meshConverter.getMaxBoneSize());
}
float alpha = m.getMaterial().getFaceColor().getAlpha();
if (alpha > 0.99f) {
String fileName = st.nextToken();
// System.out.println("fileName = " + fileName);
String s = fileName.substring(fileName.indexOf('.') + 1);
- Texture texture = assetManager.loadTexture(folderName + fileName /*
+ Texture texture = loadTexture(folderName + fileName /*
* m.getTextureFileName()
*/);
s = s.toLowerCase();
if (toonIndex >= 0) {
String extToonName = model.getToonTextureList().getToonFileName()[toonIndex];
try {
- toonTexture = assetManager.loadTexture(folderName + extToonName);
+ toonTexture = loadTexture(folderName + extToonName);
} catch (Exception ex) {
String toonname = null;
switch (toonIndex) {
break;
}
if (toonname != null) {
- toonTexture = assetManager.loadTexture("toon/" + toonname);
+ toonTexture = loadTexture("toon/" + toonname);
}
}
}
public String getFolderName() {
return folderName;
}
-
+ Texture loadTexture(String name) {
+ Texture tex = textureMap.get(name);
+ if (tex == null) {
+ tex = assetManager.loadTexture(name);
+ textureMap.put(name, tex);
+ }
+ return tex;
+ }
}