Bugfix: fixed a bug that caused that some constraints were not applied to the bones in animated model.

git-svn-id: https://jmonkeyengine.googlecode.com/svn/branches/gradle-restructure@11005 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
experimental
Kae..pl 11 years ago
parent 69978c710e
commit 595dc4cd8a
  1. 2
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/BlenderContext.java
  2. 8
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/animations/AnimationHelper.java
  3. 4
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/animations/BoneContext.java
  4. 8
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/constraints/SimulationNode.java
  5. 13
      jme3-blender/src/main/java/com/jme3/scene/plugins/blender/objects/ObjectHelper.java

@ -420,7 +420,7 @@ public class BlenderContext {
animList = new ArrayList<Animation>();
animations.put(ownerOMA, animList);
}
animations.put(ownerOMA, animList);
animList.add(animation);
}
/**

@ -10,7 +10,6 @@ import java.util.logging.Logger;
import com.jme3.animation.AnimControl;
import com.jme3.animation.Animation;
import com.jme3.animation.Bone;
import com.jme3.animation.BoneTrack;
import com.jme3.animation.Skeleton;
import com.jme3.animation.SkeletonControl;
@ -121,11 +120,8 @@ public class AnimationHelper extends AbstractBlenderHelper {
Animation boneAnimation = new Animation(animationName, action.getAnimationTime());
boneAnimation.setTracks(tracks);
animations.add(boneAnimation);
for (BoneTrack track : tracks) {
Bone bone = skeleton.getBone(track.getTargetBoneIndex());
BoneContext boneContext = blenderContext.getBoneContext(bone);
blenderContext.addAnimation(boneContext.getBoneOma(), boneAnimation);
}
Long animatedNodeOMA = ((Number)blenderContext.getMarkerValue(ObjectHelper.OMA_MARKER, node)).longValue();
blenderContext.addAnimation(animatedNodeOMA, boneAnimation);
}
} else {
LOGGER.log(Level.WARNING, "Cannot find animation named: {0}.", animationName);

@ -140,7 +140,9 @@ public class BoneContext {
ObjectHelper objectHelper = blenderContext.getHelper(ObjectHelper.class);
Structure skeletonOwnerObjectStructure = (Structure) blenderContext.getLoadedFeature(skeletonOwnerOma, LoadedFeatureDataType.LOADED_STRUCTURE);
Matrix4f invertedObjectOwnerGlobalMatrix = objectHelper.getMatrix(skeletonOwnerObjectStructure, "imat", blenderContext.getBlenderKey().isFixUpAxis());
// I could load 'imat' here, but apparently in some older blenders there were bugs or unfinished functionalities that stored ZERO matrix in imat field
// loading 'obmat' and inverting it makes us avoid errors in such cases
Matrix4f invertedObjectOwnerGlobalMatrix = objectHelper.getMatrix(skeletonOwnerObjectStructure, "obmat", blenderContext.getBlenderKey().isFixUpAxis()).invertLocal();
if (objectHelper.isParent(skeletonOwnerOma, armatureObjectOMA)) {
boneMatrixInModelSpace = globalBoneMatrix.mult(invertedObjectOwnerGlobalMatrix);
} else {

@ -131,11 +131,9 @@ public class SimulationNode {
constraints.addAll(boneConstraints);
}
}
// each bone of the skeleton has the same anim data applied
BoneContext boneContext = blenderContext.getBoneContext(skeleton.getBone(1));
Long boneOma = boneContext.getBoneOma();
animations = blenderContext.getAnimations(boneOma);
Node node = blenderContext.getControlledNode(skeleton);
Long animatedNodeOMA = ((Number)blenderContext.getMarkerValue(ObjectHelper.OMA_MARKER, node)).longValue();
animations = blenderContext.getAnimations(animatedNodeOMA);
} else {
animations = blenderContext.getAnimations(featureOMA);
for (Spatial child : spatial.getChildren()) {

@ -208,8 +208,13 @@ public class ObjectHelper extends AbstractBlenderHelper {
}
if (result != null) {
LOGGER.fine("Storing loaded feature in blender context and applying markers (those will be removed before the final result is released).");
blenderContext.addLoadedFeatures(objectStructure.getOldMemoryAddress(), name, objectStructure, result);
blenderContext.addMarker(OMA_MARKER, result, objectStructure.getOldMemoryAddress());
if (objectType == ObjectType.ARMATURE) {
blenderContext.addMarker(ARMATURE_NODE_MARKER, result, Boolean.TRUE);
}
result.setLocalTransform(t);
result.setCullHint(visible ? CullHint.Always : CullHint.Inherit);
if (parent instanceof Node) {
@ -234,12 +239,6 @@ public class ObjectHelper extends AbstractBlenderHelper {
// I prefer do compute bounding box here than read it from the file
result.updateModelBound();
LOGGER.fine("Applying markers (those will be removed before the final result is released).");
blenderContext.addMarker(OMA_MARKER, result, objectStructure.getOldMemoryAddress());
if (objectType == ObjectType.ARMATURE) {
blenderContext.addMarker(ARMATURE_NODE_MARKER, result, Boolean.TRUE);
}
LOGGER.fine("Applying animations to the object if such are defined.");
AnimationHelper animationHelper = blenderContext.getHelper(AnimationHelper.class);
animationHelper.applyAnimations(result, blenderContext.getBlenderKey().getNodeAnimationNames(name));

Loading…
Cancel
Save