Brushstroke Tools: Initial Version #328
Binary file not shown.
@ -140,7 +140,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
for mod in brushstrokes_object.modifiers:
|
for mod in brushstrokes_object.modifiers:
|
||||||
mod.show_group_selector = False
|
mod.show_group_selector = False
|
||||||
|
|
||||||
'''# enter mode and tool context
|
# enter mode and tool context
|
||||||
|
|
||||||
if settings.curve_mode == 'GP':
|
if settings.curve_mode == 'GP':
|
||||||
bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL')
|
bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL')
|
||||||
@ -149,7 +149,7 @@ class BSBST_OT_new_brushstrokes(bpy.types.Operator):
|
|||||||
else:
|
else:
|
||||||
bpy.ops.object.mode_set(mode='EDIT')
|
bpy.ops.object.mode_set(mode='EDIT')
|
||||||
bpy.ops.wm.tool_set_by_id(name="brushstroke_tools.draw")
|
bpy.ops.wm.tool_set_by_id(name="brushstroke_tools.draw")
|
||||||
'''
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
class BSBST_OT_init_preset(bpy.types.Operator):
|
class BSBST_OT_init_preset(bpy.types.Operator):
|
||||||
@ -166,17 +166,46 @@ class BSBST_OT_init_preset(bpy.types.Operator):
|
|||||||
settings = context.scene.BSBST_settings
|
settings = context.scene.BSBST_settings
|
||||||
return settings.preset_object is None
|
return settings.preset_object is None
|
||||||
|
|
||||||
def execute(self, context):
|
def init_fill(self, context):
|
||||||
|
|
||||||
settings = context.scene.BSBST_settings
|
settings = context.scene.BSBST_settings
|
||||||
|
|
||||||
utils.ensure_resources()
|
preset_object = settings.preset_object
|
||||||
preset_name = f'BSBST-PRESET_{settings.brushstroke_method}'
|
|
||||||
preset_object = bpy.data.objects.new(preset_name, bpy.data.hair_curves.new(preset_name))
|
|
||||||
settings.preset_object = preset_object
|
|
||||||
|
|
||||||
# add modifiers
|
# add modifiers
|
||||||
mod = preset_object.modifiers.new('Brushstrokes Deformation', 'NODES')
|
## input
|
||||||
|
mod = preset_object.modifiers.new('Input', 'NODES')
|
||||||
|
mod.node_group = bpy.data.node_groups['.brushstroke_tools.geometry_input']
|
||||||
|
|
||||||
|
mod_info = settings.preset_object.modifier_info.get(mod.name)
|
||||||
|
if not mod_info:
|
||||||
|
mod_info = settings.preset_object.modifier_info.add()
|
||||||
|
mod_info.name = mod.name
|
||||||
|
|
||||||
|
socket_info = mod_info.socket_info.get('Socket_2')
|
||||||
|
if not socket_info:
|
||||||
|
socket_info = mod_info.socket_info.add()
|
||||||
|
socket_info.name = 'Socket_2'
|
||||||
|
socket_info.link_context = True
|
||||||
|
|
||||||
|
## brushstrokes
|
||||||
|
mod = preset_object.modifiers.new('Brushstrokes', 'NODES')
|
||||||
|
mod.node_group = bpy.data.node_groups['.brushstroke_tools.surface_fill']
|
||||||
|
|
||||||
|
mod_info = settings.preset_object.modifier_info.get(mod.name)
|
||||||
|
if not mod_info:
|
||||||
|
mod_info = settings.preset_object.modifier_info.add()
|
||||||
|
mod_info.name = mod.name
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def init_draw(self, context):
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
|
||||||
|
preset_object = settings.preset_object
|
||||||
|
|
||||||
|
# add modifiers
|
||||||
|
## deformation
|
||||||
|
mod = preset_object.modifiers.new('Deformation', 'NODES')
|
||||||
mod.node_group = bpy.data.node_groups['.brushstroke_tools.deformation']
|
mod.node_group = bpy.data.node_groups['.brushstroke_tools.deformation']
|
||||||
|
|
||||||
mod_info = settings.preset_object.modifier_info.get(mod.name)
|
mod_info = settings.preset_object.modifier_info.get(mod.name)
|
||||||
@ -190,6 +219,37 @@ class BSBST_OT_init_preset(bpy.types.Operator):
|
|||||||
socket_info.name = 'Socket_2'
|
socket_info.name = 'Socket_2'
|
||||||
socket_info.link_context = True
|
socket_info.link_context = True
|
||||||
|
|
||||||
|
## brushstrokes
|
||||||
|
mod = preset_object.modifiers.new('Brushstrokes', 'NODES')
|
||||||
|
mod.node_group = bpy.data.node_groups['.brushstroke_tools.surface_draw']
|
||||||
|
|
||||||
|
mod_info = settings.preset_object.modifier_info.get(mod.name)
|
||||||
|
if not mod_info:
|
||||||
|
mod_info = settings.preset_object.modifier_info.add()
|
||||||
|
mod_info.name = mod.name
|
||||||
|
|
||||||
|
socket_info = mod_info.socket_info.get('Socket_2')
|
||||||
|
if not socket_info:
|
||||||
|
socket_info = mod_info.socket_info.add()
|
||||||
|
socket_info.name = 'Socket_2'
|
||||||
|
socket_info.link_context = True
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
|
||||||
|
settings = context.scene.BSBST_settings
|
||||||
|
|
||||||
|
utils.ensure_resources()
|
||||||
|
preset_name = f'BSBST-PRESET_{settings.brushstroke_method}'
|
||||||
|
preset_object = bpy.data.objects.new(preset_name, bpy.data.hair_curves.new(preset_name))
|
||||||
|
settings.preset_object = preset_object
|
||||||
|
|
||||||
|
if settings.brushstroke_method == "SURFACE_FILL":
|
||||||
|
self.init_fill(context)
|
||||||
|
elif settings.brushstroke_method == "SURFACE_DRAW":
|
||||||
|
self.init_draw(context)
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
class BSBST_OT_make_preset(bpy.types.Operator):
|
class BSBST_OT_make_preset(bpy.types.Operator):
|
||||||
|
@ -2,7 +2,12 @@ import os
|
|||||||
import bpy
|
import bpy
|
||||||
from bpy.app.handlers import persistent
|
from bpy.app.handlers import persistent
|
||||||
|
|
||||||
ng_list = [".brushstroke_tools.processing", ".brushstroke_tools.deformation"]
|
ng_list = [ ".brushstroke_tools.processing",
|
||||||
|
".brushstroke_tools.deformation",
|
||||||
|
".brushstroke_tools.surface_fill",
|
||||||
|
".brushstroke_tools.surface_draw",
|
||||||
|
".brushstroke_tools.geometry_input",
|
||||||
|
]
|
||||||
|
|
||||||
linkable_sockets = [bpy.types.NodeTreeInterfaceSocketObject, bpy.types.NodeTreeInterfaceSocketMaterial]
|
linkable_sockets = [bpy.types.NodeTreeInterfaceSocketObject, bpy.types.NodeTreeInterfaceSocketMaterial]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user