less copy protection, more size visualization
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

135 wiersze
4.0 KiB

  1. from macrovision import ops
  2. import bpy
  3. class MV_UL_ViewList(bpy.types.UIList):
  4. def draw_item(self, context, layout: bpy.types.UILayout, data, item, icon, active_data, active_propname, index):
  5. if self.layout_type in {'DEFAULT', 'COMPACT'}:
  6. layout.prop(item, "view", text="")
  7. layout.prop(item, "name", text="")
  8. elif self.layout_type in {'GRID'}:
  9. layout.alignment = 'CENTER'
  10. layout.label(text='', icon = 'OBJECT_DATAMODE')
  11. class MV_Views_List_Add(bpy.types.Operator):
  12. bl_idname = "mv.views_list_add"
  13. bl_label = "Add view"
  14. def execute(self, context: bpy.types.Context):
  15. context.scene.mv_views.add()
  16. return {'FINISHED'}
  17. class MV_Views_List_Delete(bpy.types.Operator):
  18. bl_idname = "mv.views_list_delete"
  19. bl_label = "Delete view"
  20. @classmethod
  21. def poll(self, context: bpy.types.Context):
  22. return context.scene.mv_views
  23. def execute(self, context: bpy.types.Context):
  24. lst = context.scene.mv_views
  25. index = context.scene.mv_views_index
  26. lst.remove(index)
  27. index = max(0, index - 1)
  28. index = min(index, len(lst) - 1)
  29. context.scene.mv_views_index = index
  30. return {'FINISHED'}
  31. class MVScenePanel(bpy.types.Panel):
  32. bl_idname="OBJECT_PT_MV_scene_menu"
  33. bl_label="Macrovision"
  34. bl_space_type="VIEW_3D"
  35. bl_region_type="UI"
  36. bl_category = "Macrovision"
  37. @classmethod
  38. def poll(cls, context):
  39. return True
  40. def draw(self, context):
  41. layout = self.layout
  42. box = layout.box()
  43. box.label(text="Setup")
  44. box.prop(context.scene, "mv_entity_mass_mode")
  45. box.prop(context.scene, "mv_entity_volume_mode")
  46. op_props = box.operator("mv.config_collection")
  47. op_props = box.operator("mv.assign_materials")
  48. box.prop(context.scene, "mv_material_mode")
  49. if context.scene.mv_material_mode in ('NAMES', 'FACE_MAPS'):
  50. box.prop(context.scene, "mv_material_names_light")
  51. box.prop(context.scene, "mv_material_names_medium")
  52. box = layout.box()
  53. box.label(text="Execute")
  54. op_props = box.operator("mv.export")
  55. box.prop(context.scene, "mv_name")
  56. box.prop(context.scene, "mv_kind")
  57. box.prop(context.scene, "mv_trace_mode")
  58. box.template_list(
  59. "MV_UL_ViewList",
  60. "Views",
  61. context.scene,
  62. "mv_views",
  63. context.scene,
  64. "mv_views_index"
  65. )
  66. row = box.row()
  67. row.operator("mv.views_list_add", text="+")
  68. row.operator("mv.views_list_delete", text="-")
  69. box.prop(context.scene, 'mv_scale_factor')
  70. class MVCollectionPanel(bpy.types.Panel):
  71. bl_idname="OBJECT_PT_MV_collection_menu"
  72. bl_label="Entity"
  73. bl_space_type="VIEW_3D"
  74. bl_region_type="UI"
  75. bl_category = "Macrovision"
  76. @classmethod
  77. def poll(cls, context: bpy.context):
  78. return context.collection.name in bpy.data.collections['Macrovision'].children
  79. def draw(self, context):
  80. layout = self.layout
  81. box = layout.box()
  82. box.label(text="Entity")
  83. if context.scene.mv_entity_mass_mode == "MANUAL":
  84. row = box.row()
  85. row.label(text="Mass")
  86. row.prop(context.collection.mv_entity_mass, "base")
  87. row.prop(context.collection.mv_entity_mass, "power")
  88. if context.scene.mv_entity_mass_mode == "DENSITY":
  89. row = box.row()
  90. row.label(text="Density")
  91. row.prop(context.collection.mv_entity_density, "base")
  92. row.prop(context.collection.mv_entity_density, "power")
  93. if context.scene.mv_entity_volume_mode == "MANUAL":
  94. row = box.row()
  95. row.label(text="Volume")
  96. row.prop(context.collection.mv_entity_volume, "base")
  97. row.prop(context.collection.mv_entity_volume, "power")
  98. clses = [
  99. MV_UL_ViewList,
  100. MV_Views_List_Add,
  101. MV_Views_List_Delete,
  102. MVScenePanel,
  103. MVCollectionPanel
  104. ]