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:
authorFlorian Meyer <florianfelix@web.de>2010-05-16 22:01:11 +0400
committerFlorian Meyer <florianfelix@web.de>2010-05-16 22:01:11 +0400
commitef71d65d3c9f54b29b4befec0a534866c8cc3cb5 (patch)
tree8dcf7c1a58ba9b2e7597c1457597675109f520f7 /add_mesh_twisted_torus.py
parentd61abf20a2960bfa3099b3fc7f1699d0e3f82af7 (diff)
align_matrix for the rest add mesh scripts
all done now
Diffstat (limited to 'add_mesh_twisted_torus.py')
-rw-r--r--add_mesh_twisted_torus.py34
1 files changed, 19 insertions, 15 deletions
diff --git a/add_mesh_twisted_torus.py b/add_mesh_twisted_torus.py
index cc8be0a3..4a538ea0 100644
--- a/add_mesh_twisted_torus.py
+++ b/add_mesh_twisted_torus.py
@@ -80,18 +80,18 @@ def store_recall_properties(ob, op, op_args):
ob['recall'] = recall_properties
-# Apply view rotation to objects if "Align To" for
-# new objects was set to "VIEW" in the User Preference.
-def apply_object_align(context, ob):
- obj_align = bpy.context.user_preferences.edit.object_align
-
+# calculates the matrix for the new object
+# depending on user pref
+def align_matrix(context):
+ loc = TranslationMatrix(context.scene.cursor_location)
+ obj_align = context.user_preferences.edit.object_align
if (context.space_data.type == 'VIEW_3D'
and obj_align == 'VIEW'):
- view3d = context.space_data
- region = view3d.region_3d
- viewMatrix = region.view_matrix
- rot = viewMatrix.rotation_part()
- ob.rotation_euler = rot.invert().to_euler()
+ rot = context.space_data.region_3d.view_matrix.rotation_part().invert().resize4x4()
+ else:
+ rot = Matrix()
+ align_matrix = loc * rot
+ return align_matrix
# Create a new mesh (object) from verts/edges/faces.
@@ -100,7 +100,7 @@ def apply_object_align(context, ob):
# name ... Name of the new mesh (& object).
# edit ... Replace existing mesh data.
# Note: Using "edit" will destroy/delete existing mesh data.
-def create_mesh_object(context, verts, edges, faces, name, edit):
+def create_mesh_object(context, verts, edges, faces, name, edit, align_matrix):
scene = context.scene
obj_act = scene.objects.active
@@ -153,9 +153,8 @@ def create_mesh_object(context, verts, edges, faces, name, edit):
ob_new.selected = True
# Place the object at the 3D cursor location.
- ob_new.location = scene.cursor_location
-
- apply_object_align(context, ob_new)
+ # apply viewRotaion
+ ob_new.matrix = align_matrix
if obj_act and obj_act.mode == 'EDIT':
if not edit:
@@ -349,6 +348,7 @@ class AddTwistedTorus(bpy.types.Operator):
min=0.01,
max=100.0,
default=0.5)
+ align_matrix = Matrix()
def execute(self, context):
props = self.properties
@@ -367,7 +367,7 @@ class AddTwistedTorus(bpy.types.Operator):
# Actually create the mesh object from this geometry data.
obj = create_mesh_object(context, verts, [], faces, "TwistedTorus",
- props.edit)
+ props.edit, self.align_matrix)
# Store 'recall' properties in the object.
recall_args_list = {
@@ -384,6 +384,10 @@ class AddTwistedTorus(bpy.types.Operator):
return {'FINISHED'}
+ def invoke(self, context, event):
+ self.align_matrix = align_matrix(context)
+ self.execute(context)
+ return {'FINISHED'}
# Add to the menu
menu_func = (lambda self,