Skip to content

Commit 478ec64

Browse files
committed
gitignore
1 parent ada3d6f commit 478ec64

8 files changed

Lines changed: 193 additions & 173 deletions

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python cache files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
*.so
6+
7+
# Maya specific
8+
*.mb
9+
*.ma
10+
*.mel.swp
11+
12+
# IDE specific files
13+
.vscode/
14+
.idea/
15+
*.swp
16+
*~
17+
18+
# Operating system specific files
19+
.DS_Store
20+
Thumbs.db

TextureRiggerTool.py

Lines changed: 48 additions & 48 deletions
Large diffs are not rendered by default.
-11.6 KB
Binary file not shown.
-4.85 KB
Binary file not shown.
-10.8 KB
Binary file not shown.
-14.7 KB
Binary file not shown.

step1_logic.py

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44
def check_uv_overlap(mesh_node, u_coord, v_coord):
55
"""
6-
Belirtilen UV koordinatında birden fazla yüzey (face) olup olmadığını kontrol eder.
7-
(Bu fonksiyonun doğruluğu ve etkinliği daha da geliştirilebilir.)
6+
Checks if there are multiple faces at the specified UV coordinate.
7+
(The accuracy and efficiency of this function can be further improved.)
88
"""
99
selection_list = om.MSelectionList()
1010
selection_list.add(mesh_node)
1111
dag_path = om.MDagPath()
1212
try:
1313
selection_list.getDagPath(0, dag_path)
1414
except RuntimeError:
15-
cmds.warning(f"Mesh node '{mesh_node}' DAG path alınamadı.")
16-
return True # Hata durumunda işlemi durdurmak için True dönelim
15+
cmds.warning(f"Could not get DAG path for mesh node '{mesh_node}'.")
16+
return True # Return True in case of error to stop the process
1717

1818
mesh_fn = om.MFnMesh(dag_path)
1919
current_uv_set = mesh_fn.currentUVSetName()
@@ -27,65 +27,65 @@ def check_uv_overlap(mesh_node, u_coord, v_coord):
2727
mesh_fn.getPolygonUVs(i, current_uv_set, face_uvs_u, face_uvs_v)
2828
for j in range(face_uvs_u.length()):
2929
if abs(face_uvs_u[j] - u_coord) < 0.0001 and abs(face_uvs_v[j] - v_coord) < 0.0001:
30-
uv_tuple = (round(u_coord, 4), round(v_coord, 4)) # Tolerans için yuvarlama
30+
uv_tuple = (round(u_coord, 4), round(v_coord, 4)) # Rounding for tolerance
3131
if uv_tuple not in hit_faces:
3232
hit_faces[uv_tuple] = []
3333
if i not in hit_faces[uv_tuple]:
3434
hit_faces[uv_tuple].append(i)
3535
except Exception as e:
36-
# print(f"Yüzey {i} için UV alınırken hata: {e}")
36+
# print(f"Error getting UVs for face {i}: {e}")
3737
continue
3838

3939
uv_tuple_check = (round(u_coord, 4), round(v_coord, 4))
4040
if uv_tuple_check in hit_faces and len(hit_faces[uv_tuple_check]) > 1:
41-
# cmds.warning(f"UV Overlap (basit kontrol): {len(hit_faces[uv_tuple_check])} yüzey ({hit_faces[uv_tuple_check]}) UV ({u_coord}, {v_coord}) paylaşıyor.")
41+
# cmds.warning(f"UV Overlap (simple check): {len(hit_faces[uv_tuple_check])} faces ({hit_faces[uv_tuple_check]}) share UV ({u_coord}, {v_coord}).")
4242
return True
4343
return False
4444

4545
def get_world_space_at_uv(mesh_shape_name, u_coord, v_coord):
4646
"""
47-
Belirtilen UV koordinatına karşılık gelen dünya uzayı (world space) koordinatını alır.
48-
uvPin node'u kullanarak daha güvenilir bir sonuç elde eder.
47+
Gets the world space coordinate corresponding to the specified UV coordinate.
48+
Uses uvPin node for more reliable results.
4949
"""
5050
if not cmds.objExists(mesh_shape_name):
51-
cmds.warning(f"Mesh shape '{mesh_shape_name}' bulunamadı.")
51+
cmds.warning(f"Mesh shape '{mesh_shape_name}' not found.")
5252
return None
5353

5454
mesh_transform_name_list = cmds.listRelatives(mesh_shape_name, parent=True, fullPath=True)
5555
if not mesh_transform_name_list:
56-
cmds.warning(f"Mesh shape '{mesh_shape_name}' için transform bulunamadı.")
56+
cmds.warning(f"Could not find transform for mesh shape '{mesh_shape_name}'.")
5757
return None
5858
mesh_transform_name = mesh_transform_name_list[0]
5959

6060
uv_pin_node = None
6161
try:
6262
uv_pin_node = cmds.createNode("uvPin")
6363

64-
# worldMesh veya outMesh bağlantısı
64+
# worldMesh or outMesh connection
6565
if cmds.attributeQuery("worldMesh", node=mesh_shape_name, exists=True) and \
6666
cmds.attributeQuery("worldMesh[0]", node=mesh_shape_name, exists=True):
6767
cmds.connectAttr(f"{mesh_shape_name}.worldMesh[0]", f"{uv_pin_node}.deformedGeometry")
6868
elif cmds.attributeQuery("outMesh", node=mesh_shape_name, exists=True):
6969
cmds.connectAttr(f"{mesh_shape_name}.outMesh", f"{uv_pin_node}.deformedGeometry")
7070
else:
71-
cmds.warning(f"Mesh shape '{mesh_shape_name}' üzerinde uygun bir mesh output attribute bulunamadı (worldMesh[0] veya outMesh).")
71+
cmds.warning(f"Could not find appropriate mesh output attribute on mesh shape '{mesh_shape_name}' (worldMesh[0] or outMesh).")
7272
if uv_pin_node and cmds.objExists(uv_pin_node): cmds.delete(uv_pin_node)
7373
return None
7474

75-
# uvPin node'una transformun worldMatrix'ini bağla (doğru pozisyon için önemli)
76-
# 'originalGeometryMatrix' yerine 'inputMatrix' kullanılmalı veya uvPin'in kendi transformu ayarlanmalı.
77-
# Genellikle worldMatrix[0] -> inputMatrix bağlantısı yapılır.
75+
# Connect transform's worldMatrix to the uvPin node (important for correct position)
76+
# Should use 'inputMatrix' instead of 'originalGeometryMatrix', or adjust the uvPin's own transform.
77+
# Typically a worldMatrix[0] -> inputMatrix connection is made.
7878
if cmds.attributeQuery("inputMatrix", node=uv_pin_node, exists=True):
7979
cmds.connectAttr(f"{mesh_transform_name}.worldMatrix[0]", f"{uv_pin_node}.inputMatrix")
8080
else:
81-
# Alternatif olarak, uvPin nodunun transformunu mesh'in transformuna eşitleyebiliriz
82-
# veya uvPin'i mesh'e parent edip transformlarını sıfırlayabiliriz.
83-
# Ancak inputMatrix en temiz yöntemdir. Eğer yoksa, uvPin'in çalışma şekli farklı olabilir.
84-
# Şimdilik, inputMatrix'in var olduğunu varsayıyoruz. Yoksa, bu bir sorun teşkil edebilir.
85-
# Maya'nın daha eski sürümlerinde bu attribute olmayabilir veya farklı olabilir.
86-
# Modern Maya sürümlerinde (örn. 2018+) inputMatrix olmalıdır.
87-
cmds.warning(f"uvPin node '{uv_pin_node}' üzerinde 'inputMatrix' attribute'u bulunamadı. Dünya pozisyonu yanlış olabilir.")
88-
# Bu durumda bile devam etmeyi deneyebiliriz, ancak sonuçlar yanıltıcı olabilir.
81+
# Alternatively, we could set the uvPin node's transform equal to the mesh's transform
82+
# or parent the uvPin to the mesh and zero out its transforms.
83+
# However, inputMatrix is the cleanest method. If it's missing, uvPin behavior may differ.
84+
# For now, we assume inputMatrix exists. If not, this could be problematic.
85+
# In older Maya versions this attribute might not exist or might be different.
86+
# In modern Maya versions (e.g., 2018+) inputMatrix should exist.
87+
cmds.warning(f"Could not find 'inputMatrix' attribute on uvPin node '{uv_pin_node}'. World position may be incorrect.")
88+
# We can still try to continue, but results may be misleading.
8989

9090
cmds.setAttr(f"{uv_pin_node}.coordinate[0].coordinateU", u_coord)
9191
cmds.setAttr(f"{uv_pin_node}.coordinate[0].coordinateV", v_coord)
@@ -95,68 +95,68 @@ def get_world_space_at_uv(mesh_shape_name, u_coord, v_coord):
9595

9696
return om.MPoint(world_pos[0], world_pos[1], world_pos[2])
9797
except Exception as e:
98-
cmds.warning(f"Dünya koordinatı (uvPin) alınırken hata: {e}")
98+
cmds.warning(f"Error getting world coordinate (uvPin): {e}")
9999
return None
100100
finally:
101101
if uv_pin_node and cmds.objExists(uv_pin_node):
102102
cmds.delete(uv_pin_node)
103103

104104
def create_locator_at_point(point, name_prefix="textureRigger"): # Changed default name_prefix
105105
"""
106-
Belirtilen dünya uzayı koordinatında bir locator oluşturur.
106+
Creates a locator at the specified world space coordinate.
107107
108108
Args:
109-
point (om.MPoint): Locator'ın oluşturulacağı dünya uzayı koordinatı.
110-
name_prefix (str): Locator'ın isim öneki.
109+
point (om.MPoint): World space coordinate where the locator will be created.
110+
name_prefix (str): Name prefix for the locator.
111111
"""
112-
# İsim önekini kontrol et ve boş değilse locator isimlendirmesinde kullan
112+
# Check the name prefix and use it in locator naming if not empty
113113
locator_name = f"{name_prefix}_locator#" if name_prefix else "textureRigger_locator#" # Changed fallback prefix
114114
locator = cmds.spaceLocator(name=locator_name)
115115
cmds.xform(locator[0], translation=(point.x, point.y, point.z), worldSpace=True)
116-
# cmds.select(locator[0]) # Seçimi ana UI yönetsin
117-
print(f"Locator '{locator[0]}' oluşturuldu: ({point.x}, {point.y}, {point.z})")
116+
# cmds.select(locator[0]) # Let the main UI handle selection
117+
print(f"Locator '{locator[0]}' created at: ({point.x}, {point.y}, {point.z})")
118118
return locator[0]
119119

120120
def run_step1_logic(name_prefix="textureRigger"): # Changed default name_prefix
121121
"""
122-
Step 1'in ana mantığını çalıştırır: Mesh seçimi, UV kontrolü ve locator oluşturma.
122+
Runs the main logic of Step 1: Mesh selection, UV checking, and locator creation.
123123
124124
Args:
125-
name_prefix (str): Locator ve diğer nesnelerin isim öneki.
125+
name_prefix (str): Name prefix for the locator and other objects.
126126
127127
Returns:
128-
tuple: (mesh_transform, mesh_shape, locator_name) veya (None, None, None)
128+
tuple: (mesh_transform, mesh_shape, locator_name) or (None, None, None)
129129
"""
130130
selected_objects = cmds.ls(selection=True, long=True, type="transform")
131131

132132
if not selected_objects:
133-
cmds.warning("Lütfen bir polygon mesh seçin.")
134-
return None, None, None # 3 değer döndür
133+
cmds.warning("Please select a polygon mesh.")
134+
return None, None, None # Return 3 values
135135

136136
mesh_transform = selected_objects[0]
137137
shapes = cmds.listRelatives(mesh_transform, shapes=True, fullPath=True, type="mesh")
138138

139139
if not shapes:
140-
cmds.warning(f"Seçilen obje '{mesh_transform}' bir polygon mesh değil veya mesh shape'i yok.")
141-
return None, None, None # 3 değer döndür
140+
cmds.warning(f"Selected object '{mesh_transform}' is not a polygon mesh or has no mesh shape.")
141+
return None, None, None # Return 3 values
142142

143143
mesh_shape = shapes[0]
144144

145145
uv_to_check_u, uv_to_check_v = 0.5, 0.5
146146
if check_uv_overlap(mesh_shape, uv_to_check_u, uv_to_check_v):
147-
cmds.warning(f"UV ({uv_to_check_u}, {uv_to_check_v}) noktasında UV overlapping tespit edildi (veya birden fazla yüzey bulundu). Lütfen UV'leri kontrol edin.")
148-
return None, None, None # 3 değer döndür
147+
cmds.warning(f"UV overlapping detected at point ({uv_to_check_u}, {uv_to_check_v}) (or multiple faces found). Please check your UVs.")
148+
return None, None, None # Return 3 values
149149

150150
world_point = get_world_space_at_uv(mesh_shape, uv_to_check_u, uv_to_check_v)
151151
if world_point:
152152
locator_name = create_locator_at_point(world_point, name_prefix)
153-
if locator_name: # create_locator_at_point da None dönebilir (çok olası olmasa da)
153+
if locator_name: # create_locator_at_point can also return None (though unlikely)
154154
cmds.select(locator_name, replace=True)
155155
return mesh_transform, mesh_shape, locator_name
156156
else:
157-
cmds.warning(f"Locator oluşturulamadı.")
158-
return None, None, None # 3 değer döndür
157+
cmds.warning(f"Could not create locator.")
158+
return None, None, None # Return 3 values
159159
else:
160-
cmds.warning(f"UV ({uv_to_check_u}, {uv_to_check_v}) noktasında dünya koordinatı alınamadı.")
161-
return None, None, None # 3 değer döndür
160+
cmds.warning(f"Could not get world coordinate at UV point ({uv_to_check_u}, {uv_to_check_v}).")
161+
return None, None, None # Return 3 values
162162

0 commit comments

Comments
 (0)