当前位置: 首页>>代码示例>>Python>>正文


Python Vector.to_3x3方法代码示例

本文整理汇总了Python中mathutils.Vector.to_3x3方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.to_3x3方法的具体用法?Python Vector.to_3x3怎么用?Python Vector.to_3x3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mathutils.Vector的用法示例。


在下文中一共展示了Vector.to_3x3方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_md5

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import to_3x3 [as 别名]

#.........这里部分代码省略.........
			createVertexB = 0
			createVertexC = 0

			while faces:
				material_index = faces[0].material_index
				try:
					mat_name = me.materials[0].name
				except IndexError:
					mat_name = "no_material"

				material = Material(mat_name) #call the shader name by the material's name

				submesh = SubMesh(mesh, material)
				vertices = {}
				for face in faces[:]:
					# der_ton: i added this check to make sure a face has at least 3 vertices.
					# (pdz) also checks for and removes duplicate verts
					if len(face.vertices) < 3: # throw away faces that have less than 3 vertices
						faces.remove(face)
					elif face.vertices[0] == face.vertices[1]:	  #throw away degenerate triangles
						faces.remove(face)
					elif face.vertices[0] == face.vertices[2]:
						faces.remove(face)
					elif face.vertices[1] == face.vertices[2]:
						faces.remove(face)
					elif face.material_index == material_index:
						#all faces in each sub-mesh must have the same material applied
						faces.remove(face)

						if not face.use_smooth :
							p1 = verts[ face.vertices[0] ].co
							p2 = verts[ face.vertices[1] ].co
							p3 = verts[ face.vertices[2] ].co
							normal = (w_matrix.to_3x3() * (p3-p2).cross(p1-p2)).normalized()

							#normal = vector_normalize(vector_by_matrix(vector_crossproduct( \
							#	 [p3[0] - p2[0], p3[1] - p2[1], p3[2] - p2[2]], \
							#	 [p1[0] - p2[0], p1[1] - p2[1], p1[2] - p2[2]], \
							#	 ), w_matrix))

						#for each vertex in this face, add unique to vertices dictionary
						face_vertices = []
						for i in range(len(face.vertices)):
							vertex = False
							if face.vertices[i] in vertices:
								vertex = vertices[face.vertices[i]] #type of Vertex
							if not vertex: #found unique vertex, add to list
								coord = w_matrix * verts[face.vertices[i]].co #point_by_matrix( verts[face.vertices[i]].co, w_matrix ) #TODO: fix possible bug here
								if face.use_smooth:
									normal = w_matrix.to_3x3() * verts[face.vertices[i]].normal
									#normal = vector_normalize(vector_by_matrix( verts[face.vertices[i]].normal, w_matrix ))
								vertex = vertices[face.vertices[i]] = Vertex(submesh, coord, normal)
								createVertexA += 1

								influences = []
								for j in range(len(me.vertices[face.vertices[i]].groups)):
									inf = [obj.vertex_groups[me.vertices[face.vertices[i]].groups[j].group].name, me.vertices[face.vertices[i]].groups[j].weight]
									influences.append(inf)

								if not influences:
									print("There is a vertex without attachment to a bone in mesh: " + mesh.name)
									# sum = 0.0
									# for bone_name, weight in influences: sum += weight

									# for bone_name, weight in influences:
									# if sum != 0:
开发者ID:RobertBeckebans,项目名称:blender-idtech4-md5,代码行数:70,代码来源:io_export_md5_codemanx_09122013j_release.py


注:本文中的mathutils.Vector.to_3x3方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。