Wednesday 6 March 2013

Flatten unwrap selected objects (for UDK lightmaps)

(credit to this guy for my starting point)

Scenario
  • You need some quick-n-dirty unwraps for lightmap baking
  • You need channel 2 unwrapped uniquely
  • You will improve them later
Usage
  • Select one or more objects
  • Run script
  • Script applies a flatten-map unwrap to channel 2
  • Warning: scripts collapses objects down to editable poly
  
-- MixeScript snippet: Flatten unwrap selected objects 
-- applies a flatten-map unwrap to selected objects, then collapses them down to editable poly.

--USAGE
-- Select one or more objects
-- Run script
-- Script applies a flatten-map unwrap to channel 2
-- Warning: scripts collapses objects down to editable poly

-- SETTINGS
UnwrapChannel = 2
 
objarray = getCurrentSelection()
max modify mode    
  
for obj in objarray do 
(
 convertto obj editable_mesh
    modPanel.setCurrentObject obj
    subObjectLevel = 4
    UnwrapMod = Unwrap_UVW name:"UnwrapMod"
    UnwrapMod.setApplyToWholeObject true
    addModifier obj UnwrapMod
    Temp = obj.modifiers["UnwrapMod"]
    Temp.setMapChannel UnwrapChannel
    Temp.setTVSubObjectMode 3
    Temp.flattenMap 45.0 #() 0.01 true 0 true true     
    subObjectLevel = 0
 UnwrapMod.packnoparams()
 UnwrapMod.pack 1 0.02 true true true
 convertto obj editable_poly 
)
select objarray
  

1 comment:

  1. THANK YOU SO MUCH, YOU MADE MY DAY!!!
    I am very happy that you shared this script, this one help me so much :D.
    Once again, thank you and I hope you have a happy day like me :D.

    ReplyDelete