* the Renderer to draw with.
*/
private static void drawBone(final Transform start, final Transform end, final Spatial scene,
final Renderer renderer) {
// Determine our start and end points
final Vector3 stPnt = Vector3.fetchTempInstance();
final Vector3 endPnt = Vector3.fetchTempInstance();
start.applyForward(Vector3.ZERO, stPnt);
end.applyForward(Vector3.ZERO, endPnt);
// determine distance and use as a scale to elongate the bone
double scale = stPnt.distance(endPnt);
if (scale == 0) {
scale = MathUtils.ZERO_TOLERANCE;
}
final BoundingVolume vol = scene.getWorldBound();
double size = 1.0;
if (vol != null) {
SkeletalDebugger.measureSphere.setCenter(vol.getCenter());
SkeletalDebugger.measureSphere.setRadius(0);
SkeletalDebugger.measureSphere.mergeLocal(vol);
size = SkeletalDebugger.BONE_RATIO * SkeletalDebugger.measureSphere.getRadius();
}
SkeletalDebugger.bone.setWorldTransform(Transform.IDENTITY);
SkeletalDebugger.bone.setWorldScale(size, size, scale);
// determine center point of bone (translation).
final Vector3 store = Vector3.fetchTempInstance();
SkeletalDebugger.bone.setWorldTranslation(stPnt.add(endPnt, store).divideLocal(2.0));
Vector3.releaseTempInstance(store);
// Orient bone to point along axis formed by start and end points.
final Matrix3 orient = Matrix3.fetchTempInstance();