[Closed] Flatten Dialog
Hi, i want to create a script that pops out a flattenUV dialog box where i can adjust the parameters and then those parameters are applied to the selected objects.
Right now i have a half baked solution to this
rollout test "test"
(
button Mapbut "Mapping"
on Mapbut pressed do
(
sel = selection
for i in sel do
(
i.modifiers[#unwrap_uvw].flattenMapDialog()
)
)
)
createDialog test width:200
But this solution requires to adjust the settings for every objects and then click OK for every object that it applies to. Is there a way to only adjust the settings from the dialog once and those settings are then applied to every objects one by one in the selection?
Thanks!
Create a rollout similar to flatten mapping dialog box then store all the values to variables and use this
<void><Unwrap_UVW>.flattenMap <float>angleThreshold <point3 array>normalList <float>spacing <boolean>normalize <integer>layOutType <boolean>rotateClusters <boolean>fillHoles
function in the for loop. If you need any help post here.
Thanks. Ill give it a shot. Hopefully ill make it, if not ill post here
edit: How do i tell a Cancel button to close the dialog?
I was successful weeeeeeeeeee… Thanks a lot AkramParvez
By the way has anyone noticed a “bug” with a flatten mapping?
When you execute this
<void><Unwrap_UVW>.flattenMap <float>angleThreshold <point3 array>normalList <float>spacing <boolean>normalize <integer>layOutType <boolean>rotateClusters <boolean>fillHoles
in a loop or something it always comes out bad. The reason for this is that when maxscript switches to poly mode it always has one cluster selected. So it executes on that cluster only. Weird.
I made a solution for his witch opens the edit windows and deselects any polys before and after the flatten…
lol destroyDialog I was searching for closeDialog so i couldn’t find anything usefull.
Thanks again AkramParvez
I have another problem
I decided to make all 3 mapping methods for this projects so I now want to make the Normal Mapping dialog, but it has dropdown menu and i never worked with those. So how can i make it work with dropdowns?
Here is what i have now but it doesn’t work
rollout tstnrm "TestNormal"
(
dropdownlist tpmap items:#("Back/Front Mapping", "Left/Right Mapping", "Top/Bottom Mapping", "Box No Top Mapping", "Box Mapping", "Diamond Mapping") width:150
spinner spacNRM "Spacing:" range:[0.0,1.0,0.02] type:#float scale:0.001 fieldWidth:70 pos:[22,35]
checkbox norClusNRM "Normalize Clusters" checked:true
checkbox rotClusNRM "Rotate Clusters" checked:true
checkbox alnbwith "Align By Width" checked:true
button okbutNRM "OK" width:100 height:22 pos:[220,10]
button cancNRM "Cancel" width:100 height:22 pos:[220,35]
on okbutNRM pressed do
(
obj = getCurrentSelection()
for i = 1 to obj.count do
(
select obj[i]
subobjectLevel = 3
actionMan.executeAction 0 "40043" -- Selection: Select None
obj[i].modifiers[#unwrap_uvw].normalMap #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1]) spacNRM.value norClusNRM.state tpmap.selected rotClusNRM.state alnbwith.state
actionMan.executeAction 0 "40043" -- Selection: Select None
clearSelection()
)
)
)
createDialog tstnrm width:335
Here is another thing related to the previous post.
Ok so maxscript help says this:
<void><Unwrap_UVW>.[b]normalMap[/b] <point3 array>normalList <float>spacing <boolean>normalize <integer>layOutType <boolean>rotateClusters <boolean>alignWidth
Simple enough Now the problem is this. It asks for a point3 array for the normallist, and the help also says this:
Normal Mapping is mapping based solely are the normals provided. This is identical to box mapping except you customize what normals you want to project on.
So if Normal Mapping is based on the normals provided, and you need to provide it with a point3 array for the normals… what do you putt in the point3 array? :surprised
What is the Back/Front Mapping converted to point3 array? What are the others?
On the flattenMapping it says this for the normalList
[b]normalList[/b] specifies an array of normal vectors defining clusters. The clusters will still be built using the angle threshold, but the supplied vectors will be used as starting directions for building the clusters. To use no vectors, an empty array #() can be supplied. The default UI Flatten feature uses a list of 6 vectors aligned to the world axes: #([1,0,0], [-1,0,0], [0,1,0], [0,-1,0], [0,0,1], [0,0,-1])
Am i missing something here or is there no way to find out what are the point3 arrays for the 6 Mapping types in Normal Mapping are?
I am confused, very very confused… 😮
It is a vector angle, the default one use X, -X, Y, -Y, Z, and -Z. So Back/Front Mapping would probably be Y/-Y or #([0,1,0],[0,-1,0]).
-Eric
EDIT: So did some testing and I would always leave layouttype at 1 and set the normal arrays as:
Back/Front: #([0,1,0],[0,-1,0])
Left/Right: #([1,0,0],[-1,0,0])
Top/Bottom: #([0,0,1],[0,0,-1])
Box No Top Mapping: #([1,0,0],[-1,0,0],[0,1,0],[0,-1,0])
Box Mapping: #([1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1])
Diamond Mapping: #([0.57735,0.57735,-0.57735], [-0.57735,-0.57735,-0.57735], [-0.57735,0.57735,0.57735], [0.57735,-0.57735,0.57735], [-0.57735,0.57735,-0.57735], [0.57735,0.57735,0.57735], [0.57735,-0.57735,-0.57735], [-0.57735,-0.57735,0.57735])
Thanks eric for the vector angles.
normalList = case tpmap.selection of
(
1: #([0,1,0],[0,-1,0])
2: #([1,0,0],[-1,0,0])
3: #([0,0,1],[0,0,-1])
4: #([1,0,0],[-1,0,0],[0,1,0],[0,-1,0])
5: #([1,0,0],[-1,0,0],[0,1,0],[0,-1,0],[0,0,1],[0,0,-1])
6: #([0.57735,0.57735,-0.57735], [-0.57735,-0.57735,-0.57735], [-0.57735,0.57735,0.57735], [0.57735,-0.57735,0.57735], [-0.57735,0.57735,-0.57735], [0.57735,0.57735,0.57735], [0.57735,-0.57735,-0.57735], [-0.57735,-0.57735,0.57735])
) --Add This before the for loop statement
obj[i].modifiers[#unwrap_uvw].normalMap normalList spacNRM.value norClusNRM.state tpmap.selection rotClusNRM.state alnbwith.state --Change this line