• R/O
  • SSH

MMDLoaderJME: 提交

Java版MikuMikuDanceライブラリ


Commit MetaInfo

修訂2a4df1024fb31a765b6ee1ce30a05d1b0421940f (tree)
時間2012-05-28 07:40:26
作者Kazuhiko Kobayashi <chototsu_ <moushinp@yaho...>
CommiterKazuhiko Kobayashi <chototsu_

Log Message

ignore texture error

Change Summary

差異

diff -r 454815cb9c2d -r 2a4df1024fb3 nbproject/project.properties
--- a/nbproject/project.properties Tue Mar 27 19:30:27 2012 +0900
+++ b/nbproject/project.properties Mon May 28 07:40:26 2012 +0900
@@ -26,10 +26,12 @@
2626 dist.javadoc.dir=${dist.dir}/javadoc
2727 endorsed.classpath=
2828 excludes=
29+file.reference.jME3-bullet.jar=../MikuMikuStudio/mikumikustudio/engine/dist/opt/native-bullet/lib/jME3-bullet.jar
2930 file.reference.jMonkeyEngine3.jar=/Users/kobayasi/NetBeansProjects/MMD/MikuMikuStudio/mikumikustudio/engine/dist/jMonkeyEngine3.jar
3031 includes=**
3132 jar.compress=false
3233 javac.classpath=\
34+ ${file.reference.jME3-bullet.jar}:\
3335 ${file.reference.jMonkeyEngine3.jar}:\
3436 ${libs.jme3-libraries.classpath}:\
3537 ${libs.jme3.classpath}
diff -r 454815cb9c2d -r 2a4df1024fb3 src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java
--- a/src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java Tue Mar 27 19:30:27 2012 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java Mon May 28 07:40:26 2012 +0900
@@ -65,7 +65,10 @@
6565 import java.util.ArrayList;
6666 import java.util.HashMap;
6767 import java.util.List;
68+import java.util.Map;
6869 import java.util.StringTokenizer;
70+import java.util.logging.Level;
71+import java.util.logging.Logger;
6972 import org.lwjgl.opengl.GL11;
7073 import projectkyoto.mmd.file.*;
7174 import projectkyoto.mmd.file.pmn.PMNData;
@@ -97,6 +100,7 @@
97100 Skin skinArray[];
98101 SkeletonControl skeletonControl;
99102 HashMap<String, Texture> textureMap = new HashMap<String, Texture>();
103+ public static final Logger logger = Logger.getLogger(PMDLoaderGLSLSkinning2.class.getName());
100104 public PMDLoaderGLSLSkinning2() {
101105 }
102106 public PMDLoaderGLSLSkinning2(AssetManager assetManager, PMDModel model) {
@@ -145,6 +149,7 @@
145149 node.pmdGeometryArray = new PMDGeometry[meshConverter.getMeshDataList().size()];
146150 int pmdGeometryIndex = 0;
147151 // GeometryOptimizer go = GeometryOptimizer.createNewInstance();
152+ Map<PMDMaterial, List<PMDGeometry>> childMap = new HashMap<PMDMaterial, List<PMDGeometry>>();
148153 for(int i=0;i<meshConverter.getMeshDataList().size();i++) {
149154 MeshData md = meshConverter.getMeshDataList().get(i);
150155 PMDMesh mesh = createMesh_old(md);
@@ -152,7 +157,13 @@
152157 geom.setMesh(mesh);
153158 PMDMaterial pmdMaterial = md.getMaterial();
154159 setupMaterial(pmdMaterial, geom);
155- node.attachChild(geom);
160+// node.attachChild(geom);
161+ List<PMDGeometry> geomList = childMap.get(pmdMaterial);
162+ if (geomList == null) {
163+ geomList = new ArrayList<PMDGeometry>();
164+ childMap.put(pmdMaterial, geomList);
165+ }
166+ geomList.add(geom);
156167 meshList.add(mesh);
157168 node.pmdGeometryArray[pmdGeometryIndex++] = geom;
158169 meshConverter.getMeshDataList().set(i, null);
@@ -174,9 +185,23 @@
174185 geom.setMesh(mesh);
175186 setupMaterial(pmdMaterial, geom);
176187 geom.getMaterial().setInt("NumBones", numBones);
177- node.attachChild(geom);
188+// node.attachChild(geom);
189+ List<PMDGeometry> geomList = childMap.get(pmdMaterial);
190+ if (geomList == null) {
191+ geomList = new ArrayList<PMDGeometry>();
192+ childMap.put(pmdMaterial, geomList);
193+ }
194+ geomList.add(geom);
178195 skinMeshList.add(mesh);
179196 }
197+ for(PMDMaterial pmdMaterial : model.getMaterial()) {
198+ List<PMDGeometry> list = childMap.get(pmdMaterial);
199+ if (list != null) {
200+ for(PMDGeometry geom : list) {
201+ node.attachChild(geom);
202+ }
203+ }
204+ }
180205 // System.out.println("child size = "+node.getChildren().size()+" "+meshList.size()+" "+skinMeshList.size());
181206 createSkinArray();
182207 createSkeleton();
@@ -475,6 +500,9 @@
475500 Texture texture = loadTexture(folderName + fileName /*
476501 * m.getTextureFileName()
477502 */);
503+ if (texture == null) {
504+ continue;
505+ }
478506 s = s.toLowerCase();
479507 if (s.equals("spa")) {
480508 // texture.setWrap(Texture.WrapMode.Repeat);
@@ -496,6 +524,9 @@
496524 String extToonName = model.getToonTextureList().getToonFileName()[toonIndex];
497525 try {
498526 toonTexture = loadTexture(folderName + extToonName);
527+ if (toonTexture == null) {
528+ throw new Exception();
529+ }
499530 } catch (Exception ex) {
500531 String toonname = null;
501532 switch (toonIndex) {
@@ -695,7 +726,7 @@
695726 folderName = ai.getKey().getFolder();
696727 meshConverter = new MeshConverter(model);
697728 meshConverter.convertMesh();
698- PMNData pmdData = meshConverter.createPMNData();
729+// PMNData pmdData = meshConverter.createPMNData();
699730 // model.setVertexList(null);
700731 model.setFaceVertIndex(null);
701732 PMDNode pmdNode = createNode(ai.getKey().getName());
@@ -722,11 +753,16 @@
722753 return folderName;
723754 }
724755 Texture loadTexture(String name) {
756+ try {
725757 Texture tex = textureMap.get(name);
726758 if (tex == null) {
727759 tex = assetManager.loadTexture(name);
728760 textureMap.put(name, tex);
729761 }
730762 return tex;
763+ } catch(Exception ex) {
764+ logger.log(Level.WARNING,"Txture "+name+" not found.",ex);
765+ return null;
766+ }
731767 }
732768 }
diff -r 454815cb9c2d -r 2a4df1024fb3 src/projectkyoto/jme3/mmd/nativebullet/PMDPhysicsWorld.java
--- a/src/projectkyoto/jme3/mmd/nativebullet/PMDPhysicsWorld.java Tue Mar 27 19:30:27 2012 +0900
+++ b/src/projectkyoto/jme3/mmd/nativebullet/PMDPhysicsWorld.java Mon May 28 07:40:26 2012 +0900
@@ -503,7 +503,7 @@
503503 // applyResultToBone();
504504 // }
505505 // synchronized(lockObject) {
506- physicsSpace.update(timeStep, 5);
506+ physicsSpace.update(timeStep, 100);
507507 // }
508508 // applyResultToBone();
509509 }
diff -r 454815cb9c2d -r 2a4df1024fb3 src/projectkyoto/jme3/mmd/vmd/VMDControl.java
--- a/src/projectkyoto/jme3/mmd/vmd/VMDControl.java Tue Mar 27 19:30:27 2012 +0900
+++ b/src/projectkyoto/jme3/mmd/vmd/VMDControl.java Mon May 28 07:40:26 2012 +0900
@@ -149,6 +149,7 @@
149149 }
150150 }
151151 initMotionMap();
152+ physicsControl.getWorld().setAccuracy(accuracy);
152153 }
153154
154155 private void initMotionMap() {
@@ -274,17 +275,16 @@
274275 if (isPause()) {
275276 return;
276277 }
277- if (tpf > 1) {
278- currentTime += tpf;
279- currentFrameNo = (int)(currentTime * 30f);
280- setFrameNo(currentFrameNo);
281- } else {
278+ float time = currentTime + tpf;
279+ if (accuracy > 0 && tpf < 1f) {
282280 physicsControl.update(tpf);
283281 physicsControl.getWorld().applyResultToBone();
284- resetSkins();
285- calcSkins();
286282 physicsControl.getWorld().getPhysicsSpace().distributeEvents();
283+ } else {
284+ controlUpdate2(tpf);
287285 }
286+ resetSkins();
287+ calcSkins();
288288 }
289289 protected void resetBonePos() {
290290 for(int i=0;i<pmdNode.getSkeleton().getBoneCount();i++) {
Show on old repository browser