properties_data_metaball.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. # ##### BEGIN GPL LICENSE BLOCK #####
  2. #
  3. # This program is free software; you can redistribute it and/or
  4. # modify it under the terms of the GNU General Public License
  5. # as published by the Free Software Foundation; either version 2
  6. # of the License, or (at your option) any later version.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program; if not, write to the Free Software Foundation,
  15. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. #
  17. # ##### END GPL LICENSE BLOCK #####
  18. # <pep8 compliant>
  19. import bpy
  20. from bpy.types import Panel
  21. from rna_prop_ui import PropertyPanel
  22. class DataButtonsPanel:
  23. bl_space_type = 'PROPERTIES'
  24. bl_region_type = 'WINDOW'
  25. bl_context = "data"
  26. @classmethod
  27. def poll(cls, context):
  28. return context.meta_ball
  29. class DATA_PT_context_metaball(DataButtonsPanel, Panel):
  30. bl_label = ""
  31. bl_options = {'HIDE_HEADER'}
  32. def draw(self, context):
  33. layout = self.layout
  34. ob = context.object
  35. mball = context.meta_ball
  36. space = context.space_data
  37. if ob:
  38. layout.template_ID(ob, "data")
  39. elif mball:
  40. layout.template_ID(space, "pin_id")
  41. class DATA_PT_metaball(DataButtonsPanel, Panel):
  42. bl_label = "Metaball"
  43. def draw(self, context):
  44. layout = self.layout
  45. layout.use_property_split = True
  46. mball = context.meta_ball
  47. col = layout.column(align=True)
  48. col.prop(mball, "resolution", text="Resolution Viewport")
  49. col.prop(mball, "render_resolution", text="Render")
  50. col.separator()
  51. col.prop(mball, "threshold", text="Influence Threshold")
  52. col.separator()
  53. col.prop(mball, "update_method", text="Update on Edit")
  54. class DATA_PT_mball_texture_space(DataButtonsPanel, Panel):
  55. bl_label = "Texture Space"
  56. bl_options = {'DEFAULT_CLOSED'}
  57. COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
  58. def draw(self, context):
  59. layout = self.layout
  60. layout.use_property_split = True
  61. mball = context.meta_ball
  62. layout.prop(mball, "use_auto_texspace")
  63. col = layout.column()
  64. col.prop(mball, "texspace_location")
  65. col.prop(mball, "texspace_size")
  66. class DATA_PT_metaball_element(DataButtonsPanel, Panel):
  67. bl_label = "Active Element"
  68. @classmethod
  69. def poll(cls, context):
  70. return (context.meta_ball and context.meta_ball.elements.active)
  71. def draw(self, context):
  72. layout = self.layout
  73. layout.use_property_split = True
  74. metaelem = context.meta_ball.elements.active
  75. col = layout.column()
  76. col.prop(metaelem, "type")
  77. col.separator()
  78. col.prop(metaelem, "stiffness", text="Stiffness")
  79. col.prop(metaelem, "radius", text="Radius")
  80. col.prop(metaelem, "use_negative", text="Negative")
  81. col.prop(metaelem, "hide", text="Hide")
  82. sub = col.column(align=True)
  83. if metaelem.type in {'CUBE', 'ELLIPSOID'}:
  84. sub.prop(metaelem, "size_x", text="Size X")
  85. sub.prop(metaelem, "size_y", text="Y")
  86. sub.prop(metaelem, "size_z", text="Z")
  87. elif metaelem.type == 'CAPSULE':
  88. sub.prop(metaelem, "size_x", text="Size X")
  89. elif metaelem.type == 'PLANE':
  90. sub.prop(metaelem, "size_x", text="Size X")
  91. sub.prop(metaelem, "size_y", text="Y")
  92. class DATA_PT_custom_props_metaball(DataButtonsPanel, PropertyPanel, Panel):
  93. COMPAT_ENGINES = {'BLENDER_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
  94. _context_path = "object.data"
  95. _property_type = bpy.types.MetaBall
  96. classes = (
  97. DATA_PT_context_metaball,
  98. DATA_PT_metaball,
  99. DATA_PT_mball_texture_space,
  100. DATA_PT_metaball_element,
  101. DATA_PT_custom_props_metaball,
  102. )
  103. if __name__ == "__main__": # only for live edit.
  104. from bpy.utils import register_class
  105. for cls in classes:
  106. register_class(cls)