PDA

View Full Version : Scale UV's without going into the Unwrap Editor


abyjoe
10-05-2009, 11:50 AM
I have a small UI with U and V spinners and a "Set" button to set the scale of UV's on a selected object... I have written a script that works with selected texture vertices (in the Unwrap editor)

...but I wanted to know if there is a one line code to scale UV's without having to select all texture vertices?

If not whats the best way to select all texture verts?

PiXeL_MoNKeY
10-05-2009, 07:55 PM
Scale based on what? Selection Center? UVW Center [0.5,0.5]? Random Point?<void><Unwrap_UVW>.scaleSelectedCenter <float>scale <integer>dir
Scales the selected sub-objects by the specified amount using the selection center. The dir integer defines the direction of scaling as follows:

0 - scale both X and Y

1 - scale X only

2 - scale Y only

Exposed via unwrap2 interface in 3ds Max 5 and higher.<void><Unwrap_UVW>.ScaleSelected <float>scale <integer>dir <point3>axis

Scales the selected sub-objects by the specified amount using the specified axis. The dir integer defines the scaling mode as follows:

0 - scale both X and Y

1 - scale X only

2 - scale Y only

Exposed via unwrap2 interface in 3ds Max 5 and higher.-Eric

denisT
10-05-2009, 08:15 PM
I have a small UI with U and V spinners and a "Set" button to set the scale of UV's on a selected object... I have written a script that works with selected texture vertices (in the Unwrap editor)

...but I wanted to know if there is a one line code to scale UV's without having to select all texture vertices?

If not whats the best way to select all texture verts?

sorry in advance for any probable misspelling... i don't have 3ds max on cell phone :) to verify the code...

if you want to change (scale) uv coords for editable polys (or editable meshes) you don't need to use (or apply and use) UVW Unwrap modifier. You can do it directly changing a map vert position:

uv_channel = ... -- channel that you want to work on
scale_center = ... -- let's say [0,0,0]
for node in <node_list> where iskindof node EditablePoly do
(
for v=1 to (polyop.getnummapverts node uv_channel) do
(
pos = polyop.getmapvert node uv_channel v
pos = (pos - scale_center)*[u_scale_factor,v_scale_factor,1] + scale_center
polyop.setmapvert node uv_channel v pos
)
)



2. the easiest way to select all vertices in UVW unwrap modifier is

-- modi is UVW unwrap modifier

all_verts = #{1..modi.numberVertices()}
modi.selectVerts all_verts -- maybe modi.selectVertices (don't remember)

if you need to do it for multiple nodes with the same modifier:

for node in <node_list> do
(
all_verts_by_node = #{1..modi.numberVerticesByNode node:node}
modi.selectVertsByNode all_verts_by_node node:node
)

abyjoe
10-06-2009, 10:03 AM
thanks a lot... all sorted now

abyjoe
10-06-2009, 10:09 AM
sorry in advance for any probable misspelling... i don't have 3ds max on cell phone :) to verify the code...

if you want to change (scale) uv coords for editable polys (or editable meshes) you don't need to use (or apply and use) UVW Unwrap modifier. You can do it directly changing a map vert position:

uv_channel = ... -- channel that you want to work on
scale_center = ... -- let's say [0,0,0]
for node in <node_list> where iskindof node EditablePoly do
(
for v=1 to (polyop.getnummapverts node uv_channel) do
(
pos = polyop.getmapvert node uv_channel v
pos = (pos - scale_center)*[u_scale_factor,v_scale_factor,1] + scale_center
polyop.setmapvert node uv_channel v pos
)
)



2. the easiest way to select all vertices in UVW unwrap modifier is

-- modi is UVW unwrap modifier

all_verts = #{1..modi.numberVertices()}
modi.selectVerts all_verts -- maybe modi.selectVertices (don't remember)

if you need to do it for multiple nodes with the same modifier:

for node in <node_list> do
(
all_verts_by_node = #{1..modi.numberVerticesByNode node:node}
modi.selectVertsByNode all_verts_by_node node:node
)


Thanks Denis.. i wasnt thinking of adding this for multiple nodes but theres an idea and I will use it. much appreciated dude.. thanks a lot (... and its modi.selectvertices)

CGTalk Moderation
10-06-2009, 10:09 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.