Add skin modifier: DNA, RNA, UI, and MOD_skin.c implementation.

Skin modifier documentation:
http://wiki.blender.org/index.php/User:Nicholasbishop/SkinModifier

Implementation based in part off the paper "B-Mesh: A Fast Modeling
System for Base Meshes of 3D Articulated Shapes" (Zhongping Ji,
Ligang Liu, Yigang Wang)

Note that to avoid confusion with Blender's BMesh data structure,
this tool is renamed as the Skin modifier.

The B-Mesh paper is current available here:
http://www.math.zju.edu.cn/ligangliu/CAGD/Projects/BMesh/

The main missing features in this code compared to the paper are:

* No mesh evolution. The paper suggests iteratively subsurfing the
  skin output and adapting the output to better conform with the
  spheres of influence surrounding each vertex.

* No mesh fairing. The paper suggests re-aligning output edges to
  follow principal mesh curvatures.

* No auxiliary balls. These would serve to influence mesh
  evolution, which as noted above is not implemented.

The code also adds some features not present in the paper:

* Loops in the input edge graph.

* Concave surfaces around branch nodes. The paper does not discuss
  how to handle non-convex regions; this code adds a number of
  cleanup operations to handle many (though not all) of these
  cases.
This commit is contained in:
Nicholas Bishop 2012-05-22 15:29:01 +00:00
parent f7b116e0bd
commit 8801330c18
8 changed files with 1949 additions and 0 deletions

@ -959,5 +959,29 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
layout.separator()
self.vertex_weight_mask(layout, ob, md)
def SKIN(self, layout, ob, md):
layout.operator("object.skin_armature_create", text="Create Armature")
layout.separator()
layout.prop(md, "branch_smoothing")
layout.prop(md, "use_smooth_shade")
layout.label(text="Selected Vertices:")
split = layout.split()
col = split.column(align=True)
col.operator("object.skin_loose_mark_clear", text="Mark Loose").action = "MARK"
col.operator("object.skin_loose_mark_clear", text="Clear Loose").action = "CLEAR"
col = split.column()
col.operator("object.skin_root_mark", text="Mark Root")
col.operator("object.skin_radii_equalize", text="Equalize Radii")
layout.label(text="Symmetry Axes:")
col = layout.column()
col.prop(md, "use_x_symmetry")
col.prop(md, "use_y_symmetry")
col.prop(md, "use_z_symmetry")
if __name__ == "__main__": # only for live edit.
bpy.utils.register_module(__name__)

@ -77,6 +77,7 @@ typedef enum ModifierType {
eModifierType_Ocean,
eModifierType_DynamicPaint,
eModifierType_Remesh,
eModifierType_Skin,
NUM_MODIFIER_TYPES
} ModifierType;
@ -1065,4 +1066,30 @@ typedef struct RemeshModifierData {
char pad;
} RemeshModifierData;
/* Skin modifier */
typedef struct SkinModifierData {
ModifierData modifier;
float branch_smoothing;
char flag;
char symmetry_axes;
char pad[2];
} SkinModifierData;
/* SkinModifierData.symmetry_axes */
enum {
MOD_SKIN_SYMM_X = 1,
MOD_SKIN_SYMM_Y = 2,
MOD_SKIN_SYMM_Z = 4,
};
/* SkinModifierData.flag */
enum {
MOD_SKIN_SMOOTH_SHADING = 1
};
#endif

@ -466,6 +466,7 @@ extern StructRNA RNA_ShapeKeyPoint;
extern StructRNA RNA_ShrinkwrapConstraint;
extern StructRNA RNA_ShrinkwrapModifier;
extern StructRNA RNA_SimpleDeformModifier;
extern StructRNA RNA_SkinModifier;
extern StructRNA RNA_SmokeCollSettings;
extern StructRNA RNA_SmokeDomainSettings;
extern StructRNA RNA_SmokeFlowSettings;

