This is my first post. I'm sure this has been asked before, I've searched on the forums but the threads I've found have been either short and non-specific or in other ways useless and/or long dead.
I'm with a small indie game development company. I'm currently working on an export script, getting our 3D assets from Python into our proprietary game engine. We're rolling our own binary format.
My question: Is it possible, somehow, to export tangent space coordinates from a Blender mesh via Python? I know the values are there because Blender correctly renders normal mapped surfaces, but as far as I can see they are not available through the Python API.
The problem is that normal mapping is implementation-dependant, so any attempt to recreate tangents/bitangents outside of Blender is futile. We need to access the values within Blender directly.
I've seen patches around which hack this functionality into Blender but being dependent on a patch which breaks with every update is not acceptable, nor is having to provide our external talent with hacked builds. And that's providing it even works, I haven't looked that closely at it yet.
Since the values are available to Blender internally, it should be a trivial matter to expose them to the Python API, no?
I'd be extremely grateful for any response on this issue. Normal mapping is an integral part of game graphics these days and not having the ability to extract this information is a serious impediment to Blender being a viable 3D graphics package for game development.
Just wanted to say that this is something I would very much appreciate too.
On the other hand, are you sure that tangent space definition is implementation dependent? It seems to me that two of the axis can be calculated from the UV mapping, and the third axis is a simple cross-product. From what I understand, this is what Blender does, and since you have access to the UV-mapping, you can do this yourself too.
But as you say: apparently the functionality does exist within Blender, and it would be very nice to have Python access to it.
Apply this patch to build 46548:
I am in your exact situation. Tangents are calculated differently in Blender and the engine I am using, Away3D. I can confirm that this patch works. Yes, it is a hack, but it will get the job done. Plus, 46584 is build 2.63a, so you're not missing that much. (Current build at time of writing this is 2.64a.)
There is also this patch to the Collada exporter, which I have not tried yet: