Created
August 20, 2020 11:27
-
-
Save alter-sachin/8a4c5ad6a36444a4700566c197bcae79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
scene = bpy.context.scene | |
i = 0 | |
def returnIfObject(passedName=""): | |
try: | |
result = bpy.data.objects[passedName] | |
except: | |
result = None | |
return result | |
while(True): | |
scene = bpy.context.scene | |
frame_number = "%05d" % i | |
#print(frame_number) | |
texture_name = str(frame_number)+".png" | |
object_name = str(frame_number) | |
#bpy.ops.image.open(filepath="/home/sachin/Desktop/augmented/voca/TF_FLAME/results/out/"+str(texture_name), directory="/home/sachin/Desktop/augmented/voca/TF_FLAME/results/out/", files=[{"name":texture_name, "name":texture_name}], relative_path=True, show_multiview=False) | |
mat = bpy.data.materials.new(name=texture_name) | |
mat.use_nodes = True | |
bsdf = mat.node_tree.nodes["Principled BSDF"] | |
texImage = mat.node_tree.nodes.new('ShaderNodeTexImage') | |
texImage.image = bpy.data.images.load("/home/sachin/Desktop/augmented/voca/TF_FLAME/results/out/"+str(texture_name)) | |
mat.node_tree.links.new(bsdf.inputs['Base Color'], texImage.outputs['Color']) | |
# Assign it to object | |
bpy.context.scene.frame_set(i) | |
#bpy.context.scene.frame_current = i | |
#myObj = returnIfObject(object_name) | |
#print(myObj) | |
#if myObj != None: | |
#scene = bpy.context.scene | |
#scene.object.active = myObj | |
ob = bpy.context.object | |
if ob.data.materials: | |
ob.data.materials[0] = mat | |
else: | |
ob.data.materials.append(mat) | |
i = i +1 | |
#scene.update() | |
if(i>99): | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment