|
35 | 35 | import com.jme3.math.*; |
36 | 36 | import com.jme3.scene.Node; |
37 | 37 | import com.jme3.util.TempVars; |
| 38 | +import com.jme3.util.clone.JmeCloneable; |
| 39 | +import com.jme3.util.clone.Cloner; |
38 | 40 | import java.io.IOException; |
39 | 41 | import java.util.ArrayList; |
40 | 42 |
|
|
62 | 64 | * @author Kirill Vainer |
63 | 65 | * @author Rémy Bouquet |
64 | 66 | */ |
65 | | -public final class Bone implements Savable { |
| 67 | +public final class Bone implements Savable, JmeCloneable { |
66 | 68 |
|
67 | 69 | // Version #2: Changed naming of transforms as they were misleading |
68 | 70 | public static final int SAVABLE_VERSION = 2; |
69 | 71 | private String name; |
70 | 72 | private Bone parent; |
71 | | - private final ArrayList<Bone> children = new ArrayList<Bone>(); |
| 73 | + private ArrayList<Bone> children = new ArrayList<Bone>(); |
72 | 74 | /** |
73 | 75 | * If enabled, user can control bone transform with setUserTransforms. |
74 | 76 | * Animation transforms are not applied to this bone when enabled. |
@@ -167,6 +169,43 @@ public Bone(String name) { |
167 | 169 | */ |
168 | 170 | public Bone() { |
169 | 171 | } |
| 172 | + |
| 173 | + @Override |
| 174 | + public Object jmeClone() { |
| 175 | + try { |
| 176 | + Bone clone = (Bone)super.clone(); |
| 177 | + return clone; |
| 178 | + } catch (CloneNotSupportedException ex) { |
| 179 | + throw new AssertionError(); |
| 180 | + } |
| 181 | + } |
| 182 | + |
| 183 | + @Override |
| 184 | + public void cloneFields( Cloner cloner, Object original ) { |
| 185 | + |
| 186 | + this.parent = cloner.clone(parent); |
| 187 | + this.children = cloner.clone(children); |
| 188 | + |
| 189 | + this.attachNode = cloner.clone(attachNode); |
| 190 | + |
| 191 | + this.bindPos = cloner.clone(bindPos); |
| 192 | + this.bindRot = cloner.clone(bindRot); |
| 193 | + this.bindScale = cloner.clone(bindScale); |
| 194 | + |
| 195 | + this.modelBindInversePos = cloner.clone(modelBindInversePos); |
| 196 | + this.modelBindInverseRot = cloner.clone(modelBindInverseRot); |
| 197 | + this.modelBindInverseScale = cloner.clone(modelBindInverseScale); |
| 198 | + |
| 199 | + this.localPos = cloner.clone(localPos); |
| 200 | + this.localRot = cloner.clone(localRot); |
| 201 | + this.localScale = cloner.clone(localScale); |
| 202 | + |
| 203 | + this.modelPos = cloner.clone(modelPos); |
| 204 | + this.modelRot = cloner.clone(modelRot); |
| 205 | + this.modelScale = cloner.clone(modelScale); |
| 206 | + |
| 207 | + this.tmpTransform = cloner.clone(tmpTransform); |
| 208 | + } |
170 | 209 |
|
171 | 210 | /** |
172 | 211 | * Returns the name of the bone, set in the constructor. |
|
0 commit comments