Skip to content

Commit

Permalink
Describer: add methods to describe armatures and joints
Browse files Browse the repository at this point in the history
  • Loading branch information
stephengold committed Nov 24, 2023
1 parent 484b5c5 commit 6bfa142
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions HeartLibrary/src/main/java/jme3utilities/debug/Describer.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
*/
package jme3utilities.debug;

import com.jme3.anim.Armature;
import com.jme3.anim.Joint;
import com.jme3.animation.Bone;
import com.jme3.animation.Skeleton;
import com.jme3.app.state.ScreenshotAppState;
Expand Down Expand Up @@ -122,6 +124,25 @@ public Describer() {
// *************************************************************************
// new methods exposed

/**
* Generate a compact, textual description of the specified Armature, not
* including its joints.
*
* @param armature the Armature to describe (not null, unaffected)
* @return a description (not null, not empty)
*/
public String describe(Armature armature) {
Validate.nonNull(armature, "armature");

int numRoots = MySkeleton.countRootJoints(armature);
int numJoints = armature.getJointCount();
String result = String.format("Armature with %d root%s and %d joint%s:",
numRoots, numRoots == 1 ? "" : "s",
numJoints, numJoints == 1 ? "" : "s");

return result;
}

/**
* Generate a compact, textual description of the specified Bone, not
* including its children.
Expand Down Expand Up @@ -219,6 +240,33 @@ public String describe(BoundingVolume boundingVolume) {
return result;
}

/**
* Generate a compact, textual description of the specified Joint, not
* including its children.
*
* @param joint the Joint to describe (not null, unaffected)
* @return a description (not null, not empty)
*/
public String describe(Joint joint) {
StringBuilder builder = new StringBuilder(30);
String nameText = MyString.quote(joint.getName());
builder.append(nameText);

if (MySkeleton.getAttachments(joint) != null) {
builder.append(" A");
}

List<Joint> children = joint.getChildren();
if (!children.isEmpty()) {
int numChildren = children.size();
String childText = String.format(" with %d child%s:", numChildren,
(numChildren == 1 ? "" : "ren"));
builder.append(childText);
}

return builder.toString();
}

/**
* Generate a compact, textual description of the specified Material, not
* including its parameters.
Expand Down

0 comments on commit 6bfa142

Please sign in to comment.