• R/O
  • SSH

MMDLoaderJME: 提交

Java版MikuMikuDanceライブラリ


Commit MetaInfo

修訂dc444377477f924c4bc55b003f540ec820639f78 (tree)
時間2011-08-25 22:42:06
作者Kazuhiko Kobayashi <chototsu_ <moushinp@yaho...>
CommiterKazuhiko Kobayashi <chototsu_

Log Message

0.87

Change Summary

差異

diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/PMDGeometry.java
--- a/src/projectkyoto/jme3/mmd/PMDGeometry.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDGeometry.java Thu Aug 25 22:42:06 2011 +0900
@@ -78,4 +78,20 @@
7878 public void setNoSkinningMaterial(Material noSkinningMaterial) {
7979 this.noSkinningMaterial = noSkinningMaterial;
8080 }
81+
82+ @Override
83+ public PMDGeometry clone() {
84+ PMDGeometry newPMDGeometry = (PMDGeometry)super.clone(false);
85+ newPMDGeometry.setMesh(getMesh().clone());
86+ newPMDGeometry.glslSkinningMaterial = glslSkinningMaterial.clone();
87+ newPMDGeometry.noSkinningMaterial = noSkinningMaterial.clone();
88+ System.out.println("PMDGeometry::clone() "+getName());
89+ return newPMDGeometry;
90+ }
91+
92+ @Override
93+ public PMDGeometry clone(boolean cloneMaterial) {
94+ return clone();
95+ }
96+
8197 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java
--- a/src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDLoaderGLSLSkinning2.java Thu Aug 25 22:42:06 2011 +0900
@@ -88,28 +88,45 @@
8888
8989 public PMDLoaderGLSLSkinning2() {
9090 }
91-
9291 public PMDLoaderGLSLSkinning2(AssetManager assetManager, PMDModel model) {
9392 this.assetManager = assetManager;
9493 this.model = model;
9594 folderName = "/Model/";
9695 // System.out.println("vertexCount = " + model.getVertCount());
9796 // System.out.println("faceVertCount = " + model.getFaceVertCount());
97+// assetManager.registerLoader(com.jme3.texture.plugins.AWTLoader.class, "sph", "spa");
98+ }
99+ public void init() {
100+// model = null;
101+ node = null;
98102 meshConverter = new MeshConverter(model);
99- assetManager.registerLoader(com.jme3.texture.plugins.AWTLoader.class, "sph", "spa");
103+ meshCount = 1;
104+// assetManager = null;
105+// folderName = null;
106+ meshList.clear();
107+ skinMeshList.clear();
108+ skinvb = null;
109+ skinvb2 = null;
110+ skinnb = null;
111+ skinnb2 = null;
112+ skintb = null;
113+ skeletonControl = null;
114+ skinArray = null;
100115 }
101116
102117 public PMDNode createNode(String name) {
118+ init();
103119 node = new PMDNode(name, model, assetManager);
104120 meshCount = 1;
105121 meshConverter.convertMesh();
122+ System.out.println("child size = "+node.getChildren().size()+" "+meshList.size()+" "+skinMeshList.size());
106123 for (MeshData md : meshConverter.getMeshDataList()) {
107124 PMDMesh mesh = createMesh(md);
108125 PMDGeometry geom = new PMDGeometry("geom" + meshCount++);
109126 geom.setMesh(mesh);
110127 PMDMaterial pmdMaterial = md.getMaterial();
111128 setupMaterial(pmdMaterial, geom);
112- node.attachChild(geom);
129+ System.out.println(node.attachChild(geom));
113130 meshList.add(mesh);
114131 }
115132 createSkinCommonVertData();
@@ -118,33 +135,35 @@
118135 PMDGeometry geom = new PMDGeometry("geom" + meshCount++);
119136 geom.setMesh(mesh);
120137 setupMaterial(pmdMaterial, geom);
121- node.attachChild(geom);
138+ System.out.println(node.attachChild(geom));
122139 skinMeshList.add(mesh);
123140 }
141+ System.out.println("child size = "+node.getChildren().size()+" "+meshList.size()+" "+skinMeshList.size());
124142 createSkinArray();
125143 createSkeleton();
126144 node.setSkinData(skinMeshList.toArray(new PMDSkinMesh[skinMeshList.size()]), meshConverter.getSkinMeshData().getVertexList(), skinArray);
127145 node.targets = meshList.toArray(new PMDMesh[meshList.size()]);
128146 node.init();
147+ node.update();
129148 return node;
130149 }
131150
132151 void createSkinCommonVertData() {
133152 skinvb = new VertexBuffer(VertexBuffer.Type.Position);
134153 FloatBuffer skinvfb = BufferUtils.createFloatBuffer(meshConverter.getSkinMeshData().getVertexList().size() * 3);
135- skinvb.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinvfb);
154+ skinvb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb);
136155
137156 skinvb2 = new VertexBuffer(VertexBuffer.Type.Position);
138157 FloatBuffer skinvfb2 = BufferUtils.createFloatBuffer(meshConverter.getSkinMeshData().getVertexList().size() * 3);
139- skinvb2.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinvfb2);
158+ skinvb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb2);
140159
141160 skinnb = new VertexBuffer(VertexBuffer.Type.Normal);
142161 FloatBuffer skinnfb = BufferUtils.createFloatBuffer(meshConverter.getSkinMeshData().getVertexList().size() * 3);
143- skinnb.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinnfb);
162+ skinnb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinnfb);
144163
145164 skinnb2 = new VertexBuffer(VertexBuffer.Type.Normal);
146165 FloatBuffer skinnfb2 = BufferUtils.createFloatBuffer(meshConverter.getSkinMeshData().getVertexList().size() * 3);
147- skinnb2.setupData(VertexBuffer.Usage.Static, 3, VertexBuffer.Format.Float, skinnfb2);
166+ skinnb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinnfb2);
148167
149168 skintb = new VertexBuffer(VertexBuffer.Type.TexCoord);
150169 FloatBuffer skintfb = BufferUtils.createFloatBuffer(meshConverter.getSkinMeshData().getVertexList().size() * 2);
@@ -184,10 +203,10 @@
184203 VertexBuffer nb = new VertexBuffer(VertexBuffer.Type.Normal);
185204 FloatBuffer nfb = BufferUtils.createFloatBuffer(md.getVertexList().size() * 3);
186205
187- VertexBuffer bvb = new VertexBuffer(VertexBuffer.Type.BindPosePosition);
188- FloatBuffer bvfb = BufferUtils.createFloatBuffer(md.getVertexList().size() * 3);
189- VertexBuffer bnb = new VertexBuffer(VertexBuffer.Type.BindPoseNormal);
190- FloatBuffer bnfb = BufferUtils.createFloatBuffer(md.getVertexList().size() * 3);
206+// VertexBuffer bvb = new VertexBuffer(VertexBuffer.Type.BindPosePosition);
207+// FloatBuffer bvfb = BufferUtils.createFloatBuffer(md.getVertexList().size() * 3);
208+// VertexBuffer bnb = new VertexBuffer(VertexBuffer.Type.BindPoseNormal);
209+// FloatBuffer bnfb = BufferUtils.createFloatBuffer(md.getVertexList().size() * 3);
191210
192211 VertexBuffer tb = new VertexBuffer(VertexBuffer.Type.TexCoord);
193212
@@ -202,8 +221,8 @@
202221 vfb.put(v.getPos().x).put(v.getPos().y).put(v.getPos().z);
203222 nfb.put(v.getNormal().x).put(v.getNormal().y).put(v.getNormal().z);
204223
205- bvfb.put(v.getPos().x).put(v.getPos().y).put(v.getPos().z);
206- bnfb.put(v.getNormal().x).put(v.getNormal().y).put(v.getNormal().z);
224+// bvfb.put(v.getPos().x).put(v.getPos().y).put(v.getPos().z);
225+// bnfb.put(v.getNormal().x).put(v.getNormal().y).put(v.getNormal().z);
207226
208227 tfb.put(v.getUv().getU()).put(1f - v.getUv().getV());
209228 float weight = (float) v.getBoneWeight() / 100.0f;
@@ -219,8 +238,8 @@
219238 vb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, vfb);
220239 nb.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, nfb);
221240
222- bvb.setupData(VertexBuffer.Usage.CpuOnly, 3, VertexBuffer.Format.Float, bvfb);
223- bnb.setupData(VertexBuffer.Usage.CpuOnly, 3, VertexBuffer.Format.Float, bnfb);
241+// bvb.setupData(VertexBuffer.Usage.CpuOnly, 3, VertexBuffer.Format.Float, bvfb);
242+// bnb.setupData(VertexBuffer.Usage.CpuOnly, 3, VertexBuffer.Format.Float, bnfb);
224243
225244 tb.setupData(VertexBuffer.Usage.Static, 2, VertexBuffer.Format.Float, tfb);
226245 wb.setupData(VertexBuffer.Usage.Static, 4, VertexBuffer.Format.Float, wfb);
@@ -229,8 +248,8 @@
229248 mesh.setBuffer(vb);
230249 mesh.setBuffer(nb);
231250
232- mesh.setBuffer(bvb);
233- mesh.setBuffer(bnb);
251+// mesh.setBuffer(bvb);
252+// mesh.setBuffer(bnb);
234253
235254 mesh.setBuffer(tb);
236255 mesh.setBuffer(wb);
@@ -448,6 +467,7 @@
448467 Quaternion q = new Quaternion();
449468 q = q.fromAngleNormalAxis((float) Math.PI / 8, new Vector3f(0, 0, 1));
450469 node.skeleton = skeleton;
470+ temp.release();
451471 }
452472
453473 void createSkinArray() {
@@ -509,10 +529,21 @@
509529
510530 @Override
511531 public Object load(AssetInfo ai) throws IOException {
512- this.assetManager = ai.getManager();
513- model = new PMDModel(ai.openStream());
514- folderName = ai.getKey().getFolder();
515- meshConverter = new MeshConverter(model);
516- return createNode(ai.getKey().getName());
532+ boolean errFlag = false;
533+ for(;;) {
534+ try {
535+ this.assetManager = ai.getManager();
536+ model = new PMDModel(ai.openStream());
537+ folderName = ai.getKey().getFolder();
538+ meshConverter = new MeshConverter(model);
539+ return createNode(ai.getKey().getName());
540+ }catch(OutOfMemoryError ex) {
541+ if (errFlag) {
542+ throw new RuntimeException(ex);
543+ }
544+ errFlag = true;
545+ System.gc();
546+ }
547+ }
517548 }
518549 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/PMDMesh.java
--- a/src/projectkyoto/jme3/mmd/PMDMesh.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDMesh.java Thu Aug 25 22:42:06 2011 +0900
@@ -69,4 +69,16 @@
6969 public BoundingVolume getBound() {
7070 return bound;
7171 }
72+
73+ @Override
74+ public PMDMesh clone() {
75+ PMDMesh newMesh = (PMDMesh)super.clone();
76+ newMesh.boneMatrixArray = new Matrix4f[boneMatrixArray.length];
77+ for(int i=0;i<newMesh.boneMatrixArray.length;i++) {
78+ newMesh.boneMatrixArray[i] = new Matrix4f();
79+ }
80+ System.out.println("PMDMesh::clone()");
81+ return newMesh;
82+ }
83+
7284 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/PMDModelKey.java
--- a/src/projectkyoto/jme3/mmd/PMDModelKey.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDModelKey.java Thu Aug 25 22:42:06 2011 +0900
@@ -45,5 +45,10 @@
4545 public PMDModelKey(String name) {
4646 super(name);
4747 }
48+
49+ @Override
50+ public boolean shouldCache() {
51+ return false;
52+ }
4853
4954 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/PMDNode.java
--- a/src/projectkyoto/jme3/mmd/PMDNode.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDNode.java Thu Aug 25 22:42:06 2011 +0900
@@ -58,6 +58,7 @@
5858 import java.util.Map;
5959 import java.util.Set;
6060 import projectkyoto.mmd.file.PMDBone;
61+import projectkyoto.mmd.file.PMDException;
6162 import projectkyoto.mmd.file.PMDSkinVertData;
6263 import projectkyoto.mmd.file.PMDVertex;
6364
@@ -91,7 +92,7 @@
9192 Geometry bonePositionGeomArray[];
9293 Node rigidBodyNode;
9394 Node jointNode;
94- boolean glslSkinning = false;
95+ boolean glslSkinning = true;
9596
9697 public PMDNode(String name, PMDModel pmdModel, AssetManager assetManager) {
9798 super(name);
@@ -485,6 +486,9 @@
485486 }
486487
487488 void resetToBind(PMDMesh mesh) {
489+
490+ }
491+ void _resetToBind(PMDMesh mesh) {
488492 VertexBuffer vb = mesh.getBuffer(VertexBuffer.Type.Position);
489493 FloatBuffer vfb = (FloatBuffer) vb.getData();
490494 VertexBuffer nb = mesh.getBuffer(VertexBuffer.Type.Normal);
@@ -727,6 +731,7 @@
727731 }
728732
729733 public void setGlslSkinning(boolean glslSkinning) {
734+ glslSkinning = true;
730735 this.glslSkinning = glslSkinning;
731736 for (PMDMesh mesh : targets) {
732737 // resetToBind(mesh);
@@ -763,8 +768,67 @@
763768 }
764769
765770 @Override
766- public Spatial clone() {
767- return super.clone();
771+ public PMDNode clone() {
772+ try {
773+ PMDNode newPMDNode = (PMDNode)super.clone();
774+// newPMDNode.pmdModel = pmdModel;
775+ System.out.println("model name = "+pmdModel.getModelName());
776+ System.out.println("child size = "+getChildren().size());
777+ System.out.println("source targets size = "+targets.length+" "+skinTargets.length);
778+ if (newPMDNode.getChildren().size() != getChildren().size()){
779+ System.out.println("child size error "+newPMDNode.getChildren().size());
780+ }
781+ newPMDNode.skeleton = new Skeleton(skeleton);
782+ for(int i=0;i<skeleton.getBoneCount();i++) {
783+ Bone newBone = newPMDNode.skeleton.getBone(i);
784+ Bone bone = skeleton.getBone(i);
785+ newBone.getLocalPosition().set(bone.getLocalPosition());
786+ newBone.getLocalRotation().set(bone.getLocalRotation());
787+ newBone.getLocalScale().set(bone.getLocalScale());
788+ }
789+ newPMDNode.targets = new PMDMesh[targets.length];
790+ newPMDNode.skinTargets = new PMDSkinMesh[skinTargets.length];
791+ int meshCount=0;
792+ int skinMeshCount = 0;
793+ for(Spatial sp : newPMDNode.getChildren()) {
794+ Spatial newSp = sp;//.clone();
795+// newPMDNode.attachChild(newSp);
796+ if (sp instanceof PMDGeometry) {
797+ Mesh mesh = ((Geometry)newSp).getMesh();
798+ if (mesh instanceof PMDMesh) {
799+ newPMDNode.targets[meshCount++] = (PMDMesh)mesh;
800+ } else if (mesh instanceof PMDSkinMesh) {
801+ newPMDNode.skinTargets[skinMeshCount++] = (PMDSkinMesh)mesh;
802+ }
803+ }
804+ }
805+ newPMDNode.skinMap = new HashMap<String, Skin>();
806+ for(String skinName : skinMap.keySet()) {
807+ Skin skin = skinMap.get(skinName);
808+ skin = skin.clone();
809+ newPMDNode.skinMap.put(skinName, skin);
810+ }
811+ newPMDNode.skinPosArray = new javax.vecmath.Vector3f[skinPosArray.length];
812+ for(int i=0;i<skinPosArray.length;i++) {
813+ newPMDNode.skinPosArray[i] = new javax.vecmath.Vector3f(skinPosArray[i]);
814+ }
815+ newPMDNode.skinNormalArray = new javax.vecmath.Vector3f[skinNormalArray.length];
816+ for(int i=0;i<skinNormalArray.length;i++) {
817+ newPMDNode.skinNormalArray[i] = new javax.vecmath.Vector3f(skinNormalArray[i]);
818+ }
819+// newPMDNode.offsetMatrices = new Matrix4f[offsetMatrices.length];
820+ System.out.println("skinTargets size = "+skinTargets.length+" "+skinMeshCount);
821+ newPMDNode.setGlslSkinning(newPMDNode.glslSkinning);
822+ newPMDNode.skeleton.updateWorldVectors();
823+ newPMDNode.calcOffsetMatrices();
824+ newPMDNode.updateSkinBackData();
825+ newPMDNode.update();
826+ newPMDNode.updateSkinBackData();
827+ newPMDNode.update();
828+ return newPMDNode;
829+ } catch(CloneNotSupportedException ex) {
830+ throw new PMDException(ex);
831+ }
768832 }
769833
770834 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/PMDSkinMesh.java
--- a/src/projectkyoto/jme3/mmd/PMDSkinMesh.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/PMDSkinMesh.java Thu Aug 25 22:42:06 2011 +0900
@@ -35,6 +35,8 @@
3535 import com.jme3.math.Vector3f;
3636 import com.jme3.scene.Mesh;
3737 import com.jme3.scene.VertexBuffer;
38+import com.jme3.util.BufferUtils;
39+import java.nio.FloatBuffer;
3840
3941 /**
4042 *
@@ -89,4 +91,31 @@
8991 public BoundingVolume getBound() {
9092 return bound;
9193 }
94+ @Override
95+ public PMDSkinMesh clone() {
96+ System.out.println("PMDSkinMesh::clone()");
97+ PMDSkinMesh newMesh = (PMDSkinMesh)super.clone();
98+// newMesh.boneMatrixArray = new Matrix4f[boneMatrixArray.length];
99+ newMesh.skinvb2 = new VertexBuffer(VertexBuffer.Type.Position);
100+ FloatBuffer skinvfb2 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData());
101+ newMesh.skinvb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb2);
102+
103+ newMesh.skinnb2 = new VertexBuffer(VertexBuffer.Type.Normal);
104+ FloatBuffer skinnfb2 = BufferUtils.clone((FloatBuffer)this.skinnb2.getData());
105+ newMesh.skinnb2.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinnfb2);
106+
107+ VertexBuffer skinvb1 = new VertexBuffer(VertexBuffer.Type.Position);
108+ FloatBuffer skinvfb1 = BufferUtils.clone((FloatBuffer)this.skinvb2.getData());
109+ skinvb1.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinvfb1);
110+ newMesh.clearBuffer(VertexBuffer.Type.Position);
111+ newMesh.setBuffer(skinvb1);
112+
113+ VertexBuffer skinnb1 = new VertexBuffer(VertexBuffer.Type.Normal);
114+ FloatBuffer skinnfb1 = BufferUtils.clone((FloatBuffer)this.skinnb2.getData());
115+ skinnb1.setupData(VertexBuffer.Usage.Dynamic, 3, VertexBuffer.Format.Float, skinnfb1);
116+ newMesh.clearBuffer(VertexBuffer.Type.Normal);
117+ newMesh.setBuffer(skinnb1);
118+
119+ return newMesh;
120+ }
92121 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/Skin.java
--- a/src/projectkyoto/jme3/mmd/Skin.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/Skin.java Thu Aug 25 22:42:06 2011 +0900
@@ -35,7 +35,7 @@
3535 *
3636 * @author kobayasi
3737 */
38-public class Skin {
38+public class Skin implements Cloneable{
3939
4040 String skinName;
4141 float weight = 0f;
@@ -86,4 +86,10 @@
8686 public void setUpdateNeeded(boolean updateNeeded) {
8787 this.updateNeeded = updateNeeded;
8888 }
89+
90+ @Override
91+ protected Skin clone() throws CloneNotSupportedException {
92+ return (Skin)super.clone();
93+ }
94+
8995 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/nativebullet/PMDPhysicsWorld.java
--- a/src/projectkyoto/jme3/mmd/nativebullet/PMDPhysicsWorld.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/nativebullet/PMDPhysicsWorld.java Thu Aug 25 22:42:06 2011 +0900
@@ -61,11 +61,11 @@
6161 */
6262 public class PMDPhysicsWorld {
6363 // bullet physics
64-
64+ static final Object lockObject = new Object();
6565 PhysicsSpace physicsSpace;
6666 Map<PMDNode, PMDRigidBody[]> rigidBodyMap = new HashMap<PMDNode, PMDRigidBody[]>();
6767 Map<PMDNode, SixDofJoint[]> constraintMap = new HashMap<PMDNode, SixDofJoint[]>();
68- float accuracy = 1f / 180;
68+ float accuracy = 1f / 120;
6969
7070 public PMDPhysicsWorld() {
7171 float dist = 400f;
@@ -115,7 +115,11 @@
115115 // btWorld.addRigidBody(rb, (short) (1 << fileRigidBody.getRigidBodyGroupIndex()),
116116 // (short) fileRigidBody.getRigidBodyGroupTarget());
117117 rb.setCollisionGroup(1 << (fileRigidBody.getRigidBodyGroupIndex()));
118- rb.setCollideWithGroups(fileRigidBody.getRigidBodyGroupTarget());
118+// if (fileRigidBody.getRigidBodyName().contains("スカート")) {
119+// rb.setCollideWithGroups(1 << 7);
120+// } else {
121+ rb.setCollideWithGroups(fileRigidBody.getRigidBodyGroupTarget());
122+// }
119123 // rb.setCollideWithGroups(0 );
120124 physicsSpace.addCollisionObject(rb);
121125 }
@@ -216,7 +220,7 @@
216220 throw new PMDException("Invalid getShapeType:" + fileRigidBody.getRigidBodyName() + " "
217221 + fileRigidBody.getShapeType());
218222 }
219- cs.setMargin(0.08f);
223+// cs.setMargin(0.01f);
220224 if (fileRigidBody.getRigidBodyType() != 0) {
221225 mass = fileRigidBody.getWeight();
222226 kinematic = false;
@@ -270,7 +274,7 @@
270274 return rb;
271275 }
272276
273- void convPMDEuler(Matrix3f out, float x, float y, float z) {
277+ void _convPMDEuler(Matrix3f out, float x, float y, float z) {
274278 Quaternion qx = new Quaternion();
275279 Quaternion qy = new Quaternion();
276280 Quaternion qz = new Quaternion();
@@ -284,7 +288,7 @@
284288
285289 qz.toRotationMatrix(out);
286290 }
287- void _convPMDEuler(Matrix3f out, float x, float y, float z) {
291+ void convPMDEuler(Matrix3f out, float x, float y, float z) {
288292 // Matrix3f m = new Matrix3f();
289293 // m.loadIdentity();
290294 //
@@ -418,7 +422,7 @@
418422 // System.out.println("constRot1 x must > -90");
419423 // }
420424 if (constRot1.getY() <= -FastMath.PI / 0.5f) {
421- constRot1.setY(-FastMath.PI * 0.5f);
425+ constRot1.setY(-FastMath.PI * 0.49f);
422426 System.out.println("constRot1 y must > -90");
423427 }
424428 // if (constRot1.getZ() <= -FastMath.PI / 1.0f) {
@@ -433,7 +437,7 @@
433437 // System.out.println("constRot2 x must < 90");
434438 // }
435439 if (constRot2.getY() >= FastMath.PI / 0.5f) {
436- constRot2.setY(FastMath.PI * 0.5f);
440+ constRot2.setY(FastMath.PI * 0.49f);
437441 System.out.println("constRot2 y must < 90");
438442 }
439443 // if (constRot2.getZ() >= FastMath.PI / 1.0f) {
@@ -495,7 +499,9 @@
495499 // physicsSpace.update(time + accuracy, 2);
496500 // applyResultToBone();
497501 // }
498- physicsSpace.update(timeStep, 10);
502+// synchronized(lockObject) {
503+ physicsSpace.update(timeStep, 10);
504+// }
499505 // applyResultToBone();
500506 }
501507 Transform t = new Transform();
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/nativebullet/PMDRigidBody.java
--- a/src/projectkyoto/jme3/mmd/nativebullet/PMDRigidBody.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/nativebullet/PMDRigidBody.java Thu Aug 25 22:42:06 2011 +0900
@@ -138,7 +138,7 @@
138138 // tmpQ.multLocal(invRot);
139139 bone.getModelSpaceRotation().set(m2.toRotationQuat());
140140 // bone.getModelSpacePosition().set(m2.toTranslationVector());
141- updateFromBoneMatrix();
141+// updateFromBoneMatrix();
142142 // super.getPhysicsLocation();
143143 // super.getPhysicsRotation();
144144 }
diff -r 6343ff1e87bb -r dc444377477f src/projectkyoto/jme3/mmd/vmd/VMDControl.java
--- a/src/projectkyoto/jme3/mmd/vmd/VMDControl.java Thu Aug 25 17:44:19 2011 +0900
+++ b/src/projectkyoto/jme3/mmd/vmd/VMDControl.java Thu Aug 25 22:42:06 2011 +0900
@@ -169,7 +169,7 @@
169169 // }
170170 if (time != 0 && !pause) {
171171 // controlUpdate2(time);
172- physicsControl.update(tpf);
172+ physicsControl.update(tpf);
173173 // physicsControl.getWorld().applyResultToBone();
174174 }
175175 }
Show on old repository browser