Export_3ds: Added distance cue chunk export
[blender-addons.git] / mesh_tissue / tissue_properties.py
blob4d66c2b6f715a2ced8ef6269c876309a7273dc67
1 # SPDX-FileCopyrightText: 2017 Alessandro Zomparelli
3 # SPDX-License-Identifier: GPL-2.0-or-later
5 # ---------------------------- ADAPTIVE DUPLIFACES --------------------------- #
6 # ------------------------------- version 0.84 ------------------------------- #
7 # #
8 # Creates duplicates of selected mesh to active morphing the shape according #
9 # to target faces. #
10 # #
11 # (c) Alessandro Zomparelli #
12 # (2017) #
13 # #
14 # http://www.co-de-it.com/ #
15 # #
16 # ############################################################################ #
18 import bpy
19 from bpy.types import (
20 Operator,
21 Panel,
22 PropertyGroup,
24 from bpy.props import (
25 BoolProperty,
26 EnumProperty,
27 FloatProperty,
28 IntProperty,
29 StringProperty,
30 PointerProperty
32 from .utils import tissue_time
33 from . import config
34 import time
37 def update_dependencies(ob, objects):
38 type = ob.tissue.tissue_type
39 if type == 'NONE': return objects
40 if ob.tissue.bool_dependencies:
41 deps = get_deps(ob)
42 for o in deps:
43 if o.tissue.tissue_type == 'NONE' or o.tissue.bool_lock or o in objects:
44 continue
45 objects.append(o)
46 objects = update_dependencies(o, objects)
47 return objects
49 def get_deps(ob):
50 type = ob.tissue.tissue_type
51 if type == 'TESSELLATE':
52 return [ob.tissue_tessellate.generator, ob.tissue_tessellate.component]
53 elif type == 'TO_CURVE':
54 return [ob.tissue_to_curve.object]
55 elif type == 'POLYHEDRA':
56 return [ob.tissue_polyhedra.object]
57 else: return []
59 def anim_tessellate_active(self, context):
60 ob = context.object
61 props = ob.tissue_tessellate
62 if not (ob.tissue.bool_lock or props.bool_hold):
63 try:
64 props.generator.name
65 if props.component_mode == 'OBJECT':
66 props.component.name
67 elif props.component_mode == 'COLLECTION':
68 props.component_coll.name
69 bpy.ops.object.tissue_update_tessellate()
70 except: pass
72 def anim_tessellate_object(ob):
73 try:
74 #bpy.context.view_layer.objects.active = ob
75 bpy.ops.object.tissue_update_tessellate()
76 except:
77 return None
79 #from bpy.app.handlers import persistent
82 def anim_tissue(scene, depsgraph=None):
83 tissue_time(None,'Tissue: Animating Tissue objects at frame {}...'.format(scene.frame_current), levels=0)
84 start_time = time.time()
86 try:
87 active_object = bpy.context.object
88 old_mode = bpy.context.object.mode
89 selected_objects = bpy.context.selected_objects
90 except: active_object = old_mode = selected_objects = None
92 if old_mode in ('OBJECT', 'PAINT_WEIGHT'):
93 update_objects = []
94 for ob in scene.objects:
95 if ob.tissue.bool_run and not ob.tissue.bool_lock:
96 if ob not in update_objects: update_objects.append(ob)
97 update_objects = list(reversed(update_dependencies(ob, update_objects)))
98 for ob in update_objects:
99 #override = {'object': ob}
100 for window in bpy.context.window_manager.windows:
101 screen = window.screen
102 for area in screen.areas:
103 if area.type == 'VIEW_3D':
104 override = bpy.context.copy()
105 override['window'] = window
106 override['screen'] = screen
107 override['area'] = area
108 override['selected_objects'] = [ob]
109 override['object'] = ob
110 override['active_object'] = ob
111 override['selected_editable_objects'] = [ob]
112 override['mode'] = 'OBJECT'
113 override['view_layer'] = scene.view_layers[0]
114 break
115 with bpy.context.temp_override(**override):
116 if ob.tissue.tissue_type == 'TESSELLATE':
117 bpy.ops.object.tissue_update_tessellate()
118 elif ob.tissue.tissue_type == 'TO_CURVE':
119 bpy.ops.object.tissue_update_convert_to_curve()
120 elif ob.tissue.tissue_type == 'POLYHEDRA':
121 bpy.ops.object.tissue_update_polyhedra()
122 elif ob.tissue.tissue_type == 'CONTOUR_CURVES':
123 bpy.ops.object.tissue_update_contour_curves()
125 if old_mode != None:
126 objects = bpy.context.view_layer.objects
127 objects.active = active_object
128 for o in objects: o.select_set(o in selected_objects)
129 bpy.ops.object.mode_set(mode=old_mode)
131 config.evaluatedDepsgraph = None
132 tissue_time(start_time,'Animated Tissue objects at frame {}'.format(scene.frame_current), levels=0)
133 return
135 def remove_tissue_handler():
136 tissue_handlers = []
137 blender_handlers = bpy.app.handlers.frame_change_post
138 for h in blender_handlers:
139 if "anim_tissue" in str(h):
140 tissue_handlers.append(h)
141 for h in tissue_handlers: blender_handlers.remove(h)
143 def set_tissue_handler(self, context):
144 remove_tissue_handler()
145 for o in context.scene.objects:
146 if o.tissue.bool_run:
147 blender_handlers = bpy.app.handlers.frame_change_post
148 blender_handlers.append(anim_tissue)
149 break
150 return
152 def remove_polyhedra_handler():
153 tissue_handlers = []
154 blender_handlers = bpy.app.handlers.frame_change_post
155 for h in blender_handlers:
156 if "anim_polyhedra" in str(h):
157 tissue_handlers.append(h)
158 for h in tissue_handlers: blender_handlers.remove(h)
160 def set_polyhedra_handler(self, context):
161 remove_polyhedra_handler()
162 for o in context.scene.objects:
163 if o.tissue.bool_run:
164 blender_handlers = bpy.app.handlers.frame_change_post
165 blender_handlers.append(anim_polyhedra)
166 break
167 return
170 class tissue_prop(PropertyGroup):
171 bool_lock : BoolProperty(
172 name="Lock",
173 description="Prevent automatic update on settings changes or if other objects have it in the hierarchy.",
174 default=False
176 bool_dependencies : BoolProperty(
177 name="Update Dependencies",
178 description="Automatically updates source objects, when possible",
179 default=False
181 bool_run : BoolProperty(
182 name="Animatable",
183 description="Automatically recompute the geometry when the frame is changed. Tessellations may not work using the default Render Animation",
184 default = False,
185 update = set_tissue_handler
187 tissue_type : EnumProperty(
188 items=(
189 ('NONE', "None", ""),
190 ('TESSELLATE', "Tessellate", ""),
191 ('TO_CURVE', "To Curve", ""),
192 ('POLYHEDRA', "Polyhedra", ""),
193 ('CONTOUR_CURVES', "Contour Curves", "")
195 default='NONE',
196 name=""
198 bool_hold : BoolProperty(
199 name="Hold",
200 description="Wait...",
201 default=False
204 class tissue_tessellate_prop(PropertyGroup):
205 bool_hold : BoolProperty(
206 name="Hold",
207 description="Wait...",
208 default=False
210 zscale : FloatProperty(
211 name="Scale", default=1, soft_min=0, soft_max=10,
212 description="Scale factor for the component thickness",
213 update = anim_tessellate_active
215 component_mode : EnumProperty(
216 items=(
217 ('OBJECT', "Object", "Use the same component object for all the faces"),
218 ('COLLECTION', "Collection", "Use multiple components from Collection"),
219 ('MATERIALS', "Materials", "Use multiple components by materials name")
221 default='OBJECT',
222 name="Component Mode",
223 update = anim_tessellate_active
225 scale_mode : EnumProperty(
226 items=(
227 ('CONSTANT', "Constant", "Uniform thinkness"),
228 ('ADAPTIVE', "Relative", "Preserve component's proportions")
230 default='ADAPTIVE',
231 name="Z-Scale according to faces size",
232 update = anim_tessellate_active
234 offset : FloatProperty(
235 name="Surface Offset",
236 default=1,
237 min=-1,
238 max=1,
239 soft_min=-1,
240 soft_max=1,
241 description="Surface offset",
242 update = anim_tessellate_active
244 mode : EnumProperty(
245 items=(
246 ('BOUNDS', "Bounds", "The component fits automatically the size of the target face"),
247 ('LOCAL', "Local", "Based on Local coordinates, from 0 to 1"),
248 ('GLOBAL', 'Global', "Based on Global coordinates, from 0 to 1")),
249 default='BOUNDS',
250 name="Component Mode",
251 update = anim_tessellate_active
253 rotation_mode : EnumProperty(
254 items=(('RANDOM', "Random", "Random faces rotation"),
255 ('UV', "Active UV", "Rotate according to UV coordinates"),
256 ('WEIGHT', "Weight Gradient", "Rotate according to Vertex Group gradient"),
257 ('DEFAULT', "Default", "Default rotation")),
258 default='DEFAULT',
259 name="Component Rotation",
260 update = anim_tessellate_active
262 rotation_direction : EnumProperty(
263 items=(('ORTHO', "Orthogonal", "Component main directions in XY"),
264 ('DIAG', "Diagonal", "Component main direction aligned with diagonal")),
265 default='ORTHO',
266 name="Direction",
267 update = anim_tessellate_active
269 rotation_shift : IntProperty(
270 name="Shift",
271 default=0,
272 soft_min=0,
273 soft_max=3,
274 description="Shift components rotation",
275 update = anim_tessellate_active
277 fill_mode : EnumProperty(
278 items=(
279 ('TRI', 'Tri', 'Triangulate the base mesh'),
280 ('QUAD', 'Quad', 'Regular quad tessellation. Uses only 3 or 4 vertices'),
281 ('FAN', 'Fan', 'Radial tessellation for polygonal faces'),
282 ('PATCH', 'Patch', 'Curved tessellation according to the last ' +
283 'Subsurf\n(or Multires) modifiers. Works only with 4 sides ' +
284 'patches.\nAfter the last Subsurf (or Multires) only ' +
285 'deformation\nmodifiers can be used'),
286 ('FRAME', 'Frame', 'Tessellation along the edges of each face')),
287 default='QUAD',
288 name="Fill Mode",
289 update = anim_tessellate_active
291 combine_mode : EnumProperty(
292 items=(
293 ('LAST', 'Last', 'Show only the last iteration'),
294 ('UNUSED', 'Unused', 'Combine each iteration with the unused faces of the previous iteration. Used for branching systems'),
295 ('ALL', 'All', 'Combine the result of all iterations')),
296 default='LAST',
297 name="Combine Mode",
298 update = anim_tessellate_active
300 gen_modifiers : BoolProperty(
301 name="Generator Modifiers",
302 default=True,
303 description="Apply Modifiers and Shape Keys to the base object",
304 update = anim_tessellate_active
306 com_modifiers : BoolProperty(
307 name="Component Modifiers",
308 default=True,
309 description="Apply Modifiers and Shape Keys to the component object",
310 update = anim_tessellate_active
312 merge : BoolProperty(
313 name="Merge",
314 default=False,
315 description="Merge vertices in adjacent duplicates",
316 update = anim_tessellate_active
318 merge_open_edges_only : BoolProperty(
319 name="Open edges only",
320 default=False,
321 description="Merge only open edges",
322 update = anim_tessellate_active
324 merge_thres : FloatProperty(
325 name="Distance",
326 default=0.0001,
327 soft_min=0,
328 soft_max=10,
329 description="Limit below which to merge vertices",
330 update = anim_tessellate_active
332 generator : PointerProperty(
333 type=bpy.types.Object,
334 name="",
335 description="Base object for the tessellation",
336 update = anim_tessellate_active
338 component : PointerProperty(
339 type=bpy.types.Object,
340 name="",
341 description="Component object for the tessellation",
342 #default="",
343 update = anim_tessellate_active
345 component_coll : PointerProperty(
346 type=bpy.types.Collection,
347 name="",
348 description="Use objects inside the collection",
349 #default="",
350 update = anim_tessellate_active
352 target : PointerProperty(
353 type=bpy.types.Object,
354 name="",
355 description="Target object for custom direction",
356 #default="",
357 update = anim_tessellate_active
359 even_thickness : BoolProperty(
360 name="Even Thickness",
361 default=False,
362 description="Iterative sampling method for determine the correct length of the vectors (Experimental)",
363 update = anim_tessellate_active
365 even_thickness_iter : IntProperty(
366 name="Even Thickness Iterations",
367 default=3,
368 min = 1,
369 soft_max = 20,
370 description="More iterations produces more accurate results but make the tessellation slower",
371 update = anim_tessellate_active
373 bool_random : BoolProperty(
374 name="Randomize",
375 default=False,
376 description="Randomize component rotation",
377 update = anim_tessellate_active
379 rand_seed : IntProperty(
380 name="Seed",
381 default=0,
382 soft_min=0,
383 soft_max=50,
384 description="Random seed",
385 update = anim_tessellate_active
387 coll_rand_seed : IntProperty(
388 name="Seed",
389 default=0,
390 soft_min=0,
391 soft_max=50,
392 description="Random seed",
393 update = anim_tessellate_active
395 rand_step : IntProperty(
396 name="Steps",
397 default=1,
398 min=1,
399 soft_max=2,
400 description="Random step",
401 update = anim_tessellate_active
403 bool_vertex_group : BoolProperty(
404 name="Map Vertex Group",
405 default=False,
406 description="Transfer all Vertex Groups from Base object",
407 update = anim_tessellate_active
409 bool_selection : BoolProperty(
410 name="On selected Faces",
411 default=False,
412 description="Create Tessellation only on selected faces",
413 update = anim_tessellate_active
415 bool_shapekeys : BoolProperty(
416 name="Use Shape Keys",
417 default=False,
418 description="Transfer Component's Shape Keys. If the name of Vertex "
419 "Groups and Shape Keys are the same, they will be "
420 "automatically combined",
421 update = anim_tessellate_active
423 bool_smooth : BoolProperty(
424 name="Smooth Shading",
425 default=False,
426 description="Output faces with smooth shading rather than flat shaded",
427 update = anim_tessellate_active
429 bool_materials : BoolProperty(
430 name="Transfer Materials",
431 default=False,
432 description="Preserve component's materials",
433 update = anim_tessellate_active
435 bool_material_id : BoolProperty(
436 name="Tessellation on Material ID",
437 default=False,
438 description="Apply the component only on the selected Material",
439 update = anim_tessellate_active
441 material_id : IntProperty(
442 name="Index",
443 default=0,
444 min=0,
445 description="Only the faces with the chosen Material Index will be used",
446 update = anim_tessellate_active
448 bool_dissolve_seams : BoolProperty(
449 name="Dissolve Seams",
450 default=False,
451 description="Dissolve all seam edges",
452 update = anim_tessellate_active
454 iterations : IntProperty(
455 name="Iterations",
456 default=1,
457 min=1,
458 soft_max=5,
459 description="Automatically repeat the Tessellation using the "
460 + "generated geometry as new base object.\nUsefull for "
461 + "for branching systems. Dangerous!",
462 update = anim_tessellate_active
464 bool_combine : BoolProperty(
465 name="Combine unused",
466 default=False,
467 description="Combine the generated geometry with unused faces",
468 update = anim_tessellate_active
470 bool_advanced : BoolProperty(
471 name="Advanced Settings",
472 default=False,
473 description="Show more settings"
475 normals_mode : EnumProperty(
476 items=(
477 ('VERTS', 'Normals', 'Consistent direction based on vertices normal'),
478 ('FACES', 'Faces', 'Based on individual faces normal'),
479 ('CUSTOM', 'Custom', 'Custom split normals'),
480 ('SHAPEKEYS', 'Keys', "According to base object's shape keys"),
481 ('OBJECT', 'Object', "According to a target object")),
482 default='VERTS',
483 name="Direction",
484 update = anim_tessellate_active
486 error_message : StringProperty(
487 name="Error Message",
488 default=""
490 warning_message : StringProperty(
491 name="Warning Message",
492 default=""
494 warning_message_thickness : StringProperty(
495 name="Warning Message Thickness",
496 default=""
498 warning_message_merge : StringProperty(
499 name="Warning Message Merge",
500 default=""
502 bounds_x : EnumProperty(
503 items=(
504 ('EXTEND', 'Extend', 'Default X coordinates'),
505 ('CLIP', 'Clip', 'Trim out of bounds in X direction'),
506 ('CYCLIC', 'Cyclic', 'Cyclic components in X direction')),
507 default='EXTEND',
508 name="Bounds X",
509 update = anim_tessellate_active
511 bounds_y : EnumProperty(
512 items=(
513 ('EXTEND', 'Extend', 'Default Y coordinates'),
514 ('CLIP', 'Clip', 'Trim out of bounds in Y direction'),
515 ('CYCLIC', 'Cyclic', 'Cyclic components in Y direction')),
516 default='EXTEND',
517 name="Bounds Y",
518 update = anim_tessellate_active
520 close_mesh : EnumProperty(
521 items=(
522 ('NONE', 'None', 'Keep the mesh open'),
523 ('CAP', 'Cap Holes', 'Automatically cap open loops'),
524 ('BRIDGE', 'Bridge Open Loops', 'Automatically bridge loop pairs'),
525 ('BRIDGE_CAP', 'Custom', 'Bridge loop pairs and cap holes according to vertex groups')),
526 default='NONE',
527 name="Close Mesh",
528 update = anim_tessellate_active
530 cap_faces : BoolProperty(
531 name="Cap Holes",
532 default=False,
533 description="Cap open edges loops",
534 update = anim_tessellate_active
536 frame_boundary : BoolProperty(
537 name="Frame Boundary",
538 default=False,
539 description="Support face boundaries",
540 update = anim_tessellate_active
542 fill_frame : BoolProperty(
543 name="Fill Frame",
544 default=False,
545 description="Fill inner faces with Fan tessellation",
546 update = anim_tessellate_active
548 boundary_mat_offset : IntProperty(
549 name="Material Offset",
550 default=0,
551 description="Material Offset for boundaries (with components based on Materials)",
552 update = anim_tessellate_active
554 fill_frame_mat : IntProperty(
555 name="Material Offset",
556 default=0,
557 description="Material Offset for inner faces (with components based on Materials)",
558 update = anim_tessellate_active
560 open_edges_crease : FloatProperty(
561 name="Open Edges Crease",
562 default=0,
563 min=0,
564 max=1,
565 description="Automatically set crease for open edges",
566 update = anim_tessellate_active
568 bridge_edges_crease : FloatProperty(
569 name="Bridge Edges Crease",
570 default=0,
571 min=0,
572 max=1,
573 description="Automatically set crease for bridge edges",
574 update = anim_tessellate_active
576 bridge_smoothness : FloatProperty(
577 name="Smoothness",
578 default=1,
579 min=0,
580 max=1,
581 description="Bridge Smoothness",
582 update = anim_tessellate_active
584 frame_thickness : FloatProperty(
585 name="Frame Thickness",
586 default=0.2,
587 min=0,
588 soft_max=1,
589 description="Frame Thickness",
590 update = anim_tessellate_active
592 frame_boundary_thickness : FloatProperty(
593 name="Frame Boundary Thickness",
594 default=0,
595 min=0,
596 soft_max=1,
597 description="Frame Boundary Thickness (when zero it uses the Frame Thickness instead)",
598 update = anim_tessellate_active
600 frame_mode : EnumProperty(
601 items=(
602 ('CONSTANT', 'Constant', 'Even thickness'),
603 ('RELATIVE', 'Relative', 'Frame offset depends on face areas'),
604 ('CENTER', 'Center', 'Toward the center of the face (uses Incenter for Triangles)')),
605 default='CONSTANT',
606 name="Offset",
607 update = anim_tessellate_active
609 bridge_cuts : IntProperty(
610 name="Cuts",
611 default=0,
612 min=0,
613 max=20,
614 description="Bridge Cuts",
615 update = anim_tessellate_active
617 cap_material_offset : IntProperty(
618 name="Material Offset",
619 default=0,
620 min=0,
621 description="Material index offset for the cap faces",
622 update = anim_tessellate_active
624 bridge_material_offset : IntProperty(
625 name="Material Offset",
626 default=0,
627 min=0,
628 description="Material index offset for the bridge faces",
629 update = anim_tessellate_active
631 patch_subs : IntProperty(
632 name="Patch Subdivisions",
633 default=0,
634 min=0,
635 description="Subdivisions levels for Patch tessellation after the first iteration",
636 update = anim_tessellate_active
638 use_origin_offset : BoolProperty(
639 name="Align to Origins",
640 default=True,
641 description="Define offset according to components origin and local Z coordinate",
642 update = anim_tessellate_active
645 vertex_group_thickness : StringProperty(
646 name="Thickness weight", default='',
647 description="Vertex Group used for thickness",
648 update = anim_tessellate_active
650 invert_vertex_group_thickness : BoolProperty(
651 name="Invert", default=False,
652 description="Invert the vertex group influence",
653 update = anim_tessellate_active
655 vertex_group_thickness_factor : FloatProperty(
656 name="Factor",
657 default=0,
658 min=0,
659 max=1,
660 description="Thickness factor to use for zero vertex group influence",
661 update = anim_tessellate_active
664 vertex_group_frame_thickness : StringProperty(
665 name="Frame Thickness weight", default='',
666 description="Vertex Group used for frame thickness",
667 update = anim_tessellate_active
669 invert_vertex_group_frame_thickness : BoolProperty(
670 name="Invert", default=False,
671 description="Invert the vertex group influence",
672 update = anim_tessellate_active
674 vertex_group_frame_thickness_factor : FloatProperty(
675 name="Factor",
676 default=0,
677 min=0,
678 max=1,
679 description="Frame thickness factor to use for zero vertex group influence",
680 update = anim_tessellate_active
682 face_weight_frame : BoolProperty(
683 name="Face Weight",
684 default=True,
685 description="Uniform weight for individual faces",
686 update = anim_tessellate_active
689 vertex_group_cap_owner : EnumProperty(
690 items=(
691 ('BASE', 'Base', 'Use base vertex group'),
692 ('COMP', 'Component', 'Use component vertex group')),
693 default='COMP',
694 name="Source",
695 update = anim_tessellate_active
697 vertex_group_cap : StringProperty(
698 name="Cap Vertex Group", default='',
699 description="Vertex Group used for cap open edges",
700 update = anim_tessellate_active
702 invert_vertex_group_cap : BoolProperty(
703 name="Invert", default=False,
704 description="Invert the vertex group influence",
705 update = anim_tessellate_active
708 vertex_group_bridge_owner : EnumProperty(
709 items=(
710 ('BASE', 'Base', 'Use base vertex group'),
711 ('COMP', 'Component', 'Use component vertex group')),
712 default='COMP',
713 name="Source",
714 update = anim_tessellate_active
716 vertex_group_bridge : StringProperty(
717 name="Bridge Vertex Group", default='',
718 description="Vertex Group used for bridge open edges",
719 update = anim_tessellate_active
721 invert_vertex_group_bridge : BoolProperty(
722 name="Invert", default=False,
723 description="Invert the vertex group influence",
724 update = anim_tessellate_active
727 vertex_group_rotation : StringProperty(
728 name="Rotation weight", default='',
729 description="Vertex Group used for rotation",
730 update = anim_tessellate_active
732 invert_vertex_group_rotation : BoolProperty(
733 name="Invert", default=False,
734 description="Invert the vertex group influence",
735 update = anim_tessellate_active
737 smooth_normals : BoolProperty(
738 name="Smooth Normals", default=False,
739 description="Smooth normals of the surface in order to reduce intersections",
740 update = anim_tessellate_active
742 smooth_normals_iter : IntProperty(
743 name="Iterations",
744 default=5,
745 min=0,
746 description="Smooth iterations",
747 update = anim_tessellate_active
749 smooth_normals_uv : FloatProperty(
750 name="UV Anisotropy",
751 default=0,
752 min=-1,
753 max=1,
754 description="0 means no anisotropy, -1 represent the U direction, while 1 represent the V direction",
755 update = anim_tessellate_active
757 vertex_group_smooth_normals : StringProperty(
758 name="Smooth normals weight", default='',
759 description="Vertex Group used for smooth normals",
760 update = anim_tessellate_active
762 invert_vertex_group_smooth_normals : BoolProperty(
763 name="Invert", default=False,
764 description="Invert the vertex group influence",
765 update = anim_tessellate_active
768 vertex_group_distribution : StringProperty(
769 name="Distribution weight", default='',
770 description="Vertex Group used for gradient distribution",
771 update = anim_tessellate_active
773 invert_vertex_group_distribution : BoolProperty(
774 name="Invert", default=False,
775 description="Invert the vertex group influence",
776 update = anim_tessellate_active
778 vertex_group_distribution_factor : FloatProperty(
779 name="Factor",
780 default=0,
781 min=0,
782 max=1,
783 description="Randomness factor to use for zero vertex group influence",
784 update = anim_tessellate_active
786 consistent_wedges : BoolProperty(
787 name="Consistent Wedges", default=True,
788 description="Use same component for the wedges generated by the Fan tessellation",
789 update = anim_tessellate_active
791 normals_x : FloatProperty(
792 name="X", default=1, min=0, max=1,
793 description="Scale X component of the normals",
794 update = anim_tessellate_active
796 normals_y : FloatProperty(
797 name="Y", default=1, min=0, max=1,
798 description="Scale Y component of the normals",
799 update = anim_tessellate_active
801 normals_z : FloatProperty(
802 name="Z", default=1, min=0, max=1,
803 description="Scale Z component of the normals",
804 update = anim_tessellate_active
806 vertex_group_scale_normals : StringProperty(
807 name="Scale normals weight", default='',
808 description="Vertex Group used for editing the normals directions",
809 update = anim_tessellate_active
811 invert_vertex_group_scale_normals : BoolProperty(
812 name="Invert", default=False,
813 description="Invert the vertex group influence",
814 update = anim_tessellate_active
816 boundary_variable_offset : BoolProperty(
817 name="Boundary Variable Offset", default=False,
818 description="Additional material offset based on the number of boundary vertices",
819 update = anim_tessellate_active
821 auto_rotate_boundary : BoolProperty(
822 name="Automatic Rotation", default=False,
823 description="Automatically rotate the boundary faces",
824 update = anim_tessellate_active
826 preserve_quads : BoolProperty(
827 name="Preserve Quads",
828 default=False,
829 description="Quad faces are tessellated using QUAD mode",
830 update = anim_tessellate_active
833 def store_parameters(operator, ob):
834 ob.tissue_tessellate.bool_hold = True
835 if operator.generator in bpy.data.objects.keys():
836 ob.tissue_tessellate.generator = bpy.data.objects[operator.generator]
837 if operator.component in bpy.data.objects.keys():
838 ob.tissue_tessellate.component = bpy.data.objects[operator.component]
839 if operator.component_coll in bpy.data.collections.keys():
840 ob.tissue_tessellate.component_coll = bpy.data.collections[operator.component_coll]
841 if operator.target in bpy.data.objects.keys():
842 ob.tissue_tessellate.target = bpy.data.objects[operator.target]
843 ob.tissue_tessellate.even_thickness = operator.even_thickness
844 ob.tissue_tessellate.even_thickness_iter = operator.even_thickness_iter
845 ob.tissue_tessellate.zscale = operator.zscale
846 ob.tissue_tessellate.offset = operator.offset
847 ob.tissue_tessellate.gen_modifiers = operator.gen_modifiers
848 ob.tissue_tessellate.com_modifiers = operator.com_modifiers
849 ob.tissue_tessellate.mode = operator.mode
850 ob.tissue_tessellate.rotation_mode = operator.rotation_mode
851 ob.tissue_tessellate.rotation_shift = operator.rotation_shift
852 ob.tissue_tessellate.rotation_direction = operator.rotation_direction
853 ob.tissue_tessellate.merge = operator.merge
854 ob.tissue_tessellate.merge_open_edges_only = operator.merge_open_edges_only
855 ob.tissue_tessellate.merge_thres = operator.merge_thres
856 ob.tissue_tessellate.scale_mode = operator.scale_mode
857 ob.tissue_tessellate.bool_random = operator.bool_random
858 ob.tissue_tessellate.rand_seed = operator.rand_seed
859 ob.tissue_tessellate.coll_rand_seed = operator.coll_rand_seed
860 ob.tissue_tessellate.rand_step = operator.rand_step
861 ob.tissue_tessellate.fill_mode = operator.fill_mode
862 ob.tissue_tessellate.bool_vertex_group = operator.bool_vertex_group
863 ob.tissue_tessellate.bool_selection = operator.bool_selection
864 ob.tissue_tessellate.bool_shapekeys = operator.bool_shapekeys
865 ob.tissue_tessellate.bool_smooth = operator.bool_smooth
866 ob.tissue_tessellate.bool_materials = operator.bool_materials
867 ob.tissue_tessellate.bool_material_id = operator.bool_material_id
868 ob.tissue_tessellate.material_id = operator.material_id
869 ob.tissue_tessellate.bool_dissolve_seams = operator.bool_dissolve_seams
870 ob.tissue_tessellate.iterations = operator.iterations
871 ob.tissue_tessellate.bool_advanced = operator.bool_advanced
872 ob.tissue_tessellate.normals_mode = operator.normals_mode
873 ob.tissue_tessellate.bool_combine = operator.bool_combine
874 ob.tissue_tessellate.combine_mode = operator.combine_mode
875 ob.tissue_tessellate.bounds_x = operator.bounds_x
876 ob.tissue_tessellate.bounds_y = operator.bounds_y
877 ob.tissue_tessellate.cap_faces = operator.cap_faces
878 ob.tissue_tessellate.close_mesh = operator.close_mesh
879 ob.tissue_tessellate.bridge_cuts = operator.bridge_cuts
880 ob.tissue_tessellate.bridge_smoothness = operator.bridge_smoothness
881 ob.tissue_tessellate.frame_thickness = operator.frame_thickness
882 ob.tissue_tessellate.frame_boundary_thickness = operator.frame_boundary_thickness
883 ob.tissue_tessellate.frame_mode = operator.frame_mode
884 ob.tissue_tessellate.frame_boundary = operator.frame_boundary
885 ob.tissue_tessellate.fill_frame = operator.fill_frame
886 ob.tissue_tessellate.boundary_mat_offset = operator.boundary_mat_offset
887 ob.tissue_tessellate.fill_frame_mat = operator.fill_frame_mat
888 ob.tissue_tessellate.cap_material_offset = operator.cap_material_offset
889 ob.tissue_tessellate.patch_subs = operator.patch_subs
890 ob.tissue_tessellate.use_origin_offset = operator.use_origin_offset
891 ob.tissue_tessellate.vertex_group_thickness = operator.vertex_group_thickness
892 ob.tissue_tessellate.invert_vertex_group_thickness = operator.invert_vertex_group_thickness
893 ob.tissue_tessellate.vertex_group_thickness_factor = operator.vertex_group_thickness_factor
894 ob.tissue_tessellate.vertex_group_frame_thickness = operator.vertex_group_frame_thickness
895 ob.tissue_tessellate.invert_vertex_group_frame_thickness = operator.invert_vertex_group_frame_thickness
896 ob.tissue_tessellate.vertex_group_frame_thickness_factor = operator.vertex_group_frame_thickness_factor
897 ob.tissue_tessellate.face_weight_frame = operator.face_weight_frame
898 ob.tissue_tessellate.vertex_group_distribution = operator.vertex_group_distribution
899 ob.tissue_tessellate.invert_vertex_group_distribution = operator.invert_vertex_group_distribution
900 ob.tissue_tessellate.vertex_group_distribution_factor = operator.vertex_group_distribution_factor
901 ob.tissue_tessellate.vertex_group_cap_owner = operator.vertex_group_cap_owner
902 ob.tissue_tessellate.vertex_group_cap = operator.vertex_group_cap
903 ob.tissue_tessellate.invert_vertex_group_cap = operator.invert_vertex_group_cap
904 ob.tissue_tessellate.vertex_group_bridge_owner = operator.vertex_group_bridge_owner
905 ob.tissue_tessellate.vertex_group_bridge = operator.vertex_group_bridge
906 ob.tissue_tessellate.invert_vertex_group_bridge = operator.invert_vertex_group_bridge
907 ob.tissue_tessellate.vertex_group_rotation = operator.vertex_group_rotation
908 ob.tissue_tessellate.invert_vertex_group_rotation = operator.invert_vertex_group_rotation
909 ob.tissue_tessellate.smooth_normals = operator.smooth_normals
910 ob.tissue_tessellate.smooth_normals_iter = operator.smooth_normals_iter
911 ob.tissue_tessellate.smooth_normals_uv = operator.smooth_normals_uv
912 ob.tissue_tessellate.vertex_group_smooth_normals = operator.vertex_group_smooth_normals
913 ob.tissue_tessellate.invert_vertex_group_smooth_normals = operator.invert_vertex_group_smooth_normals
914 ob.tissue_tessellate.component_mode = operator.component_mode
915 ob.tissue_tessellate.consistent_wedges = operator.consistent_wedges
916 ob.tissue_tessellate.normals_x = operator.normals_x
917 ob.tissue_tessellate.normals_y = operator.normals_y
918 ob.tissue_tessellate.normals_z = operator.normals_z
919 ob.tissue_tessellate.vertex_group_scale_normals = operator.vertex_group_scale_normals
920 ob.tissue_tessellate.invert_vertex_group_scale_normals = operator.invert_vertex_group_scale_normals
921 ob.tissue_tessellate.boundary_variable_offset = operator.boundary_variable_offset
922 ob.tissue_tessellate.auto_rotate_boundary = operator.auto_rotate_boundary
923 ob.tissue_tessellate.preserve_quads = operator.preserve_quads
924 ob.tissue_tessellate.bool_hold = False
925 return ob
927 def load_parameters(operator, ob):
928 operator.generator = ob.tissue_tessellate.generator.name
929 operator.component = ob.tissue_tessellate.component.name
930 operator.component_coll = ob.tissue_tessellate.component_coll.name
931 operator.zscale = ob.tissue_tessellate.zscale
932 operator.offset = ob.tissue_tessellate.offset
933 operator.gen_modifiers = ob.tissue_tessellate.gen_modifiers
934 operator.com_modifiers = ob.tissue_tessellate.com_modifiers
935 operator.mode = ob.tissue_tessellate.mode
936 operator.rotation_mode = ob.tissue_tessellate.rotation_mode
937 operator.rotation_shift = ob.tissue_tessellate.rotation_shift
938 operator.rotation_direction = ob.tissue_tessellate.rotation_direction
939 operator.merge = ob.tissue_tessellate.merge
940 operator.merge_open_edges_only = ob.tissue_tessellate.merge_open_edges_only
941 operator.merge_thres = ob.tissue_tessellate.merge_thres
942 operator.scale_mode = ob.tissue_tessellate.scale_mode
943 operator.bool_random = ob.tissue_tessellate.bool_random
944 operator.rand_seed = ob.tissue_tessellate.rand_seed
945 operator.coll_rand_seed = ob.tissue_tessellate.coll_rand_seed
946 operator.rand_step = ob.tissue_tessellate.rand_step
947 operator.fill_mode = ob.tissue_tessellate.fill_mode
948 operator.bool_vertex_group = ob.tissue_tessellate.bool_vertex_group
949 operator.bool_selection = ob.tissue_tessellate.bool_selection
950 operator.bool_shapekeys = ob.tissue_tessellate.bool_shapekeys
951 operator.bool_smooth = ob.tissue_tessellate.bool_smooth
952 operator.bool_materials = ob.tissue_tessellate.bool_materials
953 operator.bool_material_id = ob.tissue_tessellate.bool_material_id
954 operator.material_id = ob.tissue_tessellate.material_id
955 operator.bool_dissolve_seams = ob.tissue_tessellate.bool_dissolve_seams
956 operator.iterations = ob.tissue_tessellate.iterations
957 operator.bool_advanced = ob.tissue_tessellate.bool_advanced
958 operator.normals_mode = ob.tissue_tessellate.normals_mode
959 operator.bool_combine = ob.tissue_tessellate.bool_combine
960 operator.combine_mode = ob.tissue_tessellate.combine_mode
961 operator.bounds_x = ob.tissue_tessellate.bounds_x
962 operator.bounds_y = ob.tissue_tessellate.bounds_y
963 operator.cap_faces = ob.tissue_tessellate.cap_faces
964 operator.close_mesh = ob.tissue_tessellate.close_mesh
965 operator.bridge_cuts = ob.tissue_tessellate.bridge_cuts
966 operator.bridge_smoothness = ob.tissue_tessellate.bridge_smoothness
967 operator.cap_material_offset = ob.tissue_tessellate.cap_material_offset
968 operator.patch_subs = ob.tissue_tessellate.patch_subs
969 operator.frame_boundary = ob.tissue_tessellate.frame_boundary
970 operator.fill_frame = ob.tissue_tessellate.fill_frame
971 operator.boundary_mat_offset = ob.tissue_tessellate.boundary_mat_offset
972 operator.fill_frame_mat = ob.tissue_tessellate.fill_frame_mat
973 operator.frame_thickness = ob.tissue_tessellate.frame_thickness
974 operator.frame_boundary_thickness = ob.tissue_tessellate.frame_boundary_thickness
975 operator.frame_mode = ob.tissue_tessellate.frame_mode
976 operator.use_origin_offset = ob.tissue_tessellate.use_origin_offset
977 operator.vertex_group_thickness = ob.tissue_tessellate.vertex_group_thickness
978 operator.invert_vertex_group_thickness = ob.tissue_tessellate.invert_vertex_group_thickness
979 operator.vertex_group_thickness_factor = ob.tissue_tessellate.vertex_group_thickness_factor
980 operator.vertex_group_frame_thickness = ob.tissue_tessellate.vertex_group_frame_thickness
981 operator.invert_vertex_group_frame_thickness = ob.tissue_tessellate.invert_vertex_group_frame_thickness
982 operator.vertex_group_frame_thickness_factor = ob.tissue_tessellate.vertex_group_frame_thickness_factor
983 operator.face_weight_frame = ob.tissue_tessellate.face_weight_frame
984 operator.vertex_group_distribution = ob.tissue_tessellate.vertex_group_distribution
985 operator.invert_vertex_group_distribution = ob.tissue_tessellate.invert_vertex_group_distribution
986 operator.vertex_group_distribution_factor = ob.tissue_tessellate.vertex_group_distribution_factor
987 operator.vertex_group_cap_owner = ob.tissue_tessellate.vertex_group_cap_owner
988 operator.vertex_group_cap = ob.tissue_tessellate.vertex_group_cap
989 operator.invert_vertex_group_cap = ob.tissue_tessellate.invert_vertex_group_cap
990 operator.vertex_group_bridge_owner = ob.tissue_tessellate.vertex_group_bridge_owner
991 operator.vertex_group_bridge = ob.tissue_tessellate.vertex_group_bridge
992 operator.invert_vertex_group_bridge = ob.tissue_tessellate.invert_vertex_group_bridge
993 operator.vertex_group_rotation = ob.tissue_tessellate.vertex_group_rotation
994 operator.invert_vertex_group_rotation = ob.tissue_tessellate.invert_vertex_group_rotation
995 operator.smooth_normals = ob.tissue_tessellate.smooth_normals
996 operator.smooth_normals_iter = ob.tissue_tessellate.smooth_normals_iter
997 operator.smooth_normals_uv = ob.tissue_tessellate.smooth_normals_uv
998 operator.vertex_group_smooth_normals = ob.tissue_tessellate.vertex_group_smooth_normals
999 operator.invert_vertex_group_smooth_normals = ob.tissue_tessellate.invert_vertex_group_smooth_normals
1000 operator.component_mode = ob.tissue_tessellate.component_mode
1001 operator.consistent_wedges = ob.tissue_tessellate.consistent_wedges
1002 operator.normals_x = ob.tissue_tessellate.normals_x
1003 operator.normals_y = ob.tissue_tessellate.normals_y
1004 operator.normals_z = ob.tissue_tessellate.normals_z
1005 operator.vertex_group_scale_normals = ob.tissue_tessellate.vertex_group_scale_normals
1006 operator.invert_vertex_group_scale_normals = ob.tissue_tessellate.invert_vertex_group_scale_normals
1007 operator.boundary_variable_offset = ob.tissue_tessellate.boundary_variable_offset
1008 operator.auto_rotate_boundary = ob.tissue_tessellate.auto_rotate_boundary
1009 operator.preserve_quads = ob.tissue_tessellate.preserve_quads
1010 return ob
1012 def props_to_dict(ob):
1013 props = ob.tissue_tessellate
1014 tessellate_dict = {}
1015 tessellate_dict['self'] = ob
1016 tessellate_dict['generator'] = props.generator
1017 tessellate_dict['component'] = props.component
1018 tessellate_dict['component_coll'] = props.component_coll
1019 tessellate_dict['offset'] = props.offset
1020 tessellate_dict['zscale'] = props.zscale
1021 tessellate_dict['gen_modifiers'] = props.gen_modifiers
1022 tessellate_dict['com_modifiers'] = props.com_modifiers
1023 tessellate_dict['mode'] = props.mode
1024 tessellate_dict['scale_mode'] = props.scale_mode
1025 tessellate_dict['rotation_mode'] = props.rotation_mode
1026 tessellate_dict['rotation_shift'] = props.rotation_shift
1027 tessellate_dict['rotation_direction'] = props.rotation_direction
1028 tessellate_dict['rand_seed'] = props.rand_seed
1029 tessellate_dict['coll_rand_seed'] = props.coll_rand_seed
1030 tessellate_dict['rand_step'] = props.rand_step
1031 tessellate_dict['fill_mode'] = props.fill_mode
1032 tessellate_dict['bool_vertex_group'] = props.bool_vertex_group
1033 tessellate_dict['bool_selection'] = props.bool_selection
1034 tessellate_dict['bool_shapekeys'] = props.bool_shapekeys
1035 tessellate_dict['bool_material_id'] = props.bool_material_id
1036 tessellate_dict['material_id'] = props.material_id
1037 tessellate_dict['normals_mode'] = props.normals_mode
1038 tessellate_dict['bounds_x'] = props.bounds_x
1039 tessellate_dict['bounds_y'] = props.bounds_y
1040 tessellate_dict['use_origin_offset'] = props.use_origin_offset
1041 tessellate_dict['target'] = props.target
1042 tessellate_dict['even_thickness'] = props.even_thickness
1043 tessellate_dict['even_thickness_iter'] = props.even_thickness_iter
1044 tessellate_dict['frame_thickness'] = props.frame_thickness
1045 tessellate_dict['frame_boundary_thickness'] = props.frame_boundary_thickness
1046 tessellate_dict['frame_mode'] = props.frame_mode
1047 tessellate_dict['frame_boundary'] = props.frame_boundary
1048 tessellate_dict['fill_frame'] = props.fill_frame
1049 tessellate_dict['boundary_mat_offset'] = props.boundary_mat_offset
1050 tessellate_dict['fill_frame_mat'] = props.fill_frame_mat
1051 tessellate_dict['vertex_group_thickness'] = props.vertex_group_thickness
1052 tessellate_dict['invert_vertex_group_thickness'] = props.invert_vertex_group_thickness
1053 tessellate_dict['vertex_group_thickness_factor'] = props.vertex_group_thickness_factor
1054 tessellate_dict['vertex_group_frame_thickness'] = props.vertex_group_frame_thickness
1055 tessellate_dict['invert_vertex_group_frame_thickness'] = props.invert_vertex_group_frame_thickness
1056 tessellate_dict['vertex_group_frame_thickness_factor'] = props.vertex_group_frame_thickness_factor
1057 tessellate_dict['face_weight_frame'] = props.face_weight_frame
1058 tessellate_dict['vertex_group_distribution'] = props.vertex_group_distribution
1059 tessellate_dict['invert_vertex_group_distribution'] = props.invert_vertex_group_distribution
1060 tessellate_dict['vertex_group_distribution_factor'] = props.vertex_group_distribution_factor
1061 tessellate_dict['vertex_group_cap_owner'] = props.vertex_group_cap_owner
1062 tessellate_dict['vertex_group_cap'] = props.vertex_group_cap
1063 tessellate_dict['invert_vertex_group_cap'] = props.invert_vertex_group_cap
1064 tessellate_dict['vertex_group_bridge_owner'] = props.vertex_group_bridge_owner
1065 tessellate_dict['vertex_group_bridge'] = props.vertex_group_bridge
1066 tessellate_dict['invert_vertex_group_bridge'] = props.invert_vertex_group_bridge
1067 tessellate_dict['vertex_group_rotation'] = props.vertex_group_rotation
1068 tessellate_dict['invert_vertex_group_rotation'] = props.invert_vertex_group_rotation
1069 tessellate_dict['smooth_normals'] = props.smooth_normals
1070 tessellate_dict['smooth_normals_iter'] = props.smooth_normals_iter
1071 tessellate_dict['smooth_normals_uv'] = props.smooth_normals_uv
1072 tessellate_dict['vertex_group_smooth_normals'] = props.vertex_group_smooth_normals
1073 tessellate_dict['invert_vertex_group_smooth_normals'] = props.invert_vertex_group_smooth_normals
1074 tessellate_dict['component_mode'] = props.component_mode
1075 tessellate_dict['consistent_wedges'] = props.consistent_wedges
1076 tessellate_dict["normals_x"] = props.normals_x
1077 tessellate_dict["normals_y"] = props.normals_y
1078 tessellate_dict["normals_z"] = props.normals_z
1079 tessellate_dict["vertex_group_scale_normals"] = props.vertex_group_scale_normals
1080 tessellate_dict["invert_vertex_group_scale_normals"] = props.invert_vertex_group_scale_normals
1081 tessellate_dict["boundary_variable_offset"] = props.boundary_variable_offset
1082 tessellate_dict["auto_rotate_boundary"] = props.auto_rotate_boundary
1083 tessellate_dict["merge"] = props.merge
1084 tessellate_dict["merge_thres"] = props.merge_thres
1085 tessellate_dict["merge_open_edges_only"] = props.merge_open_edges_only
1086 tessellate_dict["preserve_quads"] = props.preserve_quads
1087 return tessellate_dict
1089 def copy_tessellate_props(source_ob, target_ob):
1090 source_props = source_ob.tissue_tessellate
1091 target_props = target_ob.tissue_tessellate
1092 for key in source_props.keys():
1093 target_props[key] = source_props[key]
1094 return