| @@ -221,6 +221,28 @@ class MVAssignMaterials(bpy.types.Operator): | |||||
| bm.free() | bm.free() | ||||
| print("OK") | print("OK") | ||||
| bpy.ops.object.mode_set(mode = 'OBJECT') | bpy.ops.object.mode_set(mode = 'OBJECT') | ||||
| elif context.scene.mv_material_mode == 'OBJECT_NAMES': | |||||
| while len(object.material_slots) > 0: | |||||
| bpy.ops.object.material_slot_remove({'object': object}) | |||||
| light_choices = context.scene.mv_material_names_light.split(",") | |||||
| medium_choices = context.scene.mv_material_names_medium.split(",") | |||||
| bpy.ops.object.material_slot_add({'object': object}) | |||||
| missing_idx = len(object.material_slots) - 1 | |||||
| chosen = 'dark' | |||||
| if any([choice in object.name for choice in medium_choices]): | |||||
| chosen = 'medium' | |||||
| if any([choice in object.name for choice in light_choices]): | |||||
| chosen = 'light' | |||||
| object.material_slots[0].material = bpy.data.materials[chosen] | |||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| @@ -82,7 +82,8 @@ scene_props["mv_material_mode"] = bpy.props.EnumProperty( | |||||
| items = ( | items = ( | ||||
| ('RANDOM', "Random", 'Randomly assign materials'), | ('RANDOM', "Random", 'Randomly assign materials'), | ||||
| ('NAMES', "Names", 'Turn the specified names medium or light; the rest become dark'), | ('NAMES', "Names", 'Turn the specified names medium or light; the rest become dark'), | ||||
| ('FACE_MAPS', "Face Maps", "Assign a material for each face map") | |||||
| ('FACE_MAPS', "Face Maps", "Assign a material for each face map"), | |||||
| ('OBJECT_NAMES', "Object Names", "Same as Names, but with object names, not material names") | |||||
| ), | ), | ||||
| ) | ) | ||||
| @@ -64,7 +64,7 @@ class MVScenePanel(bpy.types.Panel): | |||||
| box.prop(context.scene, "mv_material_mode") | box.prop(context.scene, "mv_material_mode") | ||||
| if context.scene.mv_material_mode in ('NAMES', 'FACE_MAPS'): | |||||
| if context.scene.mv_material_mode in ('NAMES', 'FACE_MAPS', 'OBJECT_NAMES'): | |||||
| box.prop(context.scene, "mv_material_names_light") | box.prop(context.scene, "mv_material_names_light") | ||||
| box.prop(context.scene, "mv_material_names_medium") | box.prop(context.scene, "mv_material_names_medium") | ||||
| @@ -5,20 +5,25 @@ var layers = doc.layers; | |||||
| var traces = [] | var traces = [] | ||||
| settings = [ | settings = [ | ||||
| { | |||||
| name: "Bright", | |||||
| color: 0x66, | |||||
| threshold: 128 | |||||
| }, | |||||
| { | { | ||||
| name: "Light", | name: "Light", | ||||
| color: 0x4d, | color: 0x4d, | ||||
| threshold: 128 | |||||
| threshold: 96 | |||||
| }, | }, | ||||
| { | { | ||||
| name: "Medium", | name: "Medium", | ||||
| color: 0x33, | color: 0x33, | ||||
| threshold: 96 | |||||
| threshold: 64 | |||||
| }, | }, | ||||
| { | { | ||||
| name: "Dark", | name: "Dark", | ||||
| color: 0x1a, | color: 0x1a, | ||||
| threshold: 64 | |||||
| threshold: 32 | |||||
| }, | }, | ||||
| { | { | ||||
| name: "Black", | name: "Black", | ||||