OSDN Git Service

Fix texture bug.(Tram girl support)
authorKazuhiko Kobayashi <chototsu_moushinp@yahoo.co.jp>
Thu, 16 May 2013 14:11:17 +0000 (23:11 +0900)
committerKazuhiko Kobayashi <chototsu_moushinp@yahoo.co.jp>
Thu, 16 May 2013 14:11:17 +0000 (23:11 +0900)
src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java
src/projectkyoto/jme3/mmd/PMDMesh.java
src/projectkyoto/jme3/mmd/PMDSkinMesh.java
src/projectkyoto/jme3/mmd/vmd/VMDControl.java
src/projectkyoto/mmd/file/util2/MeshData.java
src/projectkyoto/mmd/file/util2/SkinMeshData.java

index 7e2bf12..57f956b 100755 (executable)
@@ -97,6 +97,7 @@ public class PMDLoaderGLSLSkinning2 implements AssetLoader{
     SkeletonControl skeletonControl;
     HashMap<String, Texture> textureMap = new HashMap<String, Texture>();
     public static final Logger logger = Logger.getLogger(PMDLoaderGLSLSkinning2.class.getName());
+    public static boolean interleaveEnabled = true;
     public PMDLoaderGLSLSkinning2() {
     }
     public PMDLoaderGLSLSkinning2(AssetManager assetManager, PMDModel model) {
@@ -164,7 +165,9 @@ public class PMDLoaderGLSLSkinning2 implements AssetLoader{
             node.pmdGeometryArray[pmdGeometryIndex++] = geom;
             meshConverter.getMeshDataList().set(i, null);
 //            go.add(mesh);
-            mesh.setInterleaved();    
+            if (interleaveEnabled) {
+                mesh.setInterleaved();    
+            }
         }
 //        go.optimize3();
         createSkinCommonVertData();
@@ -425,15 +428,15 @@ public class PMDLoaderGLSLSkinning2 implements AssetLoader{
                 }
                 s = s.toLowerCase();
                 if (s.equals("spa")) {
-//                    texture.setWrap(Texture.WrapMode.Repeat);
+                    texture.setWrap(Texture.WrapMode.Repeat);
                     texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
                     mat.setTexture("SphereMap_A", texture);
                 } else if (s.equals("sph")) {
-//                    texture.setWrap(Texture.WrapMode.Repeat);
+                    texture.setWrap(Texture.WrapMode.Repeat);
                     texture.setMinFilter(Texture.MinFilter.BilinearNoMipMaps);
                     mat.setTexture("SphereMap_H", texture);
                 } else {
-//                    texture.setWrap(Texture.WrapMode.Repeat);
+                    texture.setWrap(Texture.WrapMode.Repeat);
                     mat.setTexture("DiffuseMap", texture);
                 }
             }
index a0c9f19..b5c48c3 100755 (executable)
@@ -30,6 +30,7 @@
 package projectkyoto.jme3.mmd;
 
 import com.jme3.bounding.BoundingBox;
+import com.jme3.bounding.BoundingSphere;
 import com.jme3.bounding.BoundingVolume;
 import com.jme3.export.InputCapsule;
 import com.jme3.export.JmeExporter;
@@ -78,10 +79,15 @@ public class PMDMesh extends Mesh {
     public void setBoneMatrixArray(Matrix4f[] boneMatrixArray) {
         this.boneMatrixArray = boneMatrixArray;
     }
-    BoundingVolume bound = new BoundingBox(Vector3f.ZERO, 20, 20, 20);
+//    BoundingVolume bound = new BoundingBox(Vector3f.ZERO, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
+    BoundingVolume bound = new BoundingBox(Vector3f.ZERO, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
 
     @Override
     public BoundingVolume getBound() {
+        BoundingBox bb = (BoundingBox)super.getBound();
+        BoundingBox bb2 = new BoundingBox(bb.getCenter(), bb.getXExtent()*2, bb.getYExtent()*2,
+                bb.getZExtent()*2);
+        BoundingBox bb3 = new BoundingBox(bb.getCenter().ZERO,5,5,5);
         return bound;
     }
 
index b4bf3a1..a96e110 100755 (executable)
@@ -108,11 +108,11 @@ public class PMDSkinMesh extends Mesh {
         this.boneMatrixBuffer = boneMatrixBuffer;
     }
     
-    BoundingVolume bound = new BoundingBox(Vector3f.ZERO, 20, 20, 20);
+    BoundingVolume bound = new BoundingBox(Vector3f.ZERO, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY);
 
     @Override
     public BoundingVolume getBound() {
-        return bound;
+        return bound; //super.getBound();
     }
     @Override
     public synchronized PMDSkinMesh clone() {
index 690ab95..a38b46a 100755 (executable)
@@ -181,7 +181,7 @@ public class VMDControl extends AbstractControl {
                     continue;
                 }
                 motionMap.put(m.getBoneName(), motionList);
-logger.info("boneName = "+m.getBoneName()+" "+motionList.boneIndex+" "+motionList.bone);
+//logger.info("boneName = "+m.getBoneName()+" "+motionList.boneIndex+" "+motionList.bone);
                 PMDBone pmdBone = pmdNode.getPmdModel().getBoneList().getBones()[motionList.boneIndex];
                 if (pmdBone.getBoneType() == 9) {
                     // FOLLOW_ROTATE
@@ -229,7 +229,7 @@ logger.info("boneName = "+m.getBoneName()+" "+motionList.boneIndex+" "+motionLis
 //                System.out.print(" ");
 //            }
         }
-        System.out.println();
+//        System.out.println();
         for (VMDSkin skin : vmdFile.getSkinArray()) {
             SkinList skinList = skinMap.get(skin.getSkinName());
             if (skinList == null) {
@@ -385,9 +385,9 @@ logger.info("boneName = "+m.getBoneName()+" "+motionList.boneIndex+" "+motionLis
         for (int i = pmdNode.getSkeleton().getBoneCount() - 1; i >= 0; i--) {
             int i2 = i; //boneEnabled.length -1 - i;
             if (boneEnabled[i2] == 1) {
-                if (!pmdNode.getSkeleton().getBone(i).getName().equals(pmdNode.getPmdModel().getBoneList().getBones()[i2].getBoneName())) {
-                    System.out.println("ERROR " + pmdNode.getSkeleton().getBone(i).getName() + " " + pmdNode.getPmdModel().getBoneList().getBones()[i2].getBoneName());
-                }
+//                if (!pmdNode.getSkeleton().getBone(i).getName().equals(pmdNode.getPmdModel().getBoneList().getBones()[i2].getBoneName())) {
+//                    System.out.println("ERROR " + pmdNode.getSkeleton().getBone(i).getName() + " " + pmdNode.getPmdModel().getBoneList().getBones()[i2].getBoneName());
+//                }
                 Bone bone = pmdNode.getSkeleton().getBone(i);
                 bone.getLocalRotation().loadIdentity();
             }
@@ -602,7 +602,7 @@ logger.info("boneName = "+m.getBoneName()+" "+motionList.boneIndex+" "+motionLis
 
     public void setFixedPhysics(boolean fixedPhysics) {
         this.fixedPhysics = fixedPhysics;
-        logger.info("fixedPhysics = " + fixedPhysics);
+//        logger.info("fixedPhysics = " + fixedPhysics);
     }
 
     @Override
index c6a2520..c2c49a3 100755 (executable)
@@ -220,11 +220,11 @@ public class MeshData {
 //            bnfb.put(v.getNormal().x).put(v.getNormal().y).put(v.getNormal().z);
             if (textureFlag) {
                 float f1 = v.getUv().getU();
-                float f2 = v.getUv().getV();
+                float f2 = 1f-v.getUv().getV();
 //                tfb.put(v.getUv().getU()).put(1f - v.getUv().getV());
-                f1 = f1 - FastMath.floor(f1);
-                f2 = f2 - FastMath.floor(f2);
-                f2 = 1 - f2;
+//                f1 = f1 - FastMath.floor(f1);
+//                f2 = f2 - FastMath.floor(f2);
+//                f2 = 1 - f2;
                 tfb.put(f1).put(f2);
             }
             float weight = (float) v.getBoneWeight() / 100.0f;
index e603bd3..7f75c1d 100755 (executable)
@@ -224,14 +224,14 @@ public class SkinMeshData implements Serializable {
             skinvfb.put(v.getPos().x).put(v.getPos().y).put(v.getPos().z);
             v.getNormal().normalize();
             skinnfb.put(v.getNormal().x).put(v.getNormal().y).put(v.getNormal().z);
-            float f1 = v.getUv().getU();
-            float f2 = v.getUv().getV();
+//            float f1 = v.getUv().getU();
+//            float f2 = v.getUv().getV();
 //                tfb.put(v.getUv().getU()).put(1f - v.getUv().getV());
-            f1 = f1 - FastMath.floor(f1);
-            f2 = f2 - FastMath.floor(f2);
-            f2 = 1 - f2;
-            skintfb.put(f1).put(f2);
-//            skintfb.put(v.getUv().getU()).put(1f - v.getUv().getV());
+//            f1 = f1 - FastMath.floor(f1);
+//            f2 = f2 - FastMath.floor(f2);
+//            f2 = 1 - f2;
+//            skintfb.put(f1).put(f2);
+            skintfb.put(v.getUv().getU()).put(1f - v.getUv().getV());
 //            skinbisb.put((short) meshConverter.getSkinMeshData()
 //                    .getBoneList().indexOf(v.getBoneNum1()))
 //                    .put((short) meshConverter.getSkinMeshData()