@ -75,6 +75,7 @@ EnumPropertyItem modifier_type_items[] = {
{eModifierType_Multires, "MULTIRES", ICON_MOD_MULTIRES, "Multiresolution", ""},
{eModifierType_Remesh, "REMESH", ICON_MOD_REMESH, "Remesh", ""},
{eModifierType_Screw, "SCREW", ICON_MOD_SCREW, "Screw", ""},
{eModifierType_Skin, "SKIN", ICON_MOD_SKIN, "Skin", ""},
{eModifierType_Solidify, "SOLIDIFY", ICON_MOD_SOLIDIFY, "Solidify", ""},
{eModifierType_Subsurf, "SUBSURF", ICON_MOD_SUBSURF, "Subdivision Surface", ""},
{0, "", 0, N_("Deform"), ""},
@ -207,6 +208,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA *ptr)
return &RNA_DynamicPaintModifier;
case eModifierType_Remesh:
return &RNA_RemeshModifier;
case eModifierType_Skin:
return &RNA_SkinModifier;
default:
return &RNA_Modifier;
}
@ -3196,6 +3199,42 @@ static void rna_def_modifier_ocean(BlenderRNA *brna)
/* XXX how to update? */
}
static void rna_def_modifier_skin(BlenderRNA *brna)
{
StructRNA *srna;
PropertyRNA *prop;
srna= RNA_def_struct(brna, "SkinModifier", "Modifier");
RNA_def_struct_ui_text(srna, "Skin Modifier", "Generate Skin");
RNA_def_struct_sdna(srna, "SkinModifierData");
RNA_def_struct_ui_icon(srna, ICON_MOD_SKIN);
prop = RNA_def_property(srna, "branch_smoothing", PROP_FLOAT, PROP_NONE);
RNA_def_property_ui_text(prop, "Branch Smoothing", "Smooth complex geometry around branches");
RNA_def_property_ui_range(prop, 0, 1, 1, 0);
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_smooth_shade", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", MOD_SKIN_SMOOTH_SHADING);
RNA_def_property_ui_text(prop, "Smooth Shading", "Output faces with smooth shading rather than flat shaded");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_x_symmetry", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_X);
RNA_def_property_ui_text(prop, "X", "Avoid making unsymmetric quads across the X axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_y_symmetry", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Y);
RNA_def_property_ui_text(prop, "Y", "Avoid making unsymmetric quads across the Y axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
prop = RNA_def_property(srna, "use_z_symmetry", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "symmetry_axes", MOD_SKIN_SYMM_Z);
RNA_def_property_ui_text(prop, "Z", "Avoid making unsymmetric quads across the Z axis");
RNA_def_property_update(prop, 0, "rna_Modifier_update");
}
void RNA_def_modifier(BlenderRNA *brna)
{
StructRNA *srna;
@ -3301,6 +3340,7 @@ void RNA_def_modifier(BlenderRNA *brna)
rna_def_modifier_dynamic_paint(brna);
rna_def_modifier_ocean(brna);
rna_def_modifier_remesh(brna);
rna_def_modifier_skin(brna);
}
#endif

@ -77,6 +77,7 @@ set(SRC
intern/MOD_shapekey.c
intern/MOD_shrinkwrap.c
intern/MOD_simpledeform.c
intern/MOD_skin.c
intern/MOD_smoke.c
intern/MOD_smooth.c
intern/MOD_softbody.c

@ -74,6 +74,7 @@ extern ModifierTypeInfo modifierType_WeightVGMix;
extern ModifierTypeInfo modifierType_WeightVGProximity;
extern ModifierTypeInfo modifierType_DynamicPaint;
extern ModifierTypeInfo modifierType_Remesh;
extern ModifierTypeInfo modifierType_Skin;
/* MOD_util.c */
void modifier_type_init(ModifierTypeInfo *types[]);

File diff suppressed because it is too large Load Diff

@ -276,5 +276,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
INIT_TYPE(WeightVGProximity);
INIT_TYPE(DynamicPaint);
INIT_TYPE(Remesh);
INIT_TYPE(Skin);
#undef INIT_TYPE
}