|
|
@@ -1,5 +1,14 @@
|
|
|
package com.jme3.scene.plugins.blender.modifiers;
|
|
|
|
|
|
+import java.nio.ByteBuffer;
|
|
|
+import java.nio.FloatBuffer;
|
|
|
+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.AnimControl;
|
|
|
import com.jme3.animation.Animation;
|
|
|
import com.jme3.animation.Bone;
|
|
|
@@ -26,14 +35,6 @@ import com.jme3.scene.plugins.blender.meshes.MeshContext;
|
|
|
import com.jme3.scene.plugins.blender.objects.ObjectHelper;
|
|
|
import com.jme3.scene.plugins.ogre.AnimData;
|
|
|
import com.jme3.util.BufferUtils;
|
|
|
-import java.nio.ByteBuffer;
|
|
|
-import java.nio.FloatBuffer;
|
|
|
-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 modifier allows to add bone animation to the object.
|
|
|
@@ -145,6 +146,29 @@ import java.util.logging.Logger;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ //fetching action defined in object
|
|
|
+ Pointer pAction = (Pointer) objectStructure.getFieldValue("action");
|
|
|
+ if (pAction.isNotNull()) {
|
|
|
+ Structure actionStructure = pAction.fetchData(blenderContext.getInputStream()).get(0);
|
|
|
+ String actionName = actionStructure.getName();
|
|
|
+
|
|
|
+ BoneTrack[] tracks = armatureHelper.getTracks(actionStructure, skeleton, blenderContext);
|
|
|
+ if(tracks != null && tracks.length > 0) {
|
|
|
+ // determining the animation time
|
|
|
+ float maximumTrackLength = 0;
|
|
|
+ for (BoneTrack track : tracks) {
|
|
|
+ float length = track.getLength();
|
|
|
+ if (length > maximumTrackLength) {
|
|
|
+ maximumTrackLength = length;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Animation boneAnimation = new Animation(actionName, maximumTrackLength);
|
|
|
+ boneAnimation.setTracks(tracks);
|
|
|
+ animations.add(boneAnimation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
animData = new AnimData(skeleton, animations);
|
|
|
|
|
|
// store the animation data for each bone
|