Отчет по учебной
Скачать 415.93 Kb.
|
[1] 68 ). pop () 69 other_verts = list ( selected_edges_verts [0] ^ selected_edges_verts [1] 72 ) 73 if( other_verts [0] > other_verts [1]) : other_verts [0] , other_verts [1] = other_verts [1] , other_verts [0] 76 77 bm. verts . ensure_lookup_table () 78 79 vdiff = bv[ other_verts [1]]. co - bv[ other_verts [0] ]. co
84 new_pos = bv[ joint_vert ]. co + vrot 85 bpy . ops . mesh . select_all ( action = ’ DESELECT ’) bv[ joint_vert ]. select = True 88 89 bm. select_flush ( True ) 90 91 bpy . ops . transform . translate ( value = tuple ( vrot )) 92 93 bpy . ops . object . mode_set ( mode = ’ OBJECT ’) Листинг А.5 – Вариации и обобщения. class add_snowflake ( bpy . types . Operator ): """ Add a Koch Snowflake """ bl_idname = " mesh . add_snowflake " bl_label = " Add Snowflake " bl_options = {’ REGISTER ’, ’ UNDO ’, ’ PRESET ’} 6 iterations = bpy . props . Int Property ( name = " Iterations ", description = " Number of fractal iterations ", min = 0 , max = 6 , default = 2 13 ) 14 sides = bpy . props . Int Property ( name = " Number of sides ", description = " The number of sides of the initial polygon ", min = 3 , 19 max = 32 , 20 default = 6 21 ) 22 radius = bpy . props . Float Property ( name = " Radius ", description = " Radius of the snowflake ", 26 min = 0.1 , 27 max = 100.0 , unit = ’ LENGTH ’, default = 1.0 30 ) 31 def draw ( self , context ): layout = self . layout 34 box = layout . box () box . prop ( self , ’ radius ’) box . prop ( self , ’ sides ’) box . prop ( self , ’ iterations ’) 39 40 def execute ( self , context ): 41 create_snowflake ( create_mesh_obj ( ’ snowflake ’, draw_initial_polygon ( sides = self . sides , radius = self . radius 47 ) 48 ), iterations = self . iterations 49 ) 50 51 return {’ FINISHED ’} Листинг А.6 – Функция добавления оператора. def menu_func ( self , context ): self . layout . operator ( " mesh . add_snowflake ", text = " Snowflake ", icon = " PLUGIN " 6 ) 7 def register (): bpy . utils . register_module ( __name__ ) 10 11 bpy . types . INFO_MT_mesh_add . append ( menu_func ) 12 def unregister (): bpy . utils . unregister_module ( __name__ ) 15 16 bpy . types . INFO_MT_mesh_add . remove ( menu_func ) 17 18 if __name__ == " __main__ ": 19 register () |