-This tool operates UV first. First, you need to hold the instance for operation.

Source: Internet
Author: User

--*************************************** **************************************** ***********************
-- Created: 05-05-2011
-- Last updated: 05-05-2011
-- Version: 1.0
--
-- Author: Kostadin kotev/miau_u@yahoo.com/
-- Version: 3DS MAX 2009 (shocould work in older versions too !)
--
-- Discription:
-- Randomly rotate the selected UV islands.
--
-- Usage:
-- Uvw_unwrap modifier must be applyed to object and the "Edit uvws" rolout must be open.
-- Select some UV islands or select some Verts, edges or faces of each UV islands and press the "hold selection" button.
-- Press the "random rotate" button several times.
--
--*************************************** **************************************** ***********************
-- Modify this at your own risk
/*
Macroscript uvrandomrotate_v1
Category: "miauu"
Tooltip: "UV random rotate V1.0"
Buttontext: "UV random rotate"
*/
--- 1.9.02 gaitian explanation
-- This tool first performs operations on UV. First, you need to hold the instance for operation.
-- This is good.
-- By using and looking at it, I think it is the instant rotation UV and hold is the rotation part.
-- Now I think the idea is to record the positions of all vertices, and add the Moving position to the position after the set rotation,
-- The operation was delayed for 8 days.

(
Global rol_uvrandomrotate
Try (destroydialog rol_uvrandomrotate) catch ()
Rolout rol_uvrandomrotate "UV rotate"
(
Local uvislands = #()
Local UV = undefined
Local subobjlevel = undefined

Checkbutton chkbtn_holdselection "hold selection"
Button btn_rotaterandom "random rotate"

Function randomrotateinvertsol = --- this function is used to convert some factors to all factors for processing. -- this function is very useful for vertex operations.
(
-- Get all selected vertices
Allverts = uv. getselectedvertices () --- point selected by the product
If not allverts. isempty then --- not allverts. isempty determines whether it is valid. I always convert the array when I move it.
(
-- Find and separate selected elements
While not allverts. isempty do -- is it necessary ,?
(
-- Set the first vertex as selected
UV. selectvertices # {(allverts as array) [1]}
-- Select the element of that vertex
UV. selectelement () ----- the function of selecting factors.
-- Select all vertices of this element
Elem01verts = uv. getselectedvertices ()
Append uvislands elem01verts ------------ Add the selected items to the array at a time. Is to add the bit Group of the entire vertex to the array. Fortunately, it is referenced below.
-- Remove this vertices from original selection
Allverts = allVerts-elem01verts --- and then emptied again can this release the memory, not Max self collection, I have never paid attention to this.
)
)
Else
(
MessageBox "select some UV Islands! "Title:" miauu Script Error !!! "
Chkbtn_holdselection.state = false
)
)

-- The following operations are the same as those above. You can also put them in a function for judgment.

Function randomrotateinedgesol =
(
Alledges = uv. getselectededges ()
If not alledges. isempty then
(
While not alledges. isempty do
(
UV. selectedges # {(alledges as array) [1]}
UV. selectelement ()
Elem01verts = uv. getselectededges ()
Append uvislands elem01verts -------- the design method is to use a number to add three digits. I usually use three arrays to operate this method well.
Alledges = allEdges-elem01verts
)
)
Else
(
MessageBox "select some UV Islands! "Title:" miauu Script Error !!! "
Chkbtn_holdselection.state = false
)
)
Function randomrotateinfacesol =
(
Allfaces = uv. getselectedfaces ()
If not allfaces. isempty then
(
While not allfaces. isempty do
(
UV. selectfaces # {(allfaces as array) [1]}
UV. selectelement ()
Elem01faces = uv. getselectedfaces ()
Append uvislands elem01faces
Allfaces = allFaces-elem01faces
)
)
Else
(
MessageBox "select some UV Islands! "Title:" miauu Script Error !!! "
Chkbtn_holdselection.state = false
)
)

On chkbtn_holdselection changed thestate do --- this activity can be performed at the 123 level
(
If thestate then
(
UV = modpanel. getcurrentobject () --- determine the selected level. This is very important. It is used for judgment in the skin plug-in.
If classof (UV) = unwrap_uvw then
(
Uvislands = #()
Case UV. gettvsubobjectmode () of -- UV. gettvsubobjectmode () determines the level of UV usage. Different methods are used through this determination.
(
1: (randomrotateinvertsol (); subobjlevel = 1) -- subobjlevel here is a global variable. output information is needed here.
2: (randomrotateinedgesol (); subobjlevel = 2)
3: (randomrotateinfacesol (); subobjlevel = 3)
)
)
Else
(
-- No hierarchical usage is selected. This should be very important.
MessageBox "Open the \" Edit uvws \ "window! "Title:" miauu Script Error !!! "
Chkbtn_holdselection.state = false
)
)
Else
(
Uvislands = #()
)
)

On btn_rotaterandom pressed do
(
Case subobjlevel of --- subobjlevel, which is the output unit above. This determines whether it is an operation line of the edge or a surface operation/
(
1:
(
For I = 1 to uvislands. Count do --- I think the design here is not very reasonable.
(
UV. selectvertices uvislands [I] -- in fact, it is reasonable to think about it. If there is a choice between vertices and edges, here is the one I chose at that level.
UV. rotateselectedcenter (random-3.14159 3.14159)
-- <Void> <unwrap_uvw>. moveselected <point3> offset
-- <Void> <unwrap_uvw>. rotateselected <float> Angle <point3> AXIS
-- The above all have their syntax.
-- In this way, the operation/
)
)
2:
(
For I = 1 to uvislands. Count do
(
UV. selectedges uvislands [I]
UV. rotateselectedcenter (random-3.14159 3.14159)
)
)
3:
(
For I = 1 to uvislands. Count do
(
UV. selectfaces uvislands [I]
UV. rotateselectedcenter (random-3.14159 3.14159)
)
)
)
)
)
Createdialog rol_uvrandomrotate 84 54 style: # (# style_titlebar, # style_sysmenu, # style_toolwindow)
)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.