Skip to content

Commit

Permalink
SkeletonMapping: add 2 more constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Sep 5, 2023
1 parent 254bcf0 commit 744b1e3
Showing 1 changed file with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.jme3.scene.plugins.bvh;

import com.jme3.anim.Armature;
import com.jme3.anim.Joint;
import com.jme3.animation.Bone;
import com.jme3.animation.Skeleton;
import com.jme3.export.InputCapsule;
import com.jme3.export.JmeExporter;
import com.jme3.export.JmeImporter;
Expand Down Expand Up @@ -46,6 +50,37 @@ public class SkeletonMapping implements Cloneable, Savable {
public SkeletonMapping() {
// do nothing
}

/**
* Construct a one-to-one mapping for the specified Armature.
*
* @param armature the Armature to provide the joint names (not null,
* unaffected)
*/
public SkeletonMapping(Armature armature) {
List<Joint> jointList = armature.getJointList();
for (Joint joint : jointList) {
String name = joint.getName();
BoneMapping boneMapping = new BoneMapping(name, name);
addMapping(boneMapping);
}
}

/**
* Construct a one-to-one mapping for the specified Skeleton.
*
* @param skeleton the Skeleton to provide the bone names (not null,
* unaffected)
*/
public SkeletonMapping(Skeleton skeleton) {
int boneCount = skeleton.getBoneCount();
for (int boneIndex = 0; boneIndex < boneCount; ++boneIndex) {
Bone bone = skeleton.getBone(boneIndex);
String name = bone.getName();
BoneMapping boneMapping = new BoneMapping(name, name);
addMapping(boneMapping);
}
}
// *************************************************************************
// new methods exposed

Expand Down

0 comments on commit 744b1e3

Please sign in to comment.