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:
authorCampbell Barton <ideasman42@gmail.com>2011-11-19 20:19:08 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-11-19 20:19:08 +0400
commit9ac0a714bee5df2153e0a73bb55962139ba18eb2 (patch)
tree029104d14b7e942dd616bf8443e09d0461ac6350 /add_mesh_extra_objects
parent5e44117da5a35882e7f3919f4c48c234acebe045 (diff)
indentation edits and copy pyrimid from contrib (where I had made some edits), removed so this wont happen again.
Diffstat (limited to 'add_mesh_extra_objects')
-rw-r--r--add_mesh_extra_objects/add_mesh_pyramid.py186
1 files changed, 111 insertions, 75 deletions
diff --git a/add_mesh_extra_objects/add_mesh_pyramid.py b/add_mesh_extra_objects/add_mesh_pyramid.py
index 92f7f851..5ea2a5e6 100644
--- a/add_mesh_extra_objects/add_mesh_pyramid.py
+++ b/add_mesh_extra_objects/add_mesh_pyramid.py
@@ -1,5 +1,3 @@
-# add_mesh_pyramid.py (c) 2011 Phil Cote (cotejrp1)
-#
# ***** BEGIN GPL LICENSE BLOCK *****
#
#
@@ -18,106 +16,144 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ***** END GPL LICENCE BLOCK *****
-'''
+
+# (c) 2011 Phil Cote (cotejrp1)
+
bl_info = {
'name': 'Mesh Pyramid',
'author': 'Phil Cote, cotejrp1, (http://www.blenderaddons.com)',
- 'version': (0,1),
- "blender": (2, 5, 7),
- "api": 35853,
+ 'version': (0, 3),
+ "blender": (2, 5, 8),
+ "api": 37702,
'location': 'View3D > Add > Mesh',
'description': 'Create an egyption-style step pyramid',
- 'warning': '', # used for warning icon and text in addons panel
+ 'warning': '', # used for warning icon and text in addons panel
'category': 'Add Mesh'}
-'''
+
import bpy
-from bpy.props import FloatVectorProperty, IntProperty, FloatProperty
+from bpy.props import (FloatVectorProperty,
+ IntProperty,
+ FloatProperty,
+ BoolProperty)
+
from add_utils import AddObjectHelper, add_object_data
from mathutils import Vector
-def makePyramid( initialSize, stepHeight, stepWidth, numberSteps ):
-
- vertList = []
- faceList = []
-
- curSize = initialSize # how large each step will be overall
-
+
+def makePyramid(initial_size, step_height, step_width, number_steps):
+
+ vert_list = []
+ face_list = []
+
+ cur_size = initial_size # how large each step will be overall
+
# b = buttom, t = top, f = front, b = back, l = left, r = right
x = y = z = 0
- voffset = 0 # refers relative vert indices to help make faces fo each step
- sn = 0 # step number
-
- while sn < numberSteps:
- # bottom verts for this iteration
- bfl = (x,y,z)
- bfr = (x+curSize, y, z)
- bbl = (x,y+curSize,z)
- bbr = (x+curSize, y+curSize, z)
-
+ voffset = 0 # relative vert indices to help make faces fo each step
+ sn = 0 # step number
+
+ while sn < number_steps:
+ # bottom verts for this iteration
+ bfl = (x, y, z)
+ bfr = (x + cur_size, y, z)
+ bbl = (x, y + cur_size, z)
+ bbr = (x + cur_size, y + cur_size, z)
+
# top verts for this iteration.
- tfl = (x,y,z+stepHeight)
- tfr = (x+curSize, y, z+stepHeight)
- tbl = (x,y+curSize,z+stepHeight)
- tbr = (x+curSize, y+curSize, z+stepHeight)
-
+ tfl = (x, y, z + step_height)
+ tfr = (x + cur_size, y, z + step_height)
+ tbl = (x, y + cur_size, z + step_height)
+ tbr = (x + cur_size, y + cur_size, z + step_height)
+
# add to the vert buffer
- vertList.extend( ( bfl, bfr, bbl, bbr, tfl, tfr, tbl, tbr, ) )
-
+ vert_list.extend((bfl, bfr, bbl, bbr, tfl, tfr, tbl, tbr,))
+
# side faces
- faceList.extend( ( ( voffset+4, voffset+5, voffset+1, voffset+0 ), ) )# front
- faceList.extend( ( ( voffset+6, voffset+7, voffset+3, voffset+2 ), ) )# back
- faceList.extend( ( ( voffset+2, voffset+6, voffset+4, voffset+0 ), ) ) # left
- faceList.extend( ( ( voffset+3, voffset+7, voffset+5, voffset+1 ), ) ) # right
-
-
- # horizontal connecting faces ( note: not applicable for the first iteration ).
+ face_list.extend((
+ (voffset + 4, voffset + 5, voffset + 1, voffset + 0), # back
+ (voffset + 6, voffset + 7, voffset + 3, voffset + 2), # front
+ (voffset + 2, voffset + 6, voffset + 4, voffset + 0), # left
+ (voffset + 3, voffset + 7, voffset + 5, voffset + 1), # right
+ ))
+
+ # horizontal connecting faces ( note: n/a for the first iteration ).
if voffset > 0:
- faceList.extend( ( (voffset-4, voffset-3, voffset+1, voffset+0 ), ) ) # connector front
- faceList.extend( ( (voffset-2, voffset-1, voffset+3, voffset+2 ), ) ) # back
- faceList.extend( ( (voffset-4, voffset-2, voffset+2, voffset+0 ), ) ) # left
- faceList.extend( ( (voffset-3, voffset-1, voffset+3, voffset+1 ), ) ) # right
-
-
+ face_list.extend((
+ (voffset - 4, voffset - 3, voffset + 1, voffset + 0), # connector front
+ (voffset - 2, voffset - 1, voffset + 3, voffset + 2), # back
+ (voffset - 4, voffset - 2, voffset + 2, voffset + 0), # left
+ (voffset - 3, voffset - 1, voffset + 3, voffset + 1), # right
+ ))
+
# set up parameters for the next iteration
- curSize = curSize - ( stepWidth * 2 )
- x = x + stepWidth
- y = y + stepWidth
- z = z + stepHeight
+ cur_size = cur_size - (step_width * 2)
+ x = x + step_width
+ y = y + step_width
+ z = z + step_height
sn = sn + 1
voffset = voffset + 8
-
-
- # cap the top.
- voffset = voffset - 8 # corrects for the unnecessary voffset change done final iteration
- faceList.extend( ( (voffset+6, voffset+7, voffset+5, voffset+4), ) )
-
- # cap the bottom.
- faceList.extend( ( ( 2, 3, 1, 0), ) )
- return vertList, faceList
-
-
-def add_pyramid_object( self, context ):
- verts, faces = makePyramid( self.initialSize, self.stepHeight, self.stepWidth, self.numberSteps )
- mesh_data = bpy.data.meshes.new( name = "Pyramid" )
- mesh_data.from_pydata( verts, [], faces )
+
+ voffset = voffset - 8 # remove extra voffset done on final iteration
+ face_list.extend((
+ (voffset + 6, voffset + 7, voffset + 5, voffset + 4), # cap the top.
+ (2, 3, 1, 0), # cap the bottom.
+ ))
+
+ return vert_list, face_list
+
+
+def add_pyramid_object(self, context):
+ verts, faces = makePyramid(self.initial_size, self.step_height,
+ self.step_width, self.number_steps)
+
+ mesh_data = bpy.data.meshes.new(name="Pyramid")
+ mesh_data.from_pydata(verts, [], faces)
mesh_data.update()
- res = add_object_data( context, mesh_data, operator=self )
-
-
+ res = add_object_data(context, mesh_data, operator=self)
+
+
class OBJECT_OT_add_pyramid(bpy.types.Operator, AddObjectHelper):
"""Add a Mesh Object"""
- bl_idname = "mesh.primative_step_pyramid_add"
+ bl_idname = "mesh.step_pyramid_add"
bl_label = "Pyramid"
bl_description = "Create a Pyramid Mesh"
bl_options = {'REGISTER', 'UNDO'}
-
- initialSize = FloatProperty( name="Initial Size", default=2.0, min=0.0, max=20.0 )
- stepHeight= FloatProperty( name="Step Height", default=0.2, min=0.0, max=10.0 )
- stepWidth= FloatProperty( name="Step Width", default=0.2, min=0.0, max=10.0 )
- numberSteps= IntProperty( name="Number Steps", default=5, min=1, max=20 )
-
+
+ initial_size = FloatProperty(name="Initial Size", default=2.0,
+ min=0.0, max=20.0,
+ description="Set the initial size at the pyramid base")
+
+ step_height = FloatProperty(name="Step Height", default=0.1,
+ min=0.0, max=10.0,
+ description="How tall each of the steps will be")
+
+ step_width = FloatProperty(name="Step Width", default=0.1,
+ min=0.0, max=10.0,
+ description="How wide each step will be")
+
+ number_steps = IntProperty(name="Number Steps", default=10,
+ min=1, max=20,
+ description="Total number of steps")
def execute(self, context):
add_pyramid_object(self, context)
return {'FINISHED'}
+
+
+def menu_func(self, context):
+ self.layout.operator(OBJECT_OT_add_pyramid.bl_idname,
+ text="Pyramid", icon="PLUGIN")
+
+
+def register():
+ bpy.utils.register_class(OBJECT_OT_add_pyramid)
+ bpy.types.INFO_MT_mesh_add.append(menu_func)
+
+
+def unregister():
+ bpy.utils.unregister_class(OBJECT_OT_add_pyramid)
+ bpy.types.INFO_MT_mesh_add.remove(menu_func)
+
+if __name__ == "__main__":
+ register()