Hello everyone! I created a plugin for importing glb/gltf (using the gltfio library), however I am having trouble extracting textures from glb. At the moment, the task is to save the texture to a folder with the name described below (material-name_channel.jpg / png). Please tell me how to solve this problem?
def GLB_textures(self, glb): # C:\Users\%USERNAME%\Desktop\123.glb
folder , glb_name = os.path.split(glb)
tex_folder = os.path.join(folder, glb_name + '_tex')
try : os.mkdir(tex_folder )
except : print('Error create folder %s' % tex_folder)
if glb.data.textures is None:
return
for texture in glb.data.textures:
image = glb.data.images[texture.source] # gltfio.com.gltf2_io.Image instance
full_path = os.path.join(tex_folder, image.name+'.jpg') # 'tex_folder' + 00000_basecolor.jpg
try : image.Save(full_path, c4d.FILTER_JPG, None, c4d.SAVEBIT_0)
except : print 'Error saving image %s' % full_path