utility.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:albion 作者: Oslandia 项目源码 文件源码
def computeNormals(vtx, idx):

    nrml = numpy.zeros(vtx.shape, numpy.float32)

    # compute normal per triangle
    triN = numpy.cross(vtx[idx[:,1]] - vtx[idx[:,0]], vtx[idx[:,2]] - vtx[idx[:,0]])

    # sum normals at vtx
    nrml[idx[:,0]] += triN[:]
    nrml[idx[:,1]] += triN[:]
    nrml[idx[:,2]] += triN[:]

    # compute norms
    nrmlNorm = numpy.sqrt(nrml[:,0]*nrml[:,0]+nrml[:,1]*nrml[:,1]+nrml[:,2]*nrml[:,2])

    return nrml/nrmlNorm.reshape(-1,1)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号