Не подтверждена Коммит dc5a2bb8 создал по автору Ilya V. Portnov's avatar Ilya V. Portnov Зафиксировано автором GitHub
Просмотр файлов

Merge pull request #1957 from nortikin/color_input_node

Color input node
владельцы 8ef515fa fe4d9757
Color Input
===========
Functionality
-------------
This node allows you to specify color by using a colorpicker widget. In a sense, this is an analog of "Matrix Input" or "List Input" nodes, but for colors.
Inputs
------
This node does not have any inputs.
Parameters
----------
This node has the following parameters:
* **Color**. Edited by using standard Blender's color picking widget.
* **Use Alpha**. If checked, then this node outputs 4-vector (R, G, B, A). Otherwise, it outputs 3-vector (R, G, B). By default this is not checked.
* **To 3D Panel**. If checked, then this node is recognized and collected as node tree parameter when you press "Scan for props" in Sverchok's T panel in the 3D View. By default this is checked. This parameter is only available in the N panel.
Outputs
-------
This node has only one output: **Color**. It is RGB or RGBA vector, depending on **Use Alpha** parameter.
Examples
--------
.. image:: https://user-images.githubusercontent.com/284644/36633499-b5b7108a-19b8-11e8-8e39-243d9dd42e7e.png
...@@ -279,6 +279,7 @@ ...@@ -279,6 +279,7 @@
SvSubdivideLiteNode SvSubdivideLiteNode
--- ---
SvColorsInNodeMK1 SvColorsInNodeMK1
SvColorInputNode
SvColorsOutNodeMK1 SvColorsOutNodeMK1
--- ---
SvMatrixNormalNode SvMatrixNormalNode
......
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
import colorsys
import bpy
from bpy.props import FloatProperty, BoolProperty, FloatVectorProperty
from sverchok.node_tree import SverchCustomTreeNode, StringsSocket
from sverchok.data_structure import updateNode, fullList
from sverchok.utils.sv_itertools import sv_zip_longest
class SvColorInputNode(bpy.types.Node, SverchCustomTreeNode):
"""
Triggers: Color Input
Tooltip: Specify color using color picker
"""
bl_idname = "SvColorInputNode"
bl_label = "Color Input"
bl_icon = "COLOR"
use_alpha = BoolProperty(name = "Use Alpha", default=False, update=updateNode)
color_data = FloatVectorProperty(name = "Color",
description = "Color",
size = 4, min=0.0, max=1.0, subtype='COLOR',
update=updateNode)
to3d = BoolProperty(name = "To 3D Panel",
description = "Show this node in 3D panel",
default=True, update=updateNode)
def sv_init(self, context):
self.outputs.new("SvColorSocket", "Color")
def draw_buttons(self, context, layout):
layout.template_color_picker(self, "color_data", value_slider=True)
layout.prop(self, "color_data", text='')
layout.prop(self, "use_alpha")
def draw_buttons_ext(self, context, layout):
self.draw_buttons(context, layout)
layout.prop(self, "to3d")
def process(self):
if self.use_alpha:
color = self.color_data[:]
else:
color = self.color_data[:3]
self.outputs['Color'].sv_set([color])
def register():
bpy.utils.register_class(SvColorInputNode)
def unregister():
bpy.utils.unregister_class(SvColorInputNode)
...@@ -237,6 +237,11 @@ class Sv3DPanel(bpy.types.Panel): ...@@ -237,6 +237,11 @@ class Sv3DPanel(bpy.types.Panel):
colo.prop(node, min_name, text='', slider=True, emboss=False) colo.prop(node, min_name, text='', slider=True, emboss=False)
colo.prop(node, max_name, text='', slider=True, emboss=False) colo.prop(node, max_name, text='', slider=True, emboss=False)
elif node.bl_idname in {'SvColorInputNode'}:
col.label(tex)
col.template_color_picker(node, ver, value_slider=True)
col.prop(node, ver, text='')
elif node.bl_idname in {"SvListInputNode"}: elif node.bl_idname in {"SvListInputNode"}:
if node.mode == 'vector': if node.mode == 'vector':
colum_list = col.column(align=True) colum_list = col.column(align=True)
......
...@@ -23,6 +23,7 @@ from bpy.props import StringProperty, CollectionProperty, BoolProperty ...@@ -23,6 +23,7 @@ from bpy.props import StringProperty, CollectionProperty, BoolProperty
from sverchok.core.update_system import process_tree, build_update_list from sverchok.core.update_system import process_tree, build_update_list
from sverchok.node_tree import SverchCustomTreeNode from sverchok.node_tree import SverchCustomTreeNode
from sverchok.utils.logging import debug, info
import sverchok import sverchok
...@@ -90,7 +91,7 @@ class SverchokPurgeCache(bpy.types.Operator): ...@@ -90,7 +91,7 @@ class SverchokPurgeCache(bpy.types.Operator):
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}
def execute(self, context): def execute(self, context):
print(bpy.context.space_data.node_tree.name) info(bpy.context.space_data.node_tree.name)
return {'FINISHED'} return {'FINISHED'}
...@@ -164,12 +165,12 @@ class SvClearNodesLayouts (bpy.types.Operator): ...@@ -164,12 +165,12 @@ class SvClearNodesLayouts (bpy.types.Operator):
if T.bl_rna.name in ['Shader Node Tree']: if T.bl_rna.name in ['Shader Node Tree']:
continue continue
if trees[T.name].users > 1 and T.use_fake_user: if trees[T.name].users > 1 and T.use_fake_user:
print('Layout '+str(T.name)+' protected by fake user.') info('Layout '+str(T.name)+' protected by fake user.')
if trees[T.name].users >= 1 and self.do_clear and not T.use_fake_user: if trees[T.name].users >= 1 and self.do_clear and not T.use_fake_user:
print('cleaning user: '+str(T.name)) info('cleaning user: '+str(T.name))
trees[T.name].user_clear() trees[T.name].user_clear()
if trees[T.name].users == 0: if trees[T.name].users == 0:
print('removing layout: '+str(T.name)+' | '+str(T.bl_rna.name)) info('removing layout: '+str(T.name)+' | '+str(T.bl_rna.name))
bpy.data.node_groups.remove(T) bpy.data.node_groups.remove(T)
return {'FINISHED'} return {'FINISHED'}
...@@ -197,23 +198,27 @@ class SvLayoutScanProperties(bpy.types.Operator): ...@@ -197,23 +198,27 @@ class SvLayoutScanProperties(bpy.types.Operator):
idname = node.bl_idname idname = node.bl_idname
if idname in {'ObjectsNodeMK2', 'SvObjectsNodeMK3'}: if idname in {'ObjectsNodeMK2', 'SvObjectsNodeMK3'}:
print('scans for get option ', node.label, node.name) debug('scans for get option %s %s', node.label, node.name)
if any((s.links for s in node.outputs)): if any((s.links for s in node.outputs)):
templist.append([node.label, node.name, ""]) templist.append([node.label, node.name, ""])
elif idname in {'SvNumberNode', 'IntegerNode', 'FloatNode', 'SvListInputNode'}: elif idname in {'SvNumberNode', 'IntegerNode', 'FloatNode', 'SvListInputNode', 'SvColorInputNode'}:
if not (node.inputs and node.outputs): if not node.outputs:
pass debug("Node %s does not have outputs", node.name)
continue
if len(node.inputs) and node.inputs[0].is_linked: if len(node.inputs) and node.inputs[0].is_linked:
pass debug("Node %s: first input is linked", node.name)
# somehow to3d not works at all now... continue
if not node.outputs[0].is_linked and node.to3d != True: if (not node.outputs[0].is_linked) or (node.to3d != True):
pass debug("Node %s: first output is not linked or to3d == False", node.name)
continue
if 'Integer' in idname: if 'Integer' in idname:
templist.append([node.label, node.name, 'int_']) templist.append([node.label, node.name, 'int_'])
elif 'Float' in idname: elif 'Float' in idname:
templist.append([node.label, node.name, 'float_']) templist.append([node.label, node.name, 'float_'])
elif idname == 'SvColorInputNode':
templist.append([node.label, node.name, 'color_data'])
elif 'SvListInputNode' in idname: elif 'SvListInputNode' in idname:
if node.mode == 'vector': if node.mode == 'vector':
templist.append([node.label, node.name, 'vector_list']) templist.append([node.label, node.name, 'vector_list'])
...@@ -230,7 +235,7 @@ class SvLayoutScanProperties(bpy.types.Operator): ...@@ -230,7 +235,7 @@ class SvLayoutScanProperties(bpy.types.Operator):
templ = [[t[1], t[2]] for t in templist] templ = [[t[1], t[2]] for t in templist]
tree.Sv3DProps.clear() tree.Sv3DProps.clear()
for name, prop in templ: for name, prop in templ:
print('sverchok 3d panel appended with',name, prop) debug('sverchok 3d panel appended with %s %s',name, prop)
item = tree.Sv3DProps.add() item = tree.Sv3DProps.add()
item.node_name = name item.node_name = name
item.prop_name = prop item.prop_name = prop
......
Поддерживает Markdown
0% или .
You are about to add 0 people to the discussion. Proceed with caution.
Сначала завершите редактирование этого сообщения!
Пожалуйста, зарегистрируйтесь или чтобы прокомментировать