/** * Creates a skeleton from a bone list. * The root bones are found automatically. * <p> * Note that using this constructor will cause the bones in the list * to have their bind pose recomputed based on their local transforms. * * @param boneList The list of bones to manage by this Skeleton */ public Skeleton(Bone[] boneList) { this.boneList = boneList; List<Bone> rootBoneList = new ArrayList<>(); for (int i = boneList.length - 1; i >= 0; i--) { Bone b = boneList[i]; if (b.getParent() == null) { rootBoneList.add(b); } } rootBones = rootBoneList.toArray(new Bone[rootBoneList.size()]); createSkinningMatrices(); for (int i = rootBones.length - 1; i >= 0; i--) { Bone rootBone = rootBones[i]; rootBone.update(); rootBone.setBindingPose(); } }
/** * Special-purpose copy constructor. * <p> * Shallow copies bind pose data from the source skeleton, does not * copy any other data. * * @param source The source Skeleton to copy from */ public Skeleton(Skeleton source) { Bone[] sourceList = source.boneList; boneList = new Bone[sourceList.length]; for (int i = 0; i < sourceList.length; i++) { boneList[i] = new Bone(sourceList[i]); } rootBones = new Bone[source.rootBones.length]; for (int i = 0; i < rootBones.length; i++) { rootBones[i] = recreateBoneStructure(source.rootBones[i]); } createSkinningMatrices(); for (int i = rootBones.length - 1; i >= 0; i--) { rootBones[i].update(); } }
@Override public void read(JmeImporter im) throws IOException { InputCapsule input = im.getCapsule(this); Savable[] boneRootsAsSav = input.readSavableArray("rootBones", null); rootBones = new Bone[boneRootsAsSav.length]; System.arraycopy(boneRootsAsSav, 0, rootBones, 0, boneRootsAsSav.length); Savable[] boneListAsSavable = input.readSavableArray("boneList", null); boneList = new Bone[boneListAsSavable.length]; System.arraycopy(boneListAsSavable, 0, boneList, 0, boneListAsSavable.length); createSkinningMatrices(); for (Bone rootBone : rootBones) { rootBone.reset(); rootBone.update(); rootBone.setBindingPose(); } }
/** * Creates a skeleton from a bone list. * The root bones are found automatically. * <p> * Note that using this constructor will cause the bones in the list * to have their bind pose recomputed based on their local transforms. * * @param boneList The list of bones to manage by this Skeleton */ public Skeleton(Bone[] boneList) { this.boneList = boneList; List<Bone> rootBoneList = new ArrayList<>(); for (int i = boneList.length - 1; i >= 0; i--) { Bone b = boneList[i]; if (b.getParent() == null) { rootBoneList.add(b); } } rootBones = rootBoneList.toArray(new Bone[rootBoneList.size()]); createSkinningMatrices(); for (int i = rootBones.length - 1; i >= 0; i--) { Bone rootBone = rootBones[i]; rootBone.update(); rootBone.setBindingPose(); } }
/** * Creates a skeleton from a bone list. * The root bones are found automatically. * <p> * Note that using this constructor will cause the bones in the list * to have their bind pose recomputed based on their local transforms. * * @param boneList The list of bones to manage by this Skeleton */ public Skeleton(Bone[] boneList) { this.boneList = boneList; List<Bone> rootBoneList = new ArrayList<Bone>(); for (int i = boneList.length - 1; i >= 0; i--) { Bone b = boneList[i]; if (b.getParent() == null) { rootBoneList.add(b); } } rootBones = rootBoneList.toArray(new Bone[rootBoneList.size()]); createSkinningMatrices(); for (int i = rootBones.length - 1; i >= 0; i--) { Bone rootBone = rootBones[i]; rootBone.update(); rootBone.setBindingPose(); } }
public void read(JmeImporter im) throws IOException { InputCapsule input = im.getCapsule(this); Savable[] boneRootsAsSav = input.readSavableArray("rootBones", null); rootBones = new Bone[boneRootsAsSav.length]; System.arraycopy(boneRootsAsSav, 0, rootBones, 0, boneRootsAsSav.length); Savable[] boneListAsSavable = input.readSavableArray("boneList", null); boneList = new Bone[boneListAsSavable.length]; System.arraycopy(boneListAsSavable, 0, boneList, 0, boneListAsSavable.length); createSkinningMatrices(); for (Bone rootBone : rootBones) { rootBone.update(); rootBone.setBindingPose(); } }
@Override public void read(JmeImporter im) throws IOException { InputCapsule input = im.getCapsule(this); Savable[] boneRootsAsSav = input.readSavableArray("rootBones", null); rootBones = new Bone[boneRootsAsSav.length]; System.arraycopy(boneRootsAsSav, 0, rootBones, 0, boneRootsAsSav.length); Savable[] boneListAsSavable = input.readSavableArray("boneList", null); boneList = new Bone[boneListAsSavable.length]; System.arraycopy(boneListAsSavable, 0, boneList, 0, boneListAsSavable.length); createSkinningMatrices(); for (Bone rootBone : rootBones) { rootBone.reset(); rootBone.update(); rootBone.setBindingPose(); } }
/** * Special-purpose copy constructor. * <p> * Shallow copies bind pose data from the source skeleton, does not * copy any other data. * * @param source The source Skeleton to copy from */ public Skeleton(Skeleton source) { Bone[] sourceList = source.boneList; boneList = new Bone[sourceList.length]; for (int i = 0; i < sourceList.length; i++) { boneList[i] = new Bone(sourceList[i]); } rootBones = new Bone[source.rootBones.length]; for (int i = 0; i < rootBones.length; i++) { rootBones[i] = recreateBoneStructure(source.rootBones[i]); } createSkinningMatrices(); for (int i = rootBones.length - 1; i >= 0; i--) { rootBones[i].update(); } }
/** * Special-purpose copy constructor. * <p> * Shallow copies bind pose data from the source skeleton, does not * copy any other data. * * @param source The source Skeleton to copy from */ public Skeleton(Skeleton source) { Bone[] sourceList = source.boneList; boneList = new Bone[sourceList.length]; for (int i = 0; i < sourceList.length; i++) { boneList[i] = new Bone(sourceList[i]); } rootBones = new Bone[source.rootBones.length]; for (int i = 0; i < rootBones.length; i++) { rootBones[i] = recreateBoneStructure(source.rootBones[i]); } createSkinningMatrices(); for (int i = rootBones.length - 1; i >= 0; i--) { rootBones[i].update(); } }