diff options
Diffstat (limited to 'add_mesh_extra_objects/add_mesh_menger_sponge.py')
-rw-r--r-- | add_mesh_extra_objects/add_mesh_menger_sponge.py | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/add_mesh_extra_objects/add_mesh_menger_sponge.py b/add_mesh_extra_objects/add_mesh_menger_sponge.py index 1e58ebce..3f9ec241 100644 --- a/add_mesh_extra_objects/add_mesh_menger_sponge.py +++ b/add_mesh_extra_objects/add_mesh_menger_sponge.py @@ -3,13 +3,18 @@ # This file is distributed under the MIT License. See the LICENSE.md for more details. import bpy +from bpy.props import ( + IntProperty, + BoolProperty, + BoolVectorProperty, + FloatVectorProperty, + FloatProperty, + ) -from bpy.props import IntProperty, BoolProperty, BoolVectorProperty, FloatVectorProperty, FloatProperty - -import bpy import mathutils import copy + class MengerSponge(object): FACE_INDICES = [ [3, 7, 4, 0], @@ -111,13 +116,13 @@ class MengerSponge(object): continue next_points = [ local_vert_map[(x, y, z)], - local_vert_map[(x+1, y, z)], - local_vert_map[(x+1, y, z+1)], - local_vert_map[(x, y, z+1)], - local_vert_map[(x, y+1, z)], - local_vert_map[(x+1, y+1, z)], - local_vert_map[(x+1, y+1, z+1)], - local_vert_map[(x, y+1, z+1)], + local_vert_map[(x + 1, y, z)], + local_vert_map[(x + 1, y, z + 1)], + local_vert_map[(x, y, z + 1)], + local_vert_map[(x, y + 1, z)], + local_vert_map[(x + 1, y + 1, z)], + local_vert_map[(x + 1, y + 1, z + 1)], + local_vert_map[(x, y + 1, z + 1)], ] visibility = copy.copy(self.__face_visibility[(x, y, z)]) if face_vis: @@ -134,44 +139,43 @@ class MengerSponge(object): class AddMengerSponge(bpy.types.Operator): - """Add a menger sponge""" bl_idname = "mesh.menger_sponge_add" bl_label = "Menger Sponge" + bl_description = "Construct a menger sponge mesh" bl_options = {'REGISTER', 'UNDO'} level = IntProperty( - name="Level", - description="Sponge Level", - min=0, max=4, - default=1, - ) - + name="Level", + description="Sponge Level", + min=0, max=4, + default=1, + ) radius = FloatProperty( - name="Width", - description="Sponge Radius", - min=0.01, max=100.0, - default=1.0, - ) - + name="Width", + description="Sponge Radius", + min=0.01, max=100.0, + default=1.0, + ) # generic transform props view_align = BoolProperty( - name="Align to View", - default=False, - ) + name="Align to View", + default=False, + ) location = FloatVectorProperty( - name="Location", - subtype='TRANSLATION', - ) + name="Location", + subtype='TRANSLATION', + ) rotation = FloatVectorProperty( - name="Rotation", - subtype='EULER', - ) + name="Rotation", + subtype='EULER', + ) layers = BoolVectorProperty( - name="Layers", - size=20, - subtype='LAYER', - options={'HIDDEN', 'SKIP_SAVE'}, - ) + name="Layers", + size=20, + subtype='LAYER', + options={'HIDDEN', 'SKIP_SAVE'}, + ) + def execute(self, context): sponger = MengerSponge(self.level) vertices, faces = sponger.create(self.radius * 2, self.radius * 2) @@ -182,7 +186,7 @@ class AddMengerSponge(bpy.types.Operator): uvs = [(0.0, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0)] mesh.uv_textures.new() for i, uvloop in enumerate(mesh.uv_layers.active.data): - uvloop.uv = uvs[i%4] + uvloop.uv = uvs[i % 4] from bpy_extras import object_utils object_utils.object_data_add(context, mesh, operator=self) |