Parcourir la source

* Committed fixes to mesh animation classes (not currently used). See http://jmonkeyengine.org/groups/contribution-depot-jme3/forum/topic/fix-to-ogre-mesh-animations-deserializing

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9534 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
Sha..rd il y a 13 ans
Parent
commit
fd9f274049

+ 23 - 10
engine/src/core/com/jme3/animation/Pose.java

@@ -59,6 +59,13 @@ public final class Pose implements Savable, Cloneable {
         this.indices = indices;
     }
 
+    /**
+     * Serialization-only. Do not use.
+     */
+    public Pose()
+    {
+    }
+    
     public int getTargetMeshIndex(){
         return targetMeshIndex;
     }
@@ -92,21 +99,22 @@ public final class Pose implements Savable, Cloneable {
      * This method creates a clone of the current object.
      * @return a clone of the current object
      */
+    @Override
     public Pose clone() {
-		try {
-			Pose result = (Pose) super.clone();
+        try {
+            Pose result = (Pose) super.clone();
             result.indices = this.indices.clone();
-            if(this.offsets!=null) {
-            	result.offsets = new Vector3f[this.offsets.length];
-            	for(int i=0;i<this.offsets.length;++i) {
-            		result.offsets[i] = this.offsets[i].clone();
-            	}
+            if (this.offsets != null) {
+                result.offsets = new Vector3f[this.offsets.length];
+                for (int i = 0; i < this.offsets.length; ++i) {
+                    result.offsets[i] = this.offsets[i].clone();
+                }
             }
-    		return result;
+            return result;
         } catch (CloneNotSupportedException e) {
             throw new AssertionError();
         }
-	}
+    }
 
     public void write(JmeExporter e) throws IOException {
         OutputCapsule out = e.getCapsule(this);
@@ -120,7 +128,12 @@ public final class Pose implements Savable, Cloneable {
         InputCapsule in = i.getCapsule(this);
         name = in.readString("name", "");
         targetMeshIndex = in.readInt("meshIndex", -1);
-        offsets = (Vector3f[]) in.readSavableArray("offsets", null);
         indices = in.readIntArray("indices", null);
+
+        Savable[] readSavableArray = in.readSavableArray("offsets", null);
+        if (readSavableArray != null) {
+            offsets = new Vector3f[readSavableArray.length];
+            System.arraycopy(readSavableArray, 0, offsets, 0, readSavableArray.length);
+        }
     }
 }

+ 26 - 2
engine/src/core/com/jme3/animation/PoseTrack.java

@@ -60,6 +60,13 @@ public final class PoseTrack implements Track {
             this.weights = weights;
         }
         
+        /**
+         * Serialization-only. Do not use.
+         */
+        public PoseFrame()
+        {
+        }
+        
         /**
          * This method creates a clone of the current object.
          * @return a clone of the current object
@@ -89,8 +96,13 @@ public final class PoseTrack implements Track {
 
         public void read(JmeImporter i) throws IOException {
             InputCapsule in = i.getCapsule(this);
-            poses = (Pose[]) in.readSavableArray("poses", null);
             weights = in.readFloatArray("weights", null);
+            
+            Savable[] readSavableArray = in.readSavableArray("poses", null);
+            if (readSavableArray != null) {
+                poses = new Pose[readSavableArray.length];
+                System.arraycopy(readSavableArray, 0, poses, 0, readSavableArray.length);
+            }
         }
     }
 
@@ -100,6 +112,13 @@ public final class PoseTrack implements Track {
         this.frames = frames;
     }
     
+    /**
+     * Serialization-only. Do not use.
+     */
+    public PoseTrack()
+    {
+    }
+    
     private void applyFrame(Mesh target, int frameIndex, float weight){
         PoseFrame frame = frames[frameIndex];
         VertexBuffer pb = target.getBuffer(Type.Position);
@@ -180,7 +199,12 @@ public final class PoseTrack implements Track {
     public void read(JmeImporter i) throws IOException {
         InputCapsule in = i.getCapsule(this);
         targetMeshIndex = in.readInt("meshIndex", 0);
-        frames = (PoseFrame[]) in.readSavableArray("frames", null);
         times = in.readFloatArray("times", null);
+        
+        Savable[] readSavableArray = in.readSavableArray("frames", null);
+        if (readSavableArray != null) {
+            frames = new PoseFrame[readSavableArray.length];
+            System.arraycopy(readSavableArray, 0, frames, 0, readSavableArray.length);
+        }
     }
 }