Bugfix: fixed an error that could create wrogn vertex to bone group assignment. This caused animation to be played badly because some vertices remained in their places instead of moving with the proper bone.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10463 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
Kae..pl 12 years ago
parent 23c1fddf8f
commit 3888036176
  1. 14
      engine/src/blender/com/jme3/scene/plugins/blender/animations/ArmatureHelper.java
  2. 7
      engine/src/blender/com/jme3/scene/plugins/blender/modifiers/ArmatureModifier.java

@ -31,23 +31,23 @@
*/ */
package com.jme3.scene.plugins.blender.animations; package com.jme3.scene.plugins.blender.animations;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import com.jme3.animation.Bone; import com.jme3.animation.Bone;
import com.jme3.animation.BoneTrack; import com.jme3.animation.BoneTrack;
import com.jme3.animation.Skeleton; import com.jme3.animation.Skeleton;
import com.jme3.math.Matrix4f; import com.jme3.math.Matrix4f;
import com.jme3.scene.Spatial;
import com.jme3.scene.plugins.blender.AbstractBlenderHelper; import com.jme3.scene.plugins.blender.AbstractBlenderHelper;
import com.jme3.scene.plugins.blender.BlenderContext; import com.jme3.scene.plugins.blender.BlenderContext;
import com.jme3.scene.plugins.blender.curves.BezierCurve; import com.jme3.scene.plugins.blender.curves.BezierCurve;
import com.jme3.scene.plugins.blender.exceptions.BlenderFileException; import com.jme3.scene.plugins.blender.exceptions.BlenderFileException;
import com.jme3.scene.plugins.blender.file.Pointer; import com.jme3.scene.plugins.blender.file.Pointer;
import com.jme3.scene.plugins.blender.file.Structure; import com.jme3.scene.plugins.blender.file.Structure;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/** /**
* This class defines the methods to calculate certain aspects of animation and * This class defines the methods to calculate certain aspects of animation and

@ -314,9 +314,10 @@ import com.jme3.util.BufferUtils;
List<Structure> dw = pDW.fetchData(blenderContext.getInputStream()); List<Structure> dw = pDW.fetchData(blenderContext.getInputStream());
for (Structure deformWeight : dw) { for (Structure deformWeight : dw) {
Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue()); Integer boneIndex = groupToBoneIndexMap.get(((Number) deformWeight.getFieldValue("def_nr")).intValue());
// null here means that we came accross group that has no bone attached to
if (boneIndex != null) {
float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue(); float weight = ((Number) deformWeight.getFieldValue("weight")).floatValue();
// boneIndex == null: it here means that we came accross group that has no bone attached to, so simply ignore it
// if weight == 0 and weightIndex == 0 then ignore the weight (do not set weight = 0 as a first weight)
if (boneIndex != null && (weight > 0.0f || weightIndex > 0)) {
if (weightIndex < MAXIMUM_WEIGHTS_PER_VERTEX) { if (weightIndex < MAXIMUM_WEIGHTS_PER_VERTEX) {
if (weight == 0.0f) { if (weight == 0.0f) {
boneIndex = Integer.valueOf(0); boneIndex = Integer.valueOf(0);
@ -341,9 +342,9 @@ import com.jme3.util.BufferUtils;
weightToIndexMap.put(weight, lowestWeightAndIndex.getValue()); weightToIndexMap.put(weight, lowestWeightAndIndex.getValue());
} }
} }
}
++weightIndex; ++weightIndex;
} }
}
} else { } else {
// 0.0 weight indicates, do not transform this vertex, but keep it in bind pose. // 0.0 weight indicates, do not transform this vertex, but keep it in bind pose.
for (Integer index : vertexIndices) { for (Integer index : vertexIndices) {

Loading…
Cancel
Save