In the example below, I'm using an empty object that I've named "Empty XYZ" as the Coordinate Object, right in the Coordinate node into the Sphere Material (Named: "Strip Material")
Now I would like to delete my Empty XYZ object and insert the values into the mapping node, converting the position of the object (Loc, Rot, Scale) and inserting them into the Mapping node, in order to keep the strip exactly where it was placed thanks to the Empty Object
I would like to use Python for this operation, but I'm not sure about this, I'm doing some tests that don't produce satisfactory results, in some cases the Empty XYZ object might be a child of the object on which the material is applied, and in others not. So I'm looking for a decent solution that works (As long as it can be done)
import bpy
mat = bpy.data.materials['Strip Material']
nodes = mat.node_tree.nodes
coordinate = nodes['Texture Coordinate']
mapping = nodes['Mapping']
sphere = bpy.data.objects['Sphere'] # The sphere object
empty_xyz = bpy.data.objects['Empty XYZ'] # The empty object
loc = empty_xyz.location[:]
rot = empty_xyz.rotation_euler[:]
scale = empty_xyz.scale[:]
mapping.inputs[1].default_value = loc
mapping.inputs[2].default_value = rot
mapping.inputs[3].default_value = scale
coordinate.object = sphere
This example is a basic example in order to explain better what i want to do, I don't know if I have to apply matrix inverse, or other mathematical formulas to convert.
I can't find the right approach to this solution, and I'm not even sure if I'm doing anything that would work.
Note: I would like to avoid Bake at all costs
Any help will be appreciated