Skip to main content
deleted 140 characters in body
Source Link

You access tangents and bitangents from MeshLoops:

import bpy
me = bpy.context.active_object.data

# tangents have to be pre-calculated
# this will also calculate loop normal
me.calc_tangents()

# loop faces
for face in me.polygons:
    # get index range of face vertices in me.loops: 
    l_start = face.loop_start
    l_end = l_start + face.loop_total
    # loop over face loop
    for vert in [me.loops[i] for i in range(l_start, l_end)]face.loop_indices]:
        tangent = vert.tangent
        normal = vert.normal
        bitangent = vert.bitangent_sign * normal.cross(tangent)

To get tangent and bitangent of some face you need to average tangents and bitangents of every vertex in that face loop.

You access tangents and bitangents from MeshLoops:

import bpy
me = bpy.context.active_object.data

# tangents have to be pre-calculated
# this will also calculate loop normal
me.calc_tangents()

# loop faces
for face in me.polygons:
    # get index range of face vertices in me.loops: 
    l_start = face.loop_start
    l_end = l_start + face.loop_total
    # loop over face loop
    for vert in [me.loops[i] for i in range(l_start, l_end)]:
        tangent = vert.tangent
        normal = vert.normal
        bitangent = vert.bitangent_sign * normal.cross(tangent)

To get tangent and bitangent of some face you need to average tangents and bitangents of every vertex in that face loop.

You access tangents and bitangents from MeshLoops:

import bpy
me = bpy.context.active_object.data

# tangents have to be pre-calculated
# this will also calculate loop normal
me.calc_tangents()

# loop faces
for face in me.polygons:
    # loop over face loop
    for vert in [me.loops[i] for i in face.loop_indices]:
        tangent = vert.tangent
        normal = vert.normal
        bitangent = vert.bitangent_sign * normal.cross(tangent)

To get tangent and bitangent of some face you need to average tangents and bitangents of every vertex in that face loop.

Source Link

You access tangents and bitangents from MeshLoops:

import bpy
me = bpy.context.active_object.data

# tangents have to be pre-calculated
# this will also calculate loop normal
me.calc_tangents()

# loop faces
for face in me.polygons:
    # get index range of face vertices in me.loops: 
    l_start = face.loop_start
    l_end = l_start + face.loop_total
    # loop over face loop
    for vert in [me.loops[i] for i in range(l_start, l_end)]:
        tangent = vert.tangent
        normal = vert.normal
        bitangent = vert.bitangent_sign * normal.cross(tangent)

To get tangent and bitangent of some face you need to average tangents and bitangents of every vertex in that face loop.