Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2016-12-30 22:33:05 +0300
committerlijenstina <lijenstina@gmail.com>2016-12-30 22:33:05 +0300
commitc86080a455579a8c770545e33b95513b43e1a43b (patch)
tree6c392b16b914aa3264b373022602e57ad493e7d7 /add_mesh_extra_objects/add_mesh_menger_sponge.py
parentc95e86bcef654c0686d3cf4d52446ff9ff8c819f (diff)
Add mesh extra objects: Update to version 0.3.1
General Pep8 cleanup Removed unused variables and imports Removed a panel from add_empty_as_parent Standardized the property definitions across all the scripts Moved scene props from third_domes_panel_271 to init for proper removal Added a Enum prop for mesh type in teapot Fixed a small issue with Geodesic domes self.reports (problem with value fields message spam) Fixed props names in Geodesic domes Consistent tooltips Reorganized menus: Mechanical Menu including Pipe joints, Mesh gear Added separators
Diffstat (limited to 'add_mesh_extra_objects/add_mesh_menger_sponge.py')
-rw-r--r--add_mesh_extra_objects/add_mesh_menger_sponge.py80
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)