Главная страница

Отчет по учебной


Скачать 415.93 Kb.
НазваниеОтчет по учебной
Дата06.12.2022
Размер415.93 Kb.
Формат файлаdocx
Имя файлаKursovaya_rabota_v_1_8.docx
ТипОтчет
#830166
страница12 из 12
1   ...   4   5   6   7   8   9   10   11   12
[1]

68 ). pop ()

69

  1. other_verts = list (

  2. selected_edges_verts [0] ^ selected_edges_verts [1]

72 )

73

  1. if( other_verts [0] > other_verts [1]) :

  2. 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

80

vdiff [0] *=

sqrt (3) /2.0

81

vdiff [1] *=

sqrt (3) /2.0

82

vrot = vdiff

* rot_matrix

83







84 new_pos = bv[ joint_vert ]. co + vrot

85

  1. bpy . ops . mesh . select_all ( action = DESELECT ’)

  2. 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 Вариации и обобщения.

  1. class add_snowflake ( bpy . types . Operator ):

  2. """ Add a Koch Snowflake """

  3. bl_idname = " mesh . add_snowflake "

  4. bl_label = " Add Snowflake "

  5. bl_options = {’ REGISTER ’, UNDO ’, PRESET ’}

6

  1. iterations = bpy . props . Int Property (

  2. name = " Iterations ",

  3. description = " Number of fractal iterations ",

  4. min = 0 ,

  5. max = 6 ,

  6. default = 2

13 )

14

  1. sides = bpy . props . Int Property (

  2. name = " Number of sides ",

  3. description = " The number of sides of the initial polygon ",

  4. min = 3 ,

19 max = 32 ,

20 default = 6

21 )

22

  1. radius = bpy . props . Float Property (

  2. name = " Radius ",

  3. description = " Radius of the snowflake ",

26 min = 0.1 ,

27 max = 100.0 ,

  1. unit = LENGTH ’,

  2. default = 1.0

30 )

31

  1. def draw ( self , context ):

  2. layout = self . layout

34

  1. box = layout . box ()

  2. box . prop ( self , radius ’)

  3. box . prop ( self , sides ’)

  4. box . prop ( self , iterations ’)

39

40 def execute ( self , context ):

41

  1. create_snowflake (

  2. create_mesh_obj (

  3. snowflake ’, draw_initial_polygon (

  4. sides = self . sides ,

  5. radius = self . radius

47 )

48 ), iterations = self . iterations

49 )

50

51 return {’ FINISHED ’}
Листинг А.6 Функция добавления оператора.

  1. def menu_func ( self , context ):

  2. self . layout . operator (

  3. " mesh . add_snowflake ",

  4. text = " Snowflake ",

  5. icon = " PLUGIN "

6 )

7

  1. def register ():

  2. bpy . utils . register_module ( __name__ )

10

11 bpy . types . INFO_MT_mesh_add . append ( menu_func )

12

  1. def unregister ():

  2. bpy . utils . unregister_module ( __name__ )

15

16 bpy . types . INFO_MT_mesh_add . remove ( menu_func )

17

18 if __name__ == " __main__ ":

19 register ()
1   ...   4   5   6   7   8   9   10   11   12


написать администратору сайта