skelegons ?

Issue #2254 invalid
Alessandro Padovani created an issue

I come from Lightwave, an amazing software at the time. One feature was skelegons, that's basically a mesh template for the armature, that I could edit with the modeler tools, then generate the armature itself.

A metarig in blender is not the same thing, because we can't edit the metarig as a mesh. For example skelegons would allow to use a deform modifier to make the skelegon follow a mesh morph, then make the armature follow the skelegon. This is similar to what daz studio does with autofit when fitting the rig to a figure morph.

skelegon usage:

  1. import a daz figure
  2. edit the figure as desired to create a morph in blender
  3. generate a skelegon from the figure armature
  4. apply a surface modifier to the skelegon to follow the new morph
  5. make the armature follow the skelegon

Below there's the two functions to generate a skelegon, and to fit the armature to the skelegon. These may be nice tools to have in the rigging module.

p.s. The code is simple, I know very little of python and the blender api, so probably it can be improved.

import bpy
from mathutils import Vector

# convert vector to list
def to_list(vec):
    return [vec.x,vec.y,vec.z]

# create skelegon from active armature
def skelegon():

    # copy skelegon from edit bones
    bpy.ops.object.editmode_toggle()

    verts = []
    edges = []
    idx = 0
    for bone in bpy.context.object.data.edit_bones:
        verts.append(to_list(bone.head))
        verts.append(to_list(bone.tail))
        edges.append([idx,idx+1])
        idx += 2

    bpy.ops.object.editmode_toggle()

    # create skelegon
    mesh = bpy.data.meshes.new('skelegon_mesh')
    mesh.from_pydata(verts,edges,[])
    obj = bpy.data.objects.new('skelegon',mesh)
    bpy.context.scene.collection.objects.link(obj)

# fit active armature to selected skelegon
def autofit():

    # copy skelegon to edit bones
    bpy.ops.object.editmode_toggle()

    verts = []
    for v in bpy.context.selected_objects[1].data.vertices:
        verts.append([v.co.x,v.co.y,v.co.z])

    idx = 0
    for bone in bpy.context.object.data.edit_bones:
        bone.head = Vector(verts[idx])
        bone.tail = Vector(verts[idx+1])
        idx += 2

    bpy.ops.object.editmode_toggle()

Comments (2)

  1. Thomas Larsson repo owner

    This seems like a generic tool which is not specific to daz figures. Since this plugin is already overloaded, I think it would fit better as a separate addon.

  2. Log in to comment