Skip to content

Commit fe65e0d

Browse files
authored
Update ArmatureDebugger: code cleanup
1 parent 4650463 commit fe65e0d

File tree

1 file changed

+37
-27
lines changed

1 file changed

+37
-27
lines changed

jme3-core/src/main/java/com/jme3/scene/debug/custom/ArmatureDebugger.java

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -127,18 +127,16 @@ public ArmatureDebugger(String name, Armature armature, List<Joint> deformingJoi
127127
this.attachChild(wires);
128128

129129
// Create child nodes specifically for non-deforming joints' visualization
130-
Node ndJoints = new Node("NonDeformingJoints");
131-
Node ndOutlines = new Node("NonDeformingOutlines");
132-
Node ndWires = new Node("NonDeformingWires");
133-
joints.attachChild(ndJoints);
134-
outlines.attachChild(ndOutlines);
135-
wires.attachChild(ndWires);
130+
joints.attachChild(new Node("NonDeformingJoints"));
131+
outlines.attachChild(new Node("NonDeformingOutlines"));
132+
wires.attachChild(new Node("NonDeformingWires"));
136133

137134
Node outlineDashed = new Node("DashedOutlines");
138-
Node wiresDashed = new Node("DashedWires");
139-
wiresDashed.attachChild(new Node("DashedNonDeformingWires"));
140135
outlineDashed.attachChild(new Node("DashedNonDeformingOutlines"));
141136
outlines.attachChild(outlineDashed);
137+
138+
Node wiresDashed = new Node("DashedWires");
139+
wiresDashed.attachChild(new Node("DashedNonDeformingWires"));
142140
wires.attachChild(wiresDashed);
143141

144142
// Initialize the core ArmatureNode which handles the actual mesh generation.
@@ -178,36 +176,48 @@ public void initialize(AssetManager assetManager, Camera camera) {
178176

179177
armatureNode.setCamera(camera);
180178

181-
// Material for joint points (billboarded dots).
182-
Material matJoints = new Material(assetManager, "Common/MatDefs/Misc/Billboard.j3md");
183-
Texture tex = assetManager.loadTexture("Common/Textures/dot.png");
184-
matJoints.setTexture("Texture", tex);
185-
matJoints.getAdditionalRenderState().setDepthTest(false);
186-
matJoints.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
179+
// Material for joint points (billboard dots).
180+
Material matJoints = getJointMaterial(assetManager);
187181
joints.setQueueBucket(RenderQueue.Bucket.Translucent);
188182
joints.setMaterial(matJoints);
189183

190184
// Material for bone wires/lines (unshaded, vertex colored).
191-
Material matWires = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
192-
matWires.setBoolean("VertexColor", true);
193-
matWires.getAdditionalRenderState().setDepthTest(false);
185+
Material matWires = getUnshadedMaterial(assetManager);
194186
wires.setMaterial(matWires);
195187

188+
// Material for dashed wires ("DashedLine.j3md" shader).
189+
Material matWires2 = getDashedMaterial(assetManager);
190+
wires.getChild(1).setMaterial(matWires2);
191+
196192
// Material for bone outlines (unshaded, vertex colored).
197-
Material matOutline = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
198-
matOutline.setBoolean("VertexColor", true);
199-
matOutline.getAdditionalRenderState().setDepthTest(false);
193+
Material matOutline = getUnshadedMaterial(assetManager);
200194
outlines.setMaterial(matOutline);
201195

202-
// Material for dashed outlines. This assumes a "DashedLine.j3md" shader.
203-
Material matOutline2 = new Material(assetManager, "Common/MatDefs/Misc/DashedLine.j3md");
204-
matOutline2.getAdditionalRenderState().setDepthTest(false);
196+
// Material for dashed outlines ("DashedLine.j3md" shader).
197+
Material matOutline2 = getDashedMaterial(assetManager);
205198
outlines.getChild(1).setMaterial(matOutline2);
199+
}
206200

207-
// Material for dashed wires. This assumes a "DashedLine.j3md" shader.
208-
Material matWires2 = new Material(assetManager, "Common/MatDefs/Misc/DashedLine.j3md");
209-
matWires2.getAdditionalRenderState().setDepthTest(false);
210-
wires.getChild(1).setMaterial(matWires2);
201+
private Material getJointMaterial(AssetManager asm) {
202+
Material mat = new Material(asm, "Common/MatDefs/Misc/Billboard.j3md");
203+
Texture tex = asm.loadTexture("Common/Textures/dot.png");
204+
mat.setTexture("Texture", tex);
205+
mat.getAdditionalRenderState().setDepthTest(false);
206+
mat.getAdditionalRenderState().setBlendMode(RenderState.BlendMode.Alpha);
207+
return mat;
208+
}
209+
210+
private Material getUnshadedMaterial(AssetManager asm) {
211+
Material mat = new Material(asm, "Common/MatDefs/Misc/Unshaded.j3md");
212+
mat.setBoolean("VertexColor", true);
213+
mat.getAdditionalRenderState().setDepthTest(false);
214+
return mat;
215+
}
216+
217+
private Material getDashedMaterial(AssetManager asm) {
218+
Material mat = new Material(asm, "Common/MatDefs/Misc/DashedLine.j3md");
219+
mat.getAdditionalRenderState().setDepthTest(false);
220+
return mat;
211221
}
212222

213223
/**

0 commit comments

Comments
 (0)