Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

[SOLVED]Apply UVW unwrap to selected objects + flatten mapping with default settings...

[SOLVED]Apply UVW unwrap to selected objects + flatten mapping with default settings...

LG3D_UK
Enthusiast Enthusiast
552 Views
3 Replies
Message 1 of 4

[SOLVED]Apply UVW unwrap to selected objects + flatten mapping with default settings...

LG3D_UK
Enthusiast
Enthusiast
Hi,

I'm trying to compile a script which applys UVW unwrap to indiviual objects in a selection, then applys the flatten mapping with default values..

So far i can apply UVW unwrap to multiple objects in a selection.. but cannot get the 'flatten mapping' to work, and honestly dont know how too..

heres what i've got so far:

(
for obj in selection do
(
if isKindOf obj geometryclass then
(
addmodifier obj (Unwrap_UVW ())
obj.modifiers
obj.modifiers.flattenMapDialog


)
)
)



My task is for exporting a scene to unity for lightmapping purposes. I have a lightmapping plugin for max which will apply lightmaps through unity. To do so the max objects needs a uvw unwrap on all objects and correctly mapped (flatten mapping will do..). I tried just applying 'unwrappers' in the render to texture dialog but unity needs the uvw unwrap modifier in the stack.

I'm a maxscript newbie but the more i learn the more useful its becoming!...so any help will be much appreciated.
0 Likes
553 Views
3 Replies
Replies (3)
Message 2 of 4

LG3D_UK
Enthusiast
Enthusiast
Solved it!...

Getting use to this maxscript malarky...

script converts to mesh then applys an uvw unwrap with flatten mapping.. :)

rollout progressTest "Unity Unwrapper" width:155 height:165
(

button doit "Apply Unity Unwrappers" pos: width:129 height:21

progressBar doit_prog "" pos: width:136 height:32 color: orient:#vertical

GroupBox grp1 "Unity_Unwrapper" pos: width:141 height:75
label lbl1 "This will Convert all Objects to Editable Mesh and Apply a UVW Unwrap for Lightmapping" pos: width:123 height:52

label lbl4 "Created by : Lewis Griffiths" pos: width:140 height:13

on doit pressed do
(

objArray = geometry as array -- get all geometry objects into array

for i = 1 to objArray.count do -- and iterate through all of them

(

doit_prog.value = 100.*i/objArray.count


max modify mode
convertto objArray editable_mesh
modPanel.setCurrentObject objArray
subObjectLevel = 4
Unwrapper = Unwrap_UVW name:"Unity_Unwrapper"
Unwrapper.setApplyToWholeObject true
addModifier objArray Unwrapper
Temp = objArray.modifiers
Temp.setMapChannel 2
Temp.setTVSubObjectMode 3
Temp.flattenMap 45.0 #() 0.02 true 0 true true
subObjectLevel = 0

print objArray.name

)-- end i loop

doit_prog.value = 0
)
)


createDialog progressTest 155 165 -- create a dialog to test
0 Likes
Message 3 of 4

Anonymous
Not applicable
Just what I was looking for. I can't wait to try it out. Thanks for sharing.
0 Likes
Message 4 of 4

LG3D_UK
Enthusiast
Enthusiast
No worries! glad you can find a use for it, feel free to edit it to your spec i.e. setmapchannel etc.

only started learning maxscript recently, so hope it works ok!

cheers
0 Likes