Skip to content

Instantly share code, notes, and snippets.

@zeffii
Last active December 26, 2017 13:48
Show Gist options
  • Save zeffii/1ad9706f60e5097bd5fbf487bac9353f to your computer and use it in GitHub Desktop.
Save zeffii/1ad9706f60e5097bd5fbf487bac9353f to your computer and use it in GitHub Desktop.
tissue node preamble - NO THIS DOESN'T WORK.
# ##### 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 bpy
# import mathutils
# from mathutils import Vector
# from bpy.props import FloatProperty, BoolProperty
from sverchok.node_tree import SverchCustomTreeNode
from sverchok.data_structure import updateNode
import tissue
class SvTissueMK1(bpy.types.Node, SverchCustomTreeNode):
''' a SvTissueMK1 f '''
bl_idname = 'SvTissueMK1'
bl_label = 'Tissue'
bl_icon = 'GREASEPENCIL'
# these properties need to be injected automatically
object_name = bpy.props.StringProperty(name="", description="Name of the generated object")
zscale = bpy.props.FloatProperty(name="Scale", default=1, soft_min=0, soft_max=10, description="Scale factor for the component thickness")
scale_mode = bpy.props.EnumProperty(items=(('CONSTANT', "Constant", ""), ('ADAPTIVE', "Proportional", "")), default='CONSTANT', name="Z-Scale according to faces size")
offset = bpy.props.FloatProperty(name="Surface Offset", default=0, min=-1, max=1, soft_min=-1, soft_max=1, description="Surface offset")
mode = bpy.props.EnumProperty(items=(('CONSTANT', "Constant", ""), ('ADAPTIVE', "Adaptive", "")), default='ADAPTIVE', name="Component Mode")
rotation_mode = bpy.props.EnumProperty(items=(('RANDOM', "Random", ""), ('UV', "Active UV", ""), ('DEFAULT', "Default", "")), default='DEFAULT', name="Component Rotation")
fill_mode = bpy.props.EnumProperty(items=(('QUAD', "Quad", ""), ('FAN', "Fan", "")), default='QUAD', name="Fill Mode")
gen_modifiers = bpy.props.BoolProperty(name="Generator Modifiers", default=False, description="Apply modifiers to base object")
com_modifiers = bpy.props.BoolProperty(name="Component Modifiers", default=False, description="Apply modifiers to component object")
merge = bpy.props.BoolProperty(name="Merge", default=False, description="Merge vertices in adjacent duplicates")
merge_thres = bpy.props.FloatProperty(name="Distance", default=0.001, soft_min=0, soft_max=10, description="Limit below which to merge vertices")
generator = bpy.props.StringProperty(name="", description="Base object for the tessellation")
component = bpy.props.StringProperty(name="", description="Component object for the tessellation")
bool_random = bpy.props.BoolProperty(name="Randomize", default=False, description="Randomize component rotation")
random_seed = bpy.props.IntProperty(name="Seed", default=0, soft_min=0, soft_max=10, description="Random seed")
bool_vertex_group = bpy.props.BoolProperty(name="Map Vertex Group", default=False, description="Map the active Vertex Group from the Base object to generated geometry")
bool_selection = bpy.props.BoolProperty(name="On selected Faces", default=False, description="Create Tessellation only on selected faces")
bool_shapekeys = bpy.props.BoolProperty(name="Use Shape Keys", default=False, description="Use component's active Shape Key according to active Vertex Group of the base object")
def sv_init(self, context):
self.inputs.new('SvObjectSocket', 'obj 1')
self.inputs.new('SvObjectSocket', 'obj 2')
self.outputs.new('SvObjectSocket', 'obj out')
def draw_buttons(self, context, layout):
draw = bpy.types.OBJECT_OT_tessellate.draw
node = lambda: None
for i in dir(self):
setattr(node, i, getattr(self, i))
node.layout = layout
draw(node, context)
def process(self):
pass
def register():
bpy.utils.register_class(SvTissueMK1)
def unregister():
bpy.utils.unregister_class(SvTissueMK1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment