本文整理汇总了Python中mathutils.Matrix类的典型用法代码示例。如果您正苦于以下问题:Python Matrix类的具体用法?Python Matrix怎么用?Python Matrix使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matrix类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: copyto
def copyto(scene, source_obj, pos, xdir, zdir, axes, scale=None):
"""
copy the source_obj to pos, so its primary axis points in zdir and its
secondary axis points in xdir
"""
copy_obj = source_obj.copy()
scene.objects.link(copy_obj)
xdir = xdir.normalized()
zdir = zdir.normalized()
#rotation first
z_axis = zdir
x_axis = xdir
y_axis = z_axis.cross(x_axis)
#use axes_dict to assign the axis as chosen in panel
A, B, C = axes_dict[axes]
rot_mat = Matrix()
rot_mat[A].xyz = x_axis
rot_mat[B].xyz = y_axis
rot_mat[C].xyz = z_axis
rot_mat.transpose()
#rotate object
copy_obj.matrix_world = rot_mat
#move object into position
copy_obj.location = pos
#scale object
if scale != None:
copy_obj.scale = scale
return copy_obj
开发者ID:tr37ion,项目名称:blenderpython,代码行数:33,代码来源:copy2.py
示例2: get_coconuts_mesh
def get_coconuts_mesh(context, prefs):
me = context.blend_data.meshes.new('temp_mesh')
bm = bmesh.new()
bm.from_mesh(me)
mat = Matrix()
trunk_length = prefs.palm_stage_length * prefs.palm_stages
coconutX = (0.29, -0.29, 0, 0)
coconutY = (0, 0, 0.29, -0.29)
coconutZ = trunk_length - 0.2
coconuts = get_random(prefs.lp_Tree_Palm_Top_Coconuts_Min,
prefs.lp_Tree_Palm_Top_Coconuts_Max)
for i in range(0, coconuts):
mat.translation = (coconutX[i], coconutY[i], coconutZ)
bmesh.ops.create_icosphere(
bm,
subdivisions=1,
diameter=0.15,
matrix=mat)
bm.to_mesh(me)
return me
开发者ID:luboslenco,项目名称:lowpolyfactory,代码行数:26,代码来源:createTreeObject.py
示例3: get_bone_matrix
def get_bone_matrix(armature, bone, relative=True):
pose_bone = armature.pose.bones[bone.name]
m = Matrix() ### inverted posebone origin matrix
m.row[0] = [0, 0, 1, 0]
m.row[1] = [1, 0, 0, 0]
m.row[2] = [0, 1, 0, 0]
m.row[3] = [0, 0, 0, 1]
if bone.parent == None:
mat_bone_space = m * pose_bone.matrix.copy()
else:
if relative:
mat_bone_space = pose_bone.parent.matrix.inverted() * pose_bone.matrix
else:
mat_bone_space = m * pose_bone.matrix
#### remap matrix
loc, rot, scale = mat_bone_space.decompose()
if not bone.use_inherit_scale:
scale = (m * pose_bone.matrix).decompose()[2]
loc_mat = Matrix.Translation(loc)
rot_mat = rot.inverted().to_matrix().to_4x4()
scale_mat = Matrix()
scale_mat[0][0] = scale[1]
scale_mat[1][1] = scale[0]
mat_bone_space = loc_mat * rot_mat * scale_mat
return mat_bone_space
开发者ID:,项目名称:,代码行数:34,代码来源:
示例4: focus_view_on
def focus_view_on(region_3d, location):
r3d = region_3d
a = r3d.view_location.copy()
b = location
mm = r3d.view_matrix.inverted()
vr = mm.to_3x3()
loc = mm.translation
n = (a-loc).cross(b-loc).normalized()
alp = math.acos( max(-1.0,min(1.0, (a-loc).normalized().dot( (b-loc).normalized() ) )))
zero = Vector()
u0,v0,w0 = vr.transposed()
u = rot_on( zero, n, alp, u0 )
v = rot_on( zero, n, alp, v0 )
w = rot_on( zero, n, alp, w0 )
if bpy.context.user_preferences.inputs.view_rotate_method == 'TURNTABLE':
ez = Vector((0,0,1))
u2 = ez.cross(w)
v2 = w.cross(u2)
u,v = u2,v2
vr2 = Matrix((u,v,w)).transposed()
mm2 = vr2.to_4x4()
mm2[0][3] = loc[0]
mm2[1][3] = loc[1]
mm2[2][3] = loc[2]
dist0 = (loc-location).length
r3d.view_distance = dist0
r3d.view_matrix = mm2.inverted()
开发者ID:a-nakanosora,项目名称:Focus-on-Mouse,代码行数:35,代码来源:view3d_focus_on_mouse.py
示例5: parseTree
def parseTree(tree, parentName):
# print("parsetree")
armName = bpy.context.active_object.name
armatures.createBone(armName, tree.name, parentName)
bpy.ops.roboteditor.select_segment(segment_name=tree.name)
# print(tree.name)
boneProp = bpy.context.active_bone.RobotEditor
m = Matrix()
# print(tree.transformations)
for i in tree.transformations:
# We expect a matrix here!
# Todo accept rotation and translations too!
if type(i[0]) is list:
m = m * Matrix(i)
elif len(i) == 3:
# TODO
pass
elif len(i) == 4:
# TODO
pass
else:
raise Exception("ParsingError")
# print(m)
bpy.context.active_bone.RobotEditor.Euler.x.value = m.translation[0] / 1000
bpy.context.active_bone.RobotEditor.Euler.y.value = m.translation[1] / 1000
bpy.context.active_bone.RobotEditor.Euler.z.value = m.translation[2] / 1000
bpy.context.active_bone.RobotEditor.Euler.gamma.value = degrees(m.to_euler().z)
bpy.context.active_bone.RobotEditor.Euler.beta.value = degrees(m.to_euler().y)
bpy.context.active_bone.RobotEditor.Euler.alpha.value = degrees(m.to_euler().x)
if tree.axis_type == 'revolute':
bpy.context.active_bone.RobotEditor.jointMode = 'REVOLUTE'
# boneProp.theta.value = float(tree.initalValue)
bpy.context.active_bone.RobotEditor.theta.max = float(tree.max)
bpy.context.active_bone.RobotEditor.theta.min = float(tree.min)
else:
bpy.context.active_bone.RobotEditor.jointMode = 'PRISMATIC'
# boneProp.d.value = float(tree.initialValue)
bpy.context.active_bone.RobotEditor.d.max = float(tree.max)
bpy.context.active_bone.RobotEditor.d.min = float(tree.min)
if tree.axis is not None:
for i, axis in enumerate(tree.axis):
if axis == -1.0:
bpy.context.active_bone.RobotEditor.axis_revert = True
tree.axis[i] = 1.0
if tree.axis == [1.0, 0.0, 0.0]:
bpy.context.active_bone.RobotEditor.axis = 'X'
elif tree.axis == [0.0, 1.0, 0.0]:
bpy.context.active_bone.RobotEditor.axis = 'Y'
elif tree.axis == [0.0, 0.0, 1.0]:
bpy.context.active_bone.RobotEditor.axis = 'Z'
# print("parsetree done")
for child in tree.children:
parseTree(child, tree.name)
开发者ID:HBPNeurorobotics,项目名称:BlenderRobotDesigner,代码行数:60,代码来源:files.py
示例6: make_tube
def make_tube(self, mats, verts):
edges_out = []
verts_out = []
faces_out = []
vID = 0
nring = len(verts[0])
# end face
faces_out.append(list(range(nring)))
for i,m in enumerate(mats):
for j,v in enumerate(verts[0]):
vout = Matrix(m) * Vector(v)
verts_out.append(vout.to_tuple())
vID = j + i*nring
# rings
if j != 0:
edges_out.append([vID, vID - 1])
else:
edges_out.append([vID, vID + nring-1])
# lines
if i != 0:
edges_out.append([vID, vID - nring])
# faces
if j != 0:
faces_out.append([vID, vID - nring, vID - nring - 1, vID-1,])
else:
faces_out.append([vID, vID - nring, vID-1, vID + nring-1])
# end face
# reversing list fixes face normal direction keeps mesh manifold
f = list(range(vID, vID-nring, -1))
faces_out.append(f)
return verts_out, edges_out, faces_out
开发者ID:TakamitsuNobe,项目名称:myblendercontrib,代码行数:31,代码来源:matrix_tube.py
示例7: print_mat
def print_mat(label, matrix, column=4):
if isinstance(matrix[0], (float, int)):
# buffer用
if len(matrix) == 16:
mat = [matrix[:4], matrix[4:8], matrix[8:12], matrix[12:16]]
matrix = Matrix(mat)
elif len(matrix) == 9:
matrix = Matrix([matrix[:3], matrix[3:6], matrix[6:9]])
elif len(matrix) == 4:
matrix = Matrix([matrix[:2], matrix[2:4]])
print(label)
t2 = 'row{0} [{1:>{5}.{6}f}, {2:>{5}.{6}f}]'
t3 = 'row{0} [{1:>{5}.{6}f}, {2:>{5}.{6}f}, {3:>{5}.{6}f}]'
t4 = 'row{0} [{1:>{5}.{6}f}, {2:>{5}.{6}f}, {3:>{5}.{6}f}, {4:>{5}.{6}f}]'
m = matrix.transposed()
for cnt, row in enumerate(m):
if len(row) == 2:
print(t2.format(cnt, row[0], row[1], 0, 0, column + 3, column))
elif len(row) == 3:
print(t3.format(cnt, row[0], row[1], row[2], 0,
column + 3, column))
else:
print(t4.format(cnt, row[0], row[1], row[2], row[3],
column + 3, column))
开发者ID:Italic-,项目名称:blenderpython,代码行数:25,代码来源:vautils.py
示例8: fit_cubicbezier
def fit_cubicbezier(l_v, l_t):
#########################################################
# http://nbviewer.ipython.org/gist/anonymous/5688579
# make the summation functions for A (16 of them)
A_fns = [
lambda l_t: sum([2*t**0*(t-1)**6 for t in l_t]),
lambda l_t: sum([-6*t**1*(t-1)**5 for t in l_t]),
lambda l_t: sum([6*t**2*(t-1)**4 for t in l_t]),
lambda l_t: sum([-2*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([-6*t**1*(t-1)**5 for t in l_t]),
lambda l_t: sum([18*t**2*(t-1)**4 for t in l_t]),
lambda l_t: sum([-18*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([6*t**4*(t-1)**2 for t in l_t]),
lambda l_t: sum([6*t**2*(t-1)**4 for t in l_t]),
lambda l_t: sum([-18*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([18*t**4*(t-1)**2 for t in l_t]),
lambda l_t: sum([-6*t**5*(t-1)**1 for t in l_t]),
lambda l_t: sum([-2*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([6*t**4*(t-1)**2 for t in l_t]),
lambda l_t: sum([-6*t**5*(t-1)**1 for t in l_t]),
lambda l_t: sum([2*t**6*(t-1)**0 for t in l_t])
]
# make the summation functions for b (4 of them)
b_fns = [
lambda l_t, l_v: sum(v * (-2 * (t**0) * ((t-1)**3))
for t, v in zip(l_t, l_v)),
lambda l_t, l_v: sum(v * (6 * (t**1) * ((t-1)**2))
for t, v in zip(l_t, l_v)),
lambda l_t, l_v: sum(v * (-6 * (t**2) * ((t-1)**1))
for t, v in zip(l_t, l_v)),
lambda l_t, l_v: sum(v * (2 * (t**3) * ((t-1)**0))
for t, v in zip(l_t, l_v)),
]
# compute the data we will put into matrix A
A_values = [fn(l_t) for fn in A_fns]
# fill the A matrix with data
A_matrix = Matrix(tuple(zip(*[iter(A_values)]*4)))
try:
A_inv = A_matrix.inverted()
except:
return (float('inf'), l_v[0], l_v[0], l_v[0], l_v[0])
# compute the data we will put into the b vector
b_values = [fn(l_t, l_v) for fn in b_fns]
# fill the b vector with data
b_vector = Vector(b_values)
# solve for the unknowns in vector x
v0, v1, v2, v3 = A_inv * b_vector
err = compute_cubic_error(v0, v1, v2, v3, l_v, l_t) / len(l_v)
return (err, v0, v1, v2, v3)
开发者ID:CGCookie,项目名称:retopoflow,代码行数:59,代码来源:bezier.py
示例9: matchPoseReverse
def matchPoseReverse(pb, src):
gmat = src.matrix
tail = gmat.col[3] + src.length * gmat.col[1]
rmat = Matrix((gmat.col[0], -gmat.col[1], -gmat.col[2], tail))
rmat.transpose()
pmat = getPoseMatrix(rmat, pb)
pb.matrix_basis = pmat
insertRotation(pb, pmat)
开发者ID:jultrunb,项目名称:ass,代码行数:8,代码来源:fkik.py
示例10: _convertMatrixTo4x4
def _convertMatrixTo4x4(self, value):
matrix = Matrix()
matrix[0] = value[0:4]
matrix[1] = value[4:8]
matrix[2] = value[8:12]
matrix[3] = value[12:16]
return matrix.transposed()
开发者ID:Dinicley,项目名称:virtual_reality_viewport,代码行数:9,代码来源:__init__.py
示例11: test_matrix_to_3x3
def test_matrix_to_3x3(self):
# mat =
# [ 1 2 3 4 ]
# [ 2 4 6 8 ]
# [ 3 6 9 12 ]
# [ 4 8 12 16 ]
mat = Matrix(tuple((i, 2 * i, 3 * i, 4 * i) for i in range(1, 5)))
mat_correct = Matrix(((1, 2, 3), (2, 4, 6), (3, 6, 9)))
self.assertEqual(mat.to_3x3(), mat_correct)
开发者ID:,项目名称:,代码行数:9,代码来源:
示例12: _parseVertices
def _parseVertices( self, mesh ):
'''
Extract the vertices from a blender mesh
'''
transform = Matrix().to_4x4()
transform.identity()
if not self.export_config.export_rot:
transform = self.export_config.global_matrix.to_4x4() * self.matrix_world
self.vertices = [transform * v.co for v in mesh.vertices]
开发者ID:NikolaiVChr,项目名称:Blender-AC3D,代码行数:9,代码来源:AC3D.py
示例13: parse_rotation_channel
def parse_rotation_channel(gltf, node, obj, bone, channel, animation):
"""Manage rotation animation."""
blender_path = "pose.bones[" + json.dumps(bone.name) + "].rotation_quaternion"
group_name = bone.name
keys = BinaryData.get_data_from_accessor(gltf, animation.samplers[channel.sampler].input)
values = BinaryData.get_data_from_accessor(gltf, animation.samplers[channel.sampler].output)
bind_rotation = node.blender_bone_matrix.to_quaternion()
if animation.samplers[channel.sampler].interpolation == "CUBICSPLINE":
# TODO manage tangent?
quat_keyframes = [
quaternion_gltf_to_blender(values[idx * 3 + 1])
for idx in range(0, len(keys))
]
else:
quat_keyframes = [quaternion_gltf_to_blender(vals) for vals in values]
if node.parent is None:
final_rots = [
bind_rotation.inverted() @ quat_keyframe
for quat_keyframe in quat_keyframes
]
else:
if not gltf.data.nodes[node.parent].is_joint:
parent_mat = Matrix()
else:
parent_mat = gltf.data.nodes[node.parent].blender_bone_matrix
if parent_mat != parent_mat.inverted():
final_rots = [
bind_rotation.rotation_difference(
(parent_mat @ quat_keyframe.to_matrix().to_4x4()).to_quaternion()
)
for quat_keyframe in quat_keyframes
]
else:
final_rots = [
bind_rotation.rotation_difference(quat_keyframe)
for quat_keyframe in quat_keyframes
]
# Manage antipodal quaternions
for i in range(1, len(final_rots)):
if final_rots[i].dot(final_rots[i-1]) < 0:
final_rots[i] = -final_rots[i]
BlenderBoneAnim.fill_fcurves(
obj.animation_data.action,
keys,
final_rots,
group_name,
blender_path,
animation.samplers[channel.sampler].interpolation
)
开发者ID:sambler,项目名称:myblenderaddons,代码行数:56,代码来源:gltf2_blender_animation_bone.py
示例14: sparse
def sparse(values):
"""
constructs a sparse matrix from a list of tuples (col, row, value)
"""
result = Matrix()
result.zero()
result[W][W] = 1
for cell in values:
result.col[cell[0]][cell[1]] = cell[2]
return result
开发者ID:CyberSys,项目名称:se-blender,代码行数:10,代码来源:utils.py
示例15: _transform_mesh_coordinate_system
def _transform_mesh_coordinate_system(mesh):
# This transformation swaps Y and Z axes, turning coordinate system from
# right-handed to left-handed.
transformation = Matrix()
transformation.zero()
transformation[0][0] = 1
transformation[1][2] = 1
transformation[2][1] = 1
transformation[3][3] = 1
mesh.transform(transformation)
开发者ID:vanderlokken,项目名称:storm,代码行数:10,代码来源:io_export_storm.py
示例16: cubic_bezier_fit_value
def cubic_bezier_fit_value(l_v, l_t):
def compute_error(v0,v1,v2,v3,l_v,l_t):
return math.sqrt(sum((cubic_bezier_blend_t(v0,v1,v2,v3,t)-v)**2 for v,t in zip(l_v,l_t)))
#########################################################
# http://nbviewer.ipython.org/gist/anonymous/5688579
# make the summation functions for A (16 of them)
A_fns = [
lambda l_t: sum([ 2*t**0*(t-1)**6 for t in l_t]),
lambda l_t: sum([ -6*t**1*(t-1)**5 for t in l_t]),
lambda l_t: sum([ 6*t**2*(t-1)**4 for t in l_t]),
lambda l_t: sum([ -2*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([ -6*t**1*(t-1)**5 for t in l_t]),
lambda l_t: sum([ 18*t**2*(t-1)**4 for t in l_t]),
lambda l_t: sum([-18*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([ 6*t**4*(t-1)**2 for t in l_t]),
lambda l_t: sum([ 6*t**2*(t-1)**4 for t in l_t]),
lambda l_t: sum([-18*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([ 18*t**4*(t-1)**2 for t in l_t]),
lambda l_t: sum([ -6*t**5*(t-1)**1 for t in l_t]),
lambda l_t: sum([ -2*t**3*(t-1)**3 for t in l_t]),
lambda l_t: sum([ 6*t**4*(t-1)**2 for t in l_t]),
lambda l_t: sum([ -6*t**5*(t-1)**1 for t in l_t]),
lambda l_t: sum([ 2*t**6*(t-1)**0 for t in l_t])
]
# make the summation functions for b (4 of them)
b_fns = [
lambda l_t,l_v: sum([-2*v*t**0*(t-1)**3 for t,v in zip(l_t,l_v)]),
lambda l_t,l_v: sum([ 6*v*t**1*(t-1)**2 for t,v in zip(l_t,l_v)]),
lambda l_t,l_v: sum([-6*v*t**2*(t-1)**1 for t,v in zip(l_t,l_v)]),
lambda l_t,l_v: sum([ 2*v*t**3*(t-1)**0 for t,v in zip(l_t,l_v)])
]
# compute the data we will put into matrix A
A_values = [fn(l_t) for fn in A_fns]
# fill the A matrix with data
A_matrix = Matrix(tuple(zip(*[iter(A_values)]*4)))
A_inv = A_matrix.inverted()
# compute the data we will put into the b vector
b_values = [fn(l_t, l_v) for fn in b_fns]
# fill the b vector with data
b_vector = Vector(b_values)
# solve for the unknowns in vector x
v0,v1,v2,v3 = A_inv * b_vector
err = compute_error(v0,v1,v2,v3,l_v,l_t) / len(l_v)
return (err,v0,v1,v2,v3)
开发者ID:MichaelKd,项目名称:retopoflow,代码行数:55,代码来源:polystrips_utilities.py
示例17: calculate_best_plane
def calculate_best_plane(locs):
# calculating the center of masss
com = Vector()
for loc in locs:
com += loc
com /= len(locs)
x, y, z = com
# creating the covariance matrix
mat = Matrix(((0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
(0.0, 0.0, 0.0),
))
for loc in locs:
mat[0][0] += (loc[0]-x)**2
mat[1][0] += (loc[0]-x)*(loc[1]-y)
mat[2][0] += (loc[0]-x)*(loc[2]-z)
mat[0][1] += (loc[1]-y)*(loc[0]-x)
mat[1][1] += (loc[1]-y)**2
mat[2][1] += (loc[1]-y)*(loc[2]-z)
mat[0][2] += (loc[2]-z)*(loc[0]-x)
mat[1][2] += (loc[2]-z)*(loc[1]-y)
mat[2][2] += (loc[2]-z)**2
# calculating the normal to the plane
normal = False
try:
mat.invert()
except:
if sum(mat[0]) == 0.0:
normal = Vector((1.0, 0.0, 0.0))
elif sum(mat[1]) == 0.0:
normal = Vector((0.0, 1.0, 0.0))
elif sum(mat[2]) == 0.0:
normal = Vector((0.0, 0.0, 1.0))
if not normal:
# warning! this is different from .normalize()
itermax = 500
iter = 0
vec = Vector((1.0, 1.0, 1.0))
vec2 = (mat * vec)/(mat * vec).length
while vec != vec2 and iter<itermax:
iter+=1
vec = vec2
vec2 = mat * vec
if vec2.length != 0:
vec2 /= vec2.length
if vec2.length == 0:
vec2 = Vector((1.0, 1.0, 1.0))
normal = vec2
return(com, normal)
开发者ID:tito21,项目名称:script-bakery,代码行数:55,代码来源:contour_utilities.py
示例18: unit_normal
def unit_normal(a, b, c):
mat_x = Matrix(((1, a[1], a[2]), (1, b[1], b[2]), (1, c[1], c[2])))
mat_y = Matrix(((a[0], 1, a[2]), (b[0], 1, b[2]), (c[0], 1, c[2])))
mat_z = Matrix(((a[0], a[1], 1), (b[0], b[1], 1), (c[0], c[1], 1)))
x = Matrix.determinant(mat_x)
y = Matrix.determinant(mat_y)
z = Matrix.determinant(mat_z)
magnitude = (x**2 + y**2 + z**2)**.5
return (x/magnitude, y/magnitude, z/magnitude)
开发者ID:gfcprogramer,项目名称:sverchok,代码行数:11,代码来源:area.py
示例19: to_Scene
def to_Scene(self):
if self.hasOpened:
# Load table
#
#Get the tag objects from the scene by filtering objects with
# hexadecimal strings as the first 8 chars of their name
tag_objs = {obj.name[:8]:obj for obj in bpy.data.objects if isHex(obj.name[:8])}
#
# Load placements
#
#Create a parent object to contain all placement objects
for i, p in enumerate(self.placements):
mesh = None # the mesh for the object
#The placement's index references a table item that has a tag index
if p.index >= 0 and p.index < self.n_table_items: # the index must be in the range of the table items
palette_tag_idx = self.table_items[p.index].index
try:
#apply the data if found
mesh = tag_objs[str('%08x' % palette_tag_idx).upper()].data
except KeyError:
print("Could not find tag '%08x' for placement %d" % (palette_tag_idx, i))
object = bpy.data.objects.new("Placement.%03d" % i, mesh)
#link the object to the active scene (ususally scene 0)
bpy.context.scene.objects.link(object)
for j in range(3):
object.lock_scale[j] = True #objects in forge can be only moved or rotated
#
# Apply a matrix to the object to place it correctly in the scene
#
#Recreate col1 using cross product of column vectors: col0
# and col2 that are perpendicular to one another
col2 = p.col2
col0 = p.col0
col1 = col0.cross(col2)
pos = p.pos
#Construct 3x3 matrix with column vectors for rows
mat = Matrix((col0, col1, col2))
mat.transpose() # Matrix is now correct
#Increase size from 3x3 to 4x4 to move 3D points
# as well as to rotate/scale them like a 3x3 could
mat = mat.to_4x4()
for i in range(3):
mat[i][3] = pos[i]
object.matrix_local = mat
#object.
#Assign 'Custom Properties' to the object with values from the Placement
# in order to serialize the placement later
pd = vars(p)
for key in pd.keys():
object[key] = pd[key]
#Assign the item table to the scene in order to serialize later
bpy.data.scenes[0]['item_table'] = [l.to_list() for l in self.table_items]
#Assign the entire 60k file to the scene
bpy.data.scenes[0]['usermap_data'] = struct.unpack("B" * len(self.data), self.data)
开发者ID:Gurten,项目名称:HaloOnlineTagTool,代码行数:54,代码来源:HaloOnline_usermap_io.py
示例20: pointInTri2D
def pointInTri2D(v, v1, v2, v3):
global dict_matrix
key = v1.x, v1.y, v2.x, v2.y, v3.x, v3.y
# Commented because its slower to do teh bounds check, we should realy cache the bounds info for each face.
'''
# BOUNDS CHECK
xmin= 1000000
ymin= 1000000
xmax= -1000000
ymax= -1000000
for i in (0,2,4):
x= key[i]
y= key[i+1]
if xmax<x: xmax= x
if ymax<y: ymax= y
if xmin>x: xmin= x
if ymin>y: ymin= y
x= v.x
y= v.y
if x<xmin or x>xmax or y < ymin or y > ymax:
return False
# Done with bounds check
'''
try:
mtx = dict_matrix[key]
if not mtx:
return False
except:
side1 = v2 - v1
side2 = v3 - v1
nor = side1.cross(side2)
mtx = Matrix((side1, side2, nor))
# Zero area 2d tri, even tho we throw away zerop area faces
# the projection UV can result in a zero area UV.
if not mtx.determinant():
dict_matrix[key] = None
return False
mtx.invert()
dict_matrix[key] = mtx
uvw = (v - v1) * mtx
return 0 <= uvw[0] and 0 <= uvw[1] and uvw[0] + uvw[1] <= 1
开发者ID:,项目名称:,代码行数:54,代码来源:
注:本文中的mathutils.Matrix类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论