Hello !
So I have a mesh and I need to do a script that computes the tangent vectors of each vertices.
How can I proceed without an UV map ?
Sorry for my bad english.
Hello !
So I have a mesh and I need to do a script that computes the tangent vectors of each vertices.
How can I proceed without an UV map ?
Sorry for my bad english.
You can’t without UV-Map:
RuntimeError: Error: Tangent space computation needs an UVMap, “(null)” not found, aborting
But it should suffice to create a blank UV map…
import bpy
ob = bpy.context.object
me = ob.data
uv_tex = me.uv_textures.new()
uv_layer = me.uv_layers[-1]
me.calc_tangents(uv_layer.name)
print()
print("%-6s %-6s %-30s %-30s" % ("Loop", "Vertex", "Tangent", "Bitangent"))
print("-" * 80)
r = lambda x: round(x, 4)
for l in me.loops:
print("%6i %6i %-30s %-30s" % (l.index, l.vertex_index, tuple(map(r, l.tangent)), tuple(map(r, l.bitangent))))
Thank you!
And a silly question but where can I find the source code of this function to see how it is done ?
It’s somewhere in blender\source\blender\blenkernel\intern, parts of it in mesh_evaluate.c