Skip to content

Commit

Permalink
io_coat3D: you can now change prefix and it still update textures
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuliRiihikoski committed Sep 23, 2020
1 parent feca8c5 commit f570548
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 6 deletions.
4 changes: 4 additions & 0 deletions io_coat3D/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,6 +675,8 @@ def execute(self, context):
else:
os.makedirs(bake_location)

# BAKING #

temp_string = ''
for objekti in bpy.context.selected_objects:
if objekti.type == 'MESH':
Expand Down Expand Up @@ -778,6 +780,8 @@ def execute(self, context):
bpy.data.images.remove(image)

index_bake_tex += 1

#BAKING ENDS

#bpy.ops.object.origin_set(type='ORIGIN_GEOMETRY')
if(len(bpy.context.selected_objects) > 1 and coat3D.type != 'vox'):
Expand Down
24 changes: 18 additions & 6 deletions io_coat3D/tex.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import os
import re
import json
from io_coat3D import updateimage

def find_index(objekti):

Expand Down Expand Up @@ -286,20 +287,30 @@ def createnodes(active_mat,texcoat, create_group_node, objekti, ind, is_new, udi
if (node.type == 'TEX_IMAGE'):
if (node.name == '3DC_color'):
bring_color = False
updateimage.update(texcoat, 'color', node)
elif (node.name == '3DC_metalness'):
bring_metalness = False
updateimage.update(texcoat, 'metalness', node)
elif (node.name == '3DC_rough'):
bring_roughness = False
updateimage.update(texcoat, 'rough', node)
elif (node.name == '3DC_nmap'):
bring_normal = False
updateimage.update(texcoat, 'nmap', node)
elif (node.name == '3DC_displacement'):
bring_displacement = False
updateimage.update(texcoat, 'displacement', node)
elif (node.name == '3DC_emissive'):
bring_emissive = False
updateimage.update(texcoat, 'emissive', node)
elif (node.name == '3DC_AO'):
bring_AO = False
updateimage.update(texcoat, 'ao', node)
elif (node.name == '3DC_alpha'):
bring_alpha = False
updateimage.update(texcoat, 'alpha', node)


elif (node.type == 'GROUP' and node.name.startswith('3DC_')):
if (node.name == '3DC_color'):
bring_color = False
Expand Down Expand Up @@ -634,15 +645,14 @@ def createExtraNodes(act_material, node, type):

def matlab(objekti,mat_list,texturelist,is_new):

''' FBX Materials: remove all nodes and create princibles node'''
# FBX Materials: remove all nodes and create princibles node

if(is_new):
RemoveFbxNodes(objekti)

'''Main Loop for Texture Update'''
updatetextures(objekti)

updatetextures(objekti)

''' Check if bind textures with UVs or Materials '''
# Count udim tiles

if(texturelist != []):

Expand All @@ -659,8 +669,10 @@ def matlab(objekti,mat_list,texturelist,is_new):
if texture[2] == udim_target:
udim_indexs.append(int(texture[0]))

udim_indexs.sort()
udim_indexs.sort() # sort tiles list -> 1001, 1002, 1003...

# Main loop for creating nodes

readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures, udim_indexs)


Expand Down
5 changes: 5 additions & 0 deletions io_coat3D/updateimage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import bpy

def update(texcoat,tex_type,node):
if (texcoat[tex_type][0] != node.image.filepath):
node.image = bpy.data.images.load(texcoat[tex_type][0])

0 comments on commit f570548

Please sign in to comment.