本文整理汇总了Python中mathutils.Matrix.Scale方法的典型用法代码示例。如果您正苦于以下问题:Python Matrix.Scale方法的具体用法?Python Matrix.Scale怎么用?Python Matrix.Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mathutils.Matrix
的用法示例。
在下文中一共展示了Matrix.Scale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: execute
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def execute(self, context):
from . import export_obj
from mathutils import Matrix
keywords = self.as_keywords(ignore=("axis_forward",
"axis_up",
"global_scale",
"check_existing",
"filter_glob",
))
global_matrix = (Matrix.Scale(self.global_scale, 4) *
axis_conversion(to_forward=self.axis_forward,
to_up=self.axis_up,
).to_4x4())
keywords["global_matrix"] = global_matrix
return export_obj.save(context, **keywords)
示例2: execute
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def execute(self, context):
from . import export_x3d
from mathutils import Matrix
keywords = self.as_keywords(ignore=("axis_forward",
"axis_up",
"global_scale",
"check_existing",
"filter_glob",
))
global_matrix = axis_conversion(to_forward=self.axis_forward,
to_up=self.axis_up,
).to_4x4() * Matrix.Scale(self.global_scale, 4)
keywords["global_matrix"] = global_matrix
return export_x3d.save(context, **keywords)
示例3: execute
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def execute(self, context):
from mathutils import Matrix
if not self.filepath:
raise Exception("filepath not set")
global_matrix = (Matrix.Scale(self.global_scale, 4) *
axis_conversion(to_forward=self.axis_forward,
to_up=self.axis_up,
).to_4x4())
keywords = self.as_keywords(ignore=("global_scale",
"check_existing",
"filter_glob",
"ui_tab",
))
keywords["global_matrix"] = global_matrix
if self.version == 'BIN7400':
from . import export_fbx_bin
return export_fbx_bin.save(self, context, **keywords)
else:
from . import export_fbx
return export_fbx.save(self, context, **keywords)
示例4: __init__
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def __init__(self, filepath, do_colormanage):
"""
Initialize SVG loader
"""
node = xml.dom.minidom.parse(filepath)
m = Matrix()
m = m * Matrix.Scale(1.0 / 90.0 * 0.3048 / 12.0, 4, Vector((1.0, 0.0, 0.0)))
m = m * Matrix.Scale(-1.0 / 90.0 * 0.3048 / 12.0, 4, Vector((0.0, 1.0, 0.0)))
rect = (1, 1)
self._context = {'defines': {},
'transform': [],
'rects': [rect],
'rect': rect,
'matrix': m,
'materials': {},
'styles': [None],
'style': None,
'do_colormanage': do_colormanage}
super().__init__(node, self._context)
示例5: execute
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def execute(self, context):
from . import export_ply
from mathutils import Matrix
keywords = self.as_keywords(ignore=("axis_forward",
"axis_up",
"global_scale",
"check_existing",
"filter_glob",
))
global_matrix = axis_conversion(to_forward=self.axis_forward,
to_up=self.axis_up,
).to_4x4() * Matrix.Scale(self.global_scale, 4)
keywords["global_matrix"] = global_matrix
filepath = self.filepath
filepath = bpy.path.ensure_ext(filepath, self.filename_ext)
return export_ply.save(self, context, **keywords)
示例6: create_random_floorplan
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def create_random_floorplan(bm, prop):
"""Create randomly generated building floorplan
"""
random.seed(prop.seed)
scale_x = Matrix.Scale(prop.width / 2, 4, (1, 0, 0))
scale_y = Matrix.Scale(prop.length / 2, 4, (0, 1, 0))
bmesh.ops.create_grid(
bm, x_segments=1, y_segments=1, size=1, matrix=scale_x @ scale_y
)
amount = prop.extension_amount
if prop.random_extension_amount:
amount = random.randrange(len(bm.edges) // 3, len(bm.edges))
random_edges = random.sample(
list(bm.edges), amount
)
median_reference = list(bm.faces).pop().calc_center_median()
for edge in random_edges:
edge_median = calc_edge_median(edge)
middle_edge = subdivide_edge_twice_and_get_middle(bm, edge)
random_scale_and_translate(bm, middle_edge)
random_extrude(bm, middle_edge, (edge_median - median_reference).normalized())
示例7: _fill_locator_sections
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def _fill_locator_sections(model_locator_list):
"""
Fills up "Locator" sections.
:param model_locator_list:
:return:
"""
locator_sections = []
locator_i = 0
for item in model_locator_list:
# print('locator: "%s" - "%s"' % (item.name, str(item.scs_props.locator_model_hookup)))
part_section = _SectionData("Locator")
loc_name = _name_utils.tokenize_name(item.name)
part_section.props.append(("Name", loc_name))
if item.scs_props.locator_model_hookup:
part_section.props.append(("Hookup", item.scs_props.locator_model_hookup.split(':', 1)[1].strip()))
part_section.props.append(("Index", locator_i))
loc, qua, sca = _convert_utils.get_scs_transformation_components(item.matrix_world)
part_section.props.append(("Position", ["&&", loc]))
part_section.props.append(("Rotation", ["&&", qua]))
part_section.props.append(("Scale", ["&&", sca]))
locator_sections.append(part_section)
locator_i += 1
return locator_sections
示例8: draw_model_box
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def draw_model_box(mat, scs_globals):
"""
Draw Cube for Model locator.
:param mat:
:param scs_globals:
:return:
"""
mat1 = mat @ (Matrix.Translation((0.0, 0.0, 0.0)) @
Matrix.Scale(scs_globals.locator_size / 5, 4, (1.0, 0.0, 0.0)) @
Matrix.Scale(scs_globals.locator_size / 5, 4, (0.0, 1.0, 0.0)) @
Matrix.Scale(scs_globals.locator_size / 5, 4, (0.0, 0.0, 1.0)))
cube_vertices, cube_faces, cube_wire_lines = _primitive.get_box_data()
_primitive.draw_polygon_object(mat1,
cube_vertices,
cube_faces,
scs_globals.locator_coll_face_color,
False,
True,
wire_lines=cube_wire_lines,
wire_color=scs_globals.locator_model_wire_color)
示例9: draw_model_locator
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def draw_model_locator(obj, scs_globals):
"""
Draw Model locator.
:param obj:
:return:
"""
import mathutils
size = scs_globals.locator_size
empty_size = scs_globals.locator_empty_size
mat_sca = mathutils.Matrix.Scale(size, 4)
mat_orig = obj.matrix_world
mat = mat_orig @ mat_sca
_primitive.draw_shape_x_axis(mat, empty_size)
_primitive.draw_shape_y_axis_neg(mat, empty_size)
_primitive.draw_shape_z_axis(mat, empty_size)
draw_shape_model_locator(mat, scs_globals)
if not obj.scs_props.locator_preview_model_present:
draw_model_box(mat_orig, scs_globals)
示例10: _get_delta_matrix
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def _get_delta_matrix(bone_rest_matrix_scs, parent_bone_rest_matrix_scs, bone_animation_matrix_scs, import_scale):
"""."""
scale_matrix = Matrix.Scale(import_scale, 4)
# NOTE: apply scaling bone rest matrix, because it's subtracted by bone rest matrix inverse
loc, rot, sca = bone_rest_matrix_scs.decompose()
scale = Matrix.Identity(4)
scale[0] = (sca[0], 0, 0, 0)
scale[1] = (0, sca[1], 0, 0)
scale[2] = (0, 0, sca[2], 0)
return (scale_matrix @
scale @
bone_rest_matrix_scs.inverted() @
parent_bone_rest_matrix_scs @
bone_animation_matrix_scs)
示例11: execute
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def execute(self, context):
from . import stl_utils
from . import blender_utils
from mathutils import Matrix
paths = [os.path.join(self.directory, name.name)
for name in self.files]
scene = context.scene
# Take into account scene's unit scale, so that 1 inch in Blender gives 1 inch elsewhere! See T42000.
global_scale = self.global_scale
if scene.unit_settings.system != 'NONE' and self.use_scene_unit:
global_scale /= scene.unit_settings.scale_length
global_matrix = axis_conversion(from_forward=self.axis_forward,
from_up=self.axis_up,
).to_4x4() * Matrix.Scale(global_scale, 4)
if not paths:
paths.append(self.filepath)
if bpy.ops.object.mode_set.poll():
bpy.ops.object.mode_set(mode='OBJECT')
if bpy.ops.object.select_all.poll():
bpy.ops.object.select_all(action='DESELECT')
for path in paths:
objName = bpy.path.display_name(os.path.basename(path))
tris, tri_nors, pts = stl_utils.read_stl(path)
tri_nors = tri_nors if self.use_facet_normal else None
blender_utils.create_and_link_mesh(objName, tris, tri_nors, pts, global_matrix)
return {'FINISHED'}
示例12: SVGTransformScale
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def SVGTransformScale(params):
"""
scale SVG transform command
"""
sx = float(params[0])
sy = float(params[1]) if len(params) > 1 else sx
m = Matrix()
m = m * Matrix.Scale(sx, 4, Vector((1.0, 0.0, 0.0)))
m = m * Matrix.Scale(sy, 4, Vector((0.0, 1.0, 0.0)))
return m
示例13: cube
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def cube(bm, width=2, length=2, height=2):
""" Create a cube in the given bmesh
"""
sc_x = Matrix.Scale(width, 4, (1, 0, 0))
sc_y = Matrix.Scale(length, 4, (0, 1, 0))
sc_z = Matrix.Scale(height, 4, (0, 0, 1))
mat = sc_x @ sc_y @ sc_z
return bmesh.ops.create_cube(bm, size=1, matrix=mat)
示例14: plane
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def plane(bm, width=2, length=2):
""" Create a plane in the given bmesh
"""
sc_x = Matrix.Scale(width, 4, (1, 0, 0))
sc_y = Matrix.Scale(length, 4, (0, 1, 0))
mat = sc_x @ sc_y
return bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=1, matrix=mat)
示例15: exp_tex_noise
# 需要导入模块: from mathutils import Matrix [as 别名]
# 或者: from mathutils.Matrix import Scale [as 别名]
def exp_tex_noise(socket, exp_list):
# default if socket.name == "Fac"
function_path = "/DatasmithBlenderContent/MaterialFunctions/Noise"
out_socket = 0
if socket.name == "Color":
out_socket = 1
n = Node("FunctionCall", { "Function": function_path})
exp_1 = get_expression(socket.node.inputs['Vector'], exp_list)
exp_2 = get_expression(socket.node.inputs['Scale'], exp_list)
if exp_1:
n.push(Node("0", exp_1))
n.push(Node("1", exp_2))
return { "expression": exp_list.push(n), "OutputIndex":out_socket }