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


Python Vector.zero方法代码示例

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


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

示例1: calc_custtangents

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import zero [as 别名]
def calc_custtangents(vertlength, uv_vertcoords, uvverts_list, vindexlist2, vindices, me_normals):
    me_tangents = []
    me_binormals = []

    for i in range(len(me_normals)):
        tan = (uvverts_list[i] - (
            me_normals[i] * me_normals[i].dot(uvverts_list[i])
        )).normalized()
        me_tangents.append(tan)
        me_binormals.append(me_normals[i].cross(tan))

    tempvect = Vector((0.0, 0.0, 0.0))
    smoothlist = [[], [], [], []]
    vertstoremove = []
    new_tangents = [v for v in me_tangents]

    for i in range(vertlength):
        # Gather Loop
        # - slow - checks the index list for uv islands each vert is part of
        for j in vindexlist2:
            if vindices[j] == i:
                vertstoremove.append(j)
                if len(smoothlist[0]) > 0:
                    if check_uvvertdist(uv_vertcoords[j], uv_vertcoords[smoothlist[0][0]], 0.01):
                        smoothlist[0].append(j)
                    else:
                        if len(smoothlist[1]) > 0:
                            if check_uvvertdist(uv_vertcoords[j], uv_vertcoords[smoothlist[1][0]], 0.01):
                                smoothlist[1].append(j)
                            else:
                                if len(smoothlist[2]) > 0:
                                    if check_uvvertdist(uv_vertcoords[j], uv_vertcoords[smoothlist[2][0]], 0.01):
                                        smoothlist[2].append(j)
                                    else:
                                        smoothlist[3].append(j)
                                else:
                                    smoothlist[2].append(j)
                        else:
                            smoothlist[1].append(j)
                else:
                    smoothlist[0].append(j)

        # calculation time tweak: remove indices that won't come up again for less iterations in successive passes
        for k in vertstoremove:
            vindexlist2.remove(k)

        # actual smoothing is done here:
        smooth_vertcusttangents(tempvect, smoothlist, me_normals, me_tangents, me_binormals, new_tangents)

        # reset vars for next iteration
        smoothlist = [[], [], [], []]
        vertstoremove = []
        tempvect.zero()

    me_tangents = [v for v in new_tangents]

    return me_tangents, me_binormals
开发者ID:meta-androcto,项目名称:blenderpython,代码行数:59,代码来源:cust_tangents.py

示例2: vectorFrom2Points

# 需要导入模块: from mathutils import Vector [as 别名]
# 或者: from mathutils.Vector import zero [as 别名]
def vectorFrom2Points(origin, dest, module = None):
	""" Returns a |Vector|  form 2 points in the space.

	:param origin: Point A
	:type origin: |Vector|
	:param dest: Point B
	:type dest: |Vector|
	:param float module: If setted, the returned vector will have this maxium lenght. The new lenght will never be greater than the original.
	"""
	vec = Vector((dest.x - origin.x, dest.y - origin.y, dest.z - origin.z))
	if not module: return vec

	l = vec.length

	if l < 0.0125: return vec.zero()
	if l < module: return vec

	vec = vec / l
	if module == 1: return vec
	else: return vec * module
开发者ID:Hubber116sx,项目名称:BGECore,代码行数:22,代码来源:utils.py


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