Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 29 additions & 3 deletions jme3-core/src/main/java/com/jme3/scene/debug/SkeletonDebugger.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,14 @@
package com.jme3.scene.debug;

import com.jme3.animation.Skeleton;
import com.jme3.export.JmeImporter;
import com.jme3.renderer.queue.RenderQueue.Bucket;
import com.jme3.scene.Geometry;
import com.jme3.scene.Mesh;
import com.jme3.scene.Node;
import com.jme3.util.clone.Cloner;

import java.io.IOException;
import java.util.Map;

/**
Expand Down Expand Up @@ -83,16 +86,20 @@ public SkeletonDebugger(String name, Skeleton skeleton, Map<Integer, Float> bone
wires = new SkeletonWire(skeleton, boneLengths);
points = new SkeletonPoints(skeleton, boneLengths);

this.attachChild(new Geometry(name + "_wires", wires));
this.attachChild(new Geometry(name + "_points", points));
this.attachChild(new Geometry(getGeometryName("_wires"), wires));
this.attachChild(new Geometry(getGeometryName("_points"), points));
if (boneLengths != null) {
interBoneWires = new SkeletonInterBoneWire(skeleton, boneLengths);
this.attachChild(new Geometry(name + "_interwires", interBoneWires));
this.attachChild(new Geometry(getGeometryName("_interwires"), interBoneWires));
}

this.setQueueBucket(Bucket.Transparent);
}

private String getGeometryName(String suffix) {
return name + suffix;
}

@Override
public void updateLogicalState(float tpf) {
super.updateLogicalState(tpf);
Expand Down Expand Up @@ -132,4 +139,23 @@ public void cloneFields(Cloner cloner, Object original) {
this.points = cloner.clone(points);
this.interBoneWires = cloner.clone(interBoneWires);
}

@Override
public void read(JmeImporter importer) throws IOException {
super.read(importer);

// Find our stuff
wires = getMesh("_wires");
points = getMesh("_points");
interBoneWires = getMesh("_interwires");
}

private <T extends Mesh> T getMesh(String suffix) {
Geometry child = (Geometry)getChild(getGeometryName(suffix));
if(child != null) {
return (T) child.getMesh();
}

return null;
}
}