Difference between revisions of "Snippet:TD-SDK Shift UVs"

From The Foundry MODO SDK wiki
Jump to: navigation, search
(Created page with "{{Snippet |summary=Example of using modo.Polygon.setUV /getUV from the TD-SDK |code=<syntaxhighlight lang="python">scene = modo.scene.current() geo = modo.Mesh().geometry # g...")
 
Line 1: Line 1:
 
{{Snippet
 
{{Snippet
 
|summary=Example of using modo.Polygon.setUV /getUV from the TD-SDK
 
|summary=Example of using modo.Polygon.setUV /getUV from the TD-SDK
|code=<syntaxhighlight lang="python">scene = modo.scene.current()
+
|code=<syntaxhighlight lang="python">
 +
scene = modo.scene.current()
 
geo = modo.Mesh().geometry # gets currently selected mesh
 
geo = modo.Mesh().geometry # gets currently selected mesh
 
uvmap = geo.vmaps.uvMaps[0]
 
uvmap = geo.vmaps.uvMaps[0]
Line 9: Line 10:
  
 
for polygon in vertex.polygons:
 
for polygon in vertex.polygons:
u,v = polygon.getUV(vertex)
+
u,v = polygon.getUV(vertex, uvmap=UVMapName)
 
polygon.setUV ( (u+0.1, v), vertex, uvmap=UVMapName)
 
polygon.setUV ( (u+0.1, v), vertex, uvmap=UVMapName)
  

Revision as of 09:04, 16 May 2016

Description:

Example of using modo.Polygon.setUV /getUV from the TD-SDK

Code:

scene = modo.scene.current()
geo = modo.Mesh().geometry # gets currently selected mesh
uvmap = geo.vmaps.uvMaps[0]
 
# Shift vertex UVs on all polygons
def shiftUVs (vertex, UVMapName='Texture'):
 
	for polygon in vertex.polygons:
		u,v = polygon.getUV(vertex, uvmap=UVMapName)
		polygon.setUV ( (u+0.1, v), vertex, uvmap=UVMapName)
 
vertex = geo.vertices[0]
shiftUVs (vertex)
geo.setMeshEdits()