1564 lines
40 KiB
Plaintext
Executable File
1564 lines
40 KiB
Plaintext
Executable File
-- THIS IS A TEMPORARY VERSION BEFORE THE UV TOOLKIT GETS MADE
|
|
-- Author: Andrew Liddle
|
|
|
|
--08/04/2015 : Merged UvDensity tool + done some little code cleaning <= Nico Malovec
|
|
--19/05/2015 : + Random features + Align + Rotations + Pivot <= Nico Malovec
|
|
|
|
|
|
filein (RsConfigGetWildWestDir() + "script/3dsMax/_common_functions/FN_RSTA_UI.ms")
|
|
-- filein ("x:\wildwest\script\3dsMax\_common_functions\FN_RSTA_UI.ms")
|
|
|
|
|
|
struct Strct_UvNumeric
|
|
(
|
|
MyObject,
|
|
ArrSelectedVerts,
|
|
VertPos,
|
|
SavedTransforms,
|
|
|
|
--Align values
|
|
UMax = 0,
|
|
UMin = 0,
|
|
VMax = 0,
|
|
VMin = 0,
|
|
UAvrg = 0,
|
|
VAvrg = 0,
|
|
|
|
|
|
--some trigger to reduce the number of functions to 1
|
|
UmaxTrigger = false,
|
|
UminTrigger = false,
|
|
UAvrgTrigger = false,
|
|
VmaxTrigger = false,
|
|
VminTrigger = false,
|
|
VAvrgTrigger = false,
|
|
|
|
|
|
-- get uv vert selection pos
|
|
fn RSTA_GetUvAlignValues =
|
|
(
|
|
|
|
moduvw = MyObject.modifiers[#unwrap_uvw]
|
|
|
|
if subobjectLevel == 2 do
|
|
(
|
|
--Try to get Edge selection. If > 0 convert to vert. if == 0 skip.
|
|
EdgeSelec = moduvw.getSelectedEdges()
|
|
EdgeSelec = EdgeSelec as array
|
|
|
|
if EdgeSelec.count > 0 do
|
|
(
|
|
moduvw.edgeToVertSelect()
|
|
)
|
|
)
|
|
|
|
-- vert selection and vert count
|
|
BitSelectedVerts = moduvw.getSelectedVerticesByNode MyObject
|
|
ArrSelectedVerts = BitSelectedVerts as array
|
|
-- VertexCount = ArrSelectedVerts.count
|
|
|
|
--get vert pos
|
|
VertPos = #()
|
|
For verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
append VertPos (moduvw.unwrap.getVertexPosition 0 ArrSelectedVerts[verti])
|
|
)
|
|
|
|
--Get an array of U pos and one of V
|
|
UposArr = #()
|
|
VposArr = #()
|
|
|
|
For Uposi = 1 to VertPos.count do
|
|
(
|
|
Upos = VertPos[Uposi][1]
|
|
append UposArr Upos
|
|
)
|
|
--Get min and max
|
|
UMax = amax UposArr
|
|
UMin = amin UposArr
|
|
|
|
For Vposi = 1 to VertPos.count do
|
|
(
|
|
Vpos = VertPos[Vposi][2]
|
|
append VposArr Vpos
|
|
)
|
|
--Get min and max
|
|
VMax = amax VposArr
|
|
VMin = amin VposArr
|
|
|
|
--Get average of of both U and V
|
|
UAvrg = 0
|
|
for Uposi = 1 to UposArr.count do
|
|
(
|
|
UAvrg+= UposArr[Uposi]
|
|
)
|
|
UAvrg = UAvrg/UposArr.count
|
|
|
|
VAvrg = 0
|
|
for Vposi = 1 to VposArr.count do
|
|
(
|
|
VAvrg+= VposArr[Vposi]
|
|
)
|
|
VAvrg = VAvrg/VposArr.count
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
--align uv vert in U or V by min max or average
|
|
fn RSTA_AllignUVverts =
|
|
(
|
|
moduvw = MyObject.modifiers[#unwrap_uvw]
|
|
|
|
|
|
if UMaxTrigger == true do
|
|
(
|
|
for verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
pos = VertPos[verti]
|
|
pos[1] = UMax
|
|
moduvw.unwrap.setVertexPosition 0 ArrSelectedVerts[verti] pos
|
|
)
|
|
)
|
|
if UMinTrigger == true do
|
|
(
|
|
for verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
pos = VertPos[verti]
|
|
pos[1] = UMin
|
|
moduvw.unwrap.setVertexPosition 0 ArrSelectedVerts[verti] pos
|
|
)
|
|
)
|
|
|
|
if VMaxTrigger == true do
|
|
(
|
|
for verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
pos = VertPos[verti]
|
|
pos[2] = VMax
|
|
moduvw.unwrap.setVertexPosition 0 ArrSelectedVerts[verti] pos
|
|
)
|
|
)
|
|
if VMinTrigger == true do
|
|
(
|
|
for verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
pos = VertPos[verti]
|
|
pos[2] = VMin
|
|
moduvw.unwrap.setVertexPosition 0 ArrSelectedVerts[verti] pos
|
|
)
|
|
)
|
|
if UAvrgTrigger == true do
|
|
(
|
|
for verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
pos = VertPos[verti]
|
|
pos[1] = UAvrg
|
|
moduvw.unwrap.setVertexPosition 0 ArrSelectedVerts[verti] pos
|
|
)
|
|
)
|
|
if VAvrgTrigger == true do
|
|
(
|
|
for verti = 1 to ArrSelectedVerts.count do
|
|
(
|
|
pos = VertPos[verti]
|
|
pos[2] = VAvrg
|
|
moduvw.unwrap.setVertexPosition 0 ArrSelectedVerts[verti] pos
|
|
)
|
|
)
|
|
|
|
),
|
|
|
|
|
|
|
|
--check for an unwrap modifier. if not present, add one.
|
|
fn RSTA_CheckForUnwrap =
|
|
(
|
|
if MyObject.modifiers[#unwrap_uvw] == undefined do
|
|
(
|
|
try
|
|
(
|
|
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
|
|
)catch()
|
|
)
|
|
)
|
|
|
|
|
|
)
|
|
Strct_UvNumeric = Strct_UvNumeric()
|
|
|
|
|
|
struct Strct_UvRandomization
|
|
(
|
|
MyObject,
|
|
UTrigger = false,
|
|
VTrigger = false,
|
|
offset = [0,0,0],
|
|
|
|
MinU = 0.0,
|
|
MaxU = 0.25,
|
|
|
|
MinV = 0.0,
|
|
MaxV = 0.25,
|
|
|
|
elemarray = #(),
|
|
moduvw,
|
|
UvSelected = true,
|
|
BitSelectedVerts,
|
|
Usteps = 0.0,
|
|
Vsteps = 0.0,
|
|
StepsArr = #(),
|
|
StepsVArr = #(),
|
|
|
|
AllVertsArr,
|
|
SavedTransforms = #(),
|
|
|
|
|
|
UFlipTrigger = false,
|
|
VFlipTrigger = false,
|
|
|
|
|
|
--Save initial UV transforms for reset options
|
|
fn RSTA_Ini_UV =
|
|
(
|
|
moduvw = MyObject.modifiers[#unwrap_uvw]
|
|
VertexCount = moduvw.unwrap.numbervertices()
|
|
AllVertsArr = (#{1..VertexCount} as array)
|
|
|
|
For verti = 1 to AllVertsArr.count do
|
|
(
|
|
append SavedTransforms (moduvw.unwrap.getVertexPosition 0 verti)
|
|
)
|
|
),
|
|
|
|
--Reload initial UV values
|
|
fn Reload_Ini_Uv =
|
|
(
|
|
For verti = 1 to SavedTransforms.count do
|
|
(
|
|
moduvw = MyObject.modifiers[#unwrap_uvw]
|
|
pos = SavedTransforms[verti]
|
|
moduvw.unwrap.setVertexPosition 0 verti pos
|
|
)
|
|
),
|
|
|
|
|
|
|
|
fn RSTA_GetUV_Islands =
|
|
(
|
|
if selection.count == 1 do
|
|
(
|
|
--check we have a unwrap modifier, if not, add one.
|
|
if (ClassOf MyObject.modifiers[1]) != Unwrap_UVW do
|
|
(
|
|
addmodifier MyObject (Unwrap_UVW ())
|
|
)
|
|
|
|
moduvw = MyObject.modifiers[#unwrap_uvw]
|
|
|
|
--get selected vertice count. if == 0 get all of them
|
|
BitSelectedVerts = moduvw.getSelectedVerticesByNode MyObject
|
|
ArrSelectedVerts = BitSelectedVerts as array
|
|
VertexCount = ArrSelectedVerts.count
|
|
if VertexCount != 0 do
|
|
(
|
|
UvSelected = true
|
|
)
|
|
if VertexCount == 0 do
|
|
(
|
|
UvSelected = false
|
|
VertexCount = moduvw.unwrap.numbervertices()
|
|
BitSelectedVerts = #{1..VertexCount}
|
|
ArrSelectedVerts = (BitSelectedVerts as array)
|
|
moduvw.unwrap.selectVertices BitSelectedVerts
|
|
)
|
|
|
|
|
|
vertelemarray=#()
|
|
modPanel.setCurrentObject moduvw
|
|
subobjectlevel = 1
|
|
---------------------------------------------------
|
|
|
|
--Loop through our selected verts, get their element
|
|
for verti=1 to VertexCount do
|
|
(
|
|
moduvw.unwrap.selectVertices #{}
|
|
MyVert = ArrSelectedVerts[verti]
|
|
moduvw.unwrap.selectVertices #{MyVert}
|
|
moduvw.unwrap2.SelectElement()
|
|
|
|
elemverts = moduvw.unwrap.getselectedvertices()
|
|
append vertelemarray elemverts
|
|
)
|
|
--Sort out the elements array. Keep only uniques
|
|
local BArrays = #()
|
|
for ThisItem in vertelemarray do
|
|
(
|
|
local isUnique = True
|
|
for ThatItem in BArrays while isUnique == true do
|
|
(
|
|
isUnique = ((ThisItem * ThatItem).NumberSet != ThisItem.NumberSet)
|
|
)
|
|
|
|
if isUnique == true do
|
|
(
|
|
append BArrays ThisItem
|
|
)
|
|
)
|
|
--here's out array of unique elements
|
|
elemarray = BArrays
|
|
)
|
|
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn RSTA_OffsetUVPos =
|
|
(
|
|
StepsArr = #()
|
|
StepsVArr = #()
|
|
modPanel.setCurrentObject moduvw
|
|
subobjectlevel = 1
|
|
-- go through all elements and apply offset
|
|
for i=1 to elemarray.count do
|
|
(
|
|
moduvw.unwrap.selectVertices elemarray[i]
|
|
elemverts=moduvw.unwrap.getselectedvertices()
|
|
|
|
--Build the offset. Two ways, with or without steps.
|
|
--steps == 0 == steps OFF
|
|
if Usteps == 0 do
|
|
(
|
|
Uoffset = random MinU MaxU
|
|
)
|
|
if Vsteps == 0 do
|
|
(
|
|
Voffset = random MinV MaxV
|
|
)
|
|
|
|
-- Offset with steps : Build an array of all possible steps
|
|
if Usteps != 0 do
|
|
(
|
|
Step = MinU
|
|
append StepsArr Step
|
|
StepCnt = ((MaxU - MinU)/Usteps)
|
|
For stepi = 1 to StepCnt do
|
|
(
|
|
Step += Usteps
|
|
append StepsArr Step
|
|
)
|
|
--Now randomly pick an item of this array == our random offset
|
|
--Generate random Array Item
|
|
RdItem = random 1 StepsArr.count
|
|
RdValue = StepsArr[RdItem]
|
|
Uoffset = RdValue
|
|
)
|
|
if Vsteps != 0 do
|
|
(
|
|
Step = MinV
|
|
append StepsVArr Step
|
|
StepCnt = ((MaxV - MinV)/Vsteps)
|
|
For stepi = 1 to StepCnt do
|
|
(
|
|
Step += Vsteps
|
|
append StepsVArr Step
|
|
)
|
|
--Now randomly pick an item of this array == our random offset
|
|
--Generate random Array Item
|
|
RdItem = random 1 StepsVArr.count
|
|
RdValue = StepsVArr[RdItem]
|
|
Voffset = RdValue
|
|
)
|
|
|
|
|
|
--Loop through the island, offset them
|
|
for verti in elemverts do
|
|
(
|
|
uvwpos = moduvw.unwrap.getVertexPosition 0 verti
|
|
if UTrigger == true do
|
|
(
|
|
uvwpos[1] += Uoffset
|
|
)
|
|
if VTrigger == true do
|
|
(
|
|
uvwpos[2] += Voffset
|
|
)
|
|
|
|
moduvw.unwrap.setVertexPosition 0 verti uvwpos
|
|
)
|
|
|
|
-- If Flip triggers are ON. Random Flip too
|
|
If UFlipTrigger == true do
|
|
(
|
|
-- pick a random number. if this number is even , flip. If not, don't flip
|
|
RdmNB = random 1 100
|
|
if (mod RdmNB 2) == 0 do
|
|
(
|
|
moduvw.unwrap.selectVertices elemarray[i]
|
|
moduvw.unwrap.flipHorizontal()
|
|
)
|
|
)
|
|
If VFlipTrigger == true do
|
|
(
|
|
RdmNB = random 1 100
|
|
if (mod RdmNB 2) == 0 do
|
|
(
|
|
moduvw.unwrap.selectVertices elemarray[i]
|
|
moduvw.unwrap.flipVertical()
|
|
)
|
|
)
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--put back the vert selection as it was
|
|
if UvSelected == false do
|
|
(
|
|
moduvw.unwrap.selectVertices #{}
|
|
)
|
|
if UvSelected == true do
|
|
(
|
|
moduvw.unwrap.selectVertices BitSelectedVerts
|
|
)
|
|
|
|
subobjectlevel = 0
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
)
|
|
Strct_UvRandomization = Strct_UvRandomization()
|
|
|
|
|
|
|
|
|
|
struct Strct_UvAutoRatio
|
|
(
|
|
MyObject,
|
|
MyObjects=#(),
|
|
MyRollout,
|
|
AveFaceArea = 0,
|
|
DensityRatio = 1,
|
|
areaUVW = 0,
|
|
areaGeom = 0,
|
|
pickSwitch = false,
|
|
|
|
TextureSizeX = 1,
|
|
TextureSizeY = 1,
|
|
Worldm = 1,
|
|
|
|
numericSwitch = false,
|
|
|
|
|
|
--Get 3D Surface area
|
|
--Get UV Surface area
|
|
--How many time 3D Surface area in the UV one ? => get ratio out of it
|
|
fn RSTA_GetRatio =
|
|
(
|
|
|
|
FaceNb = polyop.getNumFaces MyObject
|
|
FaceBitArray = #{1..FaceNb}
|
|
|
|
myUnwrapMod = unWrap_UVW()
|
|
addModifier MyObject myUnwrapMod
|
|
|
|
areaUVW = #()
|
|
areaGeom = #()
|
|
x = #()
|
|
y = #()
|
|
height = #()
|
|
MyObject.modifiers[#unwrap_uvw].getArea FaceBitArray &x &y &width &height &areaUVW &areaGeom
|
|
|
|
|
|
DensityRatio = areaUVW/areaGeom
|
|
|
|
deleteModifier MyObject myUnwrapMod
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
-- Density ratio from world metric system : Texture Size / Metric Unit <= for the numeric option only
|
|
fn RSTA_GetMetricsRatio =
|
|
(
|
|
TxtArea = TextureSizeX * TextureSizeY
|
|
|
|
DensityRatio = TxtArea/Worldm
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
--Past ratio to selected meshs
|
|
fn RSTA_PastDansity =
|
|
(
|
|
MyObjects = #()
|
|
|
|
for selecti in selection do
|
|
(
|
|
append MyObjects selecti
|
|
)
|
|
|
|
|
|
uv_channel = 1
|
|
scale_center = [0,0,0]
|
|
|
|
For Objecti = 1 to MyObjects.count do
|
|
(
|
|
MyPastObject = MyObjects[Objecti]
|
|
|
|
clearSelection()
|
|
select MyPastObject
|
|
|
|
FaceNb = polyop.getNumFaces MyPastObject
|
|
FaceBitArray = #{1..FaceNb}
|
|
|
|
|
|
myUnwrapMod = unWrap_UVW()
|
|
addModifier MyPastObject myUnwrapMod
|
|
|
|
TempareaUVW = #()
|
|
TempareaGeom = #()
|
|
Tempx = #()
|
|
Tempy = #()
|
|
Tempheight = #()
|
|
MyPastObject.modifiers[#unwrap_uvw].getArea FaceBitArray &Tempx &Tempy &Tempwidth &Tempheight &TempareaUVW &TempareaGeom
|
|
|
|
TempDensityRatio = TempareaUVW/TempareaGeom
|
|
|
|
|
|
|
|
maxOps.CollapseNodeTo MyPastObject 1 off
|
|
|
|
|
|
for verti = 1 to (polyop.getnummapverts MyPastObject uv_channel) do
|
|
(
|
|
pos = polyop.getmapvert MyPastObject uv_channel verti
|
|
|
|
NewPos = (pos - scale_center)*( (((sqrt TempareaGeom)*DensityRatio)/((sqrt TempareaUVW)*DensityRatio)) *sqrt DensityRatio ) + scale_center
|
|
|
|
polyop.setmapvert MyPastObject uv_channel verti NewPos
|
|
)
|
|
|
|
update MyPastObject
|
|
)
|
|
|
|
select MyObjects
|
|
|
|
)
|
|
|
|
|
|
)
|
|
Strct_UvAutoRatio = Strct_UvAutoRatio()
|
|
|
|
|
|
rollout UvRandom "Uv Random"
|
|
(
|
|
group "Random Pos"
|
|
(
|
|
checkbox cbx_Urandom "U Offset :" offset:[1,0] align:#left
|
|
spinner spn_UStep "Steps" range:[-100,100,0] align:#right width:60 offset:[-5,-20]
|
|
spinner spn_Urandom1 "Min" range:[-100,100,0] align:#right width:60 offset:[-80,-2]
|
|
spinner spn_Urandom2 "Max" range:[-100,100,0.25] align:#right width:65 offset:[-5,-21]
|
|
checkbox cbx_Vrandom "V Offset :" offset:[2,5] align:#left
|
|
spinner spn_VStep "Steps" range:[-100,100,0] align:#right width:60 offset:[-5,-19]
|
|
spinner spn_Vrandom1 "Min" range:[-100,100,0] align:#right width:60 offset:[-80,-2]
|
|
spinner spn_Vrandom2 "Max" range:[-100,100,0.25] align:#right width:65 offset:[-5,-21]
|
|
|
|
Button btn_Randomize "Randomize Selected" width:125 height:25 align:#right offset:[-15,5] toolTip:""
|
|
|
|
)
|
|
|
|
group "Random Flip"
|
|
(
|
|
checkbox cbx_rdmUFlip "U Flip" offset:[1,0] align:#left
|
|
checkbox cbx_rdmVFlip "V Flip" offset:[1,0] align:#left
|
|
)
|
|
|
|
|
|
Button btn_Reset "Undo" width:125 height:25 align:#right offset:[-15,0] toolTip:""
|
|
|
|
|
|
|
|
|
|
on cbx_rdmUFlip changed arg do
|
|
(
|
|
Strct_UvRandomization.UFlipTrigger = arg
|
|
)
|
|
on cbx_rdmVFlip changed arg do
|
|
(
|
|
Strct_UvRandomization.VFlipTrigger = arg
|
|
)
|
|
|
|
|
|
|
|
on btn_Reset pressed do
|
|
(
|
|
Strct_UvRandomization.Reload_Ini_Uv()
|
|
)
|
|
|
|
|
|
|
|
on spn_UStep changed arg do
|
|
(
|
|
Strct_UvRandomization.Usteps = arg
|
|
)
|
|
on spn_VStep changed arg do
|
|
(
|
|
Strct_UvRandomization.Vsteps = arg
|
|
)
|
|
|
|
|
|
|
|
on spn_Urandom2 changed arg do
|
|
(
|
|
Strct_UvRandomization.MaxU = arg
|
|
)
|
|
|
|
on spn_Vrandom1 changed arg do
|
|
(
|
|
Strct_UvRandomization.MinV = arg
|
|
)
|
|
on spn_Vrandom2 changed arg do
|
|
(
|
|
Strct_UvRandomization.MaxV = arg
|
|
)
|
|
|
|
|
|
on UvRandom rolledUp bState do
|
|
(
|
|
if (bState == true) then
|
|
(
|
|
tab_example.height += UvRandom.height
|
|
tab_example.height += 4
|
|
)
|
|
else
|
|
(
|
|
tab_example.height -= UvRandom.height
|
|
tab_example.height -= 4
|
|
)
|
|
)
|
|
|
|
|
|
On UvRandom open do
|
|
(
|
|
spn_Urandom1.enabled = false
|
|
spn_Urandom2.enabled = false
|
|
spn_Vrandom1.enabled = false
|
|
spn_Vrandom2.enabled = false
|
|
spn_UStep.enabled = false
|
|
spn_VStep.enabled = false
|
|
)
|
|
|
|
on cbx_Urandom changed arg do
|
|
(
|
|
if arg == true do
|
|
(
|
|
spn_Urandom1.enabled = true
|
|
spn_Urandom2.enabled = true
|
|
Strct_UvRandomization.UTrigger = true
|
|
spn_UStep.enabled = true
|
|
)
|
|
if arg == false do
|
|
(
|
|
spn_Urandom1.enabled = false
|
|
spn_Urandom2.enabled = false
|
|
Strct_UvRandomization.UTrigger = false
|
|
spn_UStep.enabled = false
|
|
)
|
|
)
|
|
|
|
on cbx_Vrandom changed arg do
|
|
(
|
|
if arg == true do
|
|
(
|
|
spn_Vrandom1.enabled = true
|
|
spn_Vrandom2.enabled = true
|
|
Strct_UvRandomization.VTrigger = true
|
|
spn_VStep.enabled = true
|
|
)
|
|
if arg == false do
|
|
(
|
|
spn_Vrandom1.enabled = false
|
|
spn_Vrandom2.enabled = false
|
|
Strct_UvRandomization.VTrigger = false
|
|
spn_VStep.enabled = false
|
|
)
|
|
)
|
|
|
|
on btn_Randomize pressed do
|
|
(
|
|
undo off
|
|
disableSceneRedraw()
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_GetUV_Islands()
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
Strct_UvRandomization.RSTA_OffsetUVPos()
|
|
undo on
|
|
enableSceneRedraw()
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
--try(DestroyDialog UvAutoRatio)catch()
|
|
rollout UvAutoRatio "Uv Density"
|
|
(
|
|
label lblDensityMethod "Get Texel Density Method" align:#left offset:[10,10]
|
|
radiobuttons rdb_GetMethod labels:#("Pick", "Numeric") offset:[0,-3]
|
|
|
|
label lblDummy "" align:#right offset:[-40,2]
|
|
group "Pick Texel Density"
|
|
(
|
|
Button btn_PickRatio "Pick Density" width:125 height:30 align:#right offset:[-12,5] toolTip:"yo"
|
|
|
|
label lblGeoStats "Mesh Stats :" align:#right offset:[-40,0]
|
|
label lblGeoName "Geo Name :" align:#right offset:[-90,0]
|
|
label lblGeoNameDisp "Null" align:#left offset:[65,-18] width:92
|
|
label lblGeoArea "Geo Area :" align:#right offset:[-90,0]
|
|
label lblGeoAreaDisp "Null" align:#left offset:[65,-18]
|
|
label lblUVArea "UV Area :" align:#right offset:[-90,0]
|
|
label lblUVAreaDisp "Null" align:#left offset:[65,-18]
|
|
label lblDensity "Density :" align:#right offset:[-90,0]
|
|
label lblDensityDisp "Null" align:#left offset:[65,-18]
|
|
)
|
|
group "Type Texel Density"
|
|
(
|
|
|
|
checkbox cbx_worldMtrx "" offset:[2,10] align:#left
|
|
label lblWorldMethod "World Metrics :" align:#left offset:[28,-20]
|
|
label lblTextureSize "- Texture Size :" align:#left offset:[0,0]
|
|
spinner spn_TextureSze1 "" range:[0,10000,1] align:#right width:60 offset:[-80,-2]
|
|
spinner spn_TextureSze2 "x " range:[0,10000,1] align:#right width:65 offset:[-8,-23]
|
|
spinner spn_WrldMts "- World m� :" range:[0,10000,1] align:#right width:100 offset:[-32,5]
|
|
|
|
label lblNumDensity "Density :" align:#right offset:[-95,0]
|
|
label lblNumDensityDisp "Null" align:#left offset:[55,-17]
|
|
|
|
label lblDummy3 "-----------------" align:#right offset:[-40,0]
|
|
|
|
checkbox cbx_UvSpace "" offset:[3,0] align:#left
|
|
label lblUvMethod "Uv Space :" align:#left offset:[28,-18]
|
|
spinner spn_Density "- Density :" range:[0,100,1] align:#left width:100 offset:[0,2]
|
|
label lblDummy2 "" align:#right offset:[-40,0]
|
|
)
|
|
|
|
Button btn_PastRatio "Paste Density" width:125 height:30 align:#right offset:[-10,0] toolTip:"yo"
|
|
|
|
|
|
|
|
|
|
on UvAutoRatio rolledUp bState do
|
|
(
|
|
if (bState == true) then
|
|
(
|
|
tab_example.height += UvAutoRatio.height
|
|
tab_example.height += 4
|
|
)
|
|
else
|
|
(
|
|
tab_example.height -= UvAutoRatio.height
|
|
tab_example.height -= 4
|
|
)
|
|
)
|
|
|
|
|
|
|
|
on spn_TextureSze1 changed arg do
|
|
(
|
|
Strct_UvAutoRatio.TextureSizeX = arg
|
|
Strct_UvAutoRatio.RSTA_GetMetricsRatio()
|
|
lblNumDensityDisp.text = Strct_UvAutoRatio.DensityRatio as string
|
|
)
|
|
|
|
on spn_TextureSze1 changed arg do
|
|
(
|
|
Strct_UvAutoRatio.TextureSizeY = arg
|
|
Strct_UvAutoRatio.RSTA_GetMetricsRatio()
|
|
lblNumDensityDisp.text = Strct_UvAutoRatio.DensityRatio as string
|
|
)
|
|
|
|
on spn_WrldMts changed arg do
|
|
(
|
|
Strct_UvAutoRatio.Worldm = arg
|
|
Strct_UvAutoRatio.RSTA_GetMetricsRatio()
|
|
lblNumDensityDisp.text = Strct_UvAutoRatio.DensityRatio as string
|
|
)
|
|
|
|
|
|
|
|
on UvAutoRatio open do
|
|
(
|
|
Strct_UvAutoRatio.MyRollout = UvAutoRatio
|
|
|
|
lblDummy3.enabled = false
|
|
lblWorldMethod.enabled = false
|
|
lblTextureSize.enabled = false
|
|
spn_TextureSze1.enabled = false
|
|
spn_TextureSze2.enabled = false
|
|
spn_WrldMts.enabled = false
|
|
lblUvMethod.enabled = false
|
|
spn_Density.enabled = false
|
|
|
|
lblNumDensity.enabled = false
|
|
lblNumDensityDisp.enabled = false
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
on cbx_worldMtrx changed arg do
|
|
(
|
|
if arg == true do
|
|
(
|
|
|
|
Strct_UvAutoRatio.RSTA_GetMetricsRatio()
|
|
|
|
cbx_UvSpace.state = false
|
|
spn_Density.enabled = false
|
|
|
|
lblTextureSize.enabled = true
|
|
spn_TextureSze1.enabled = true
|
|
spn_TextureSze2.enabled = true
|
|
spn_WrldMts.enabled = true
|
|
|
|
lblNumDensity.enabled = true
|
|
lblNumDensityDisp.enabled = true
|
|
|
|
)
|
|
if arg == false do
|
|
(
|
|
Strct_UvAutoRatio.DensityRatio = spn_Density.value
|
|
|
|
|
|
cbx_UvSpace.state = true
|
|
spn_Density.enabled = true
|
|
|
|
|
|
lblTextureSize.enabled = false
|
|
spn_TextureSze1.enabled = false
|
|
spn_TextureSze2.enabled = false
|
|
spn_WrldMts.enabled = false
|
|
|
|
lblNumDensity.enabled = false
|
|
lblNumDensityDisp.enabled = false
|
|
|
|
)
|
|
)
|
|
|
|
|
|
on cbx_UvSpace changed arg do
|
|
(
|
|
if arg == true do
|
|
(
|
|
Strct_UvAutoRatio.DensityRatio = spn_Density.value
|
|
|
|
cbx_worldMtrx.state = false
|
|
spn_Density.enabled = true
|
|
|
|
lblTextureSize.enabled = false
|
|
spn_TextureSze1.enabled = false
|
|
spn_TextureSze2.enabled = false
|
|
spn_WrldMts.enabled = false
|
|
|
|
lblNumDensity.enabled = false
|
|
lblNumDensityDisp.enabled = false
|
|
)
|
|
if arg == false do
|
|
(
|
|
Strct_UvAutoRatio.RSTA_GetMetricsRatio()
|
|
|
|
|
|
cbx_worldMtrx.state = true
|
|
spn_Density.enabled = false
|
|
|
|
lblTextureSize.enabled = true
|
|
spn_TextureSze1.enabled = true
|
|
spn_TextureSze2.enabled = true
|
|
spn_WrldMts.enabled = true
|
|
|
|
lblNumDensity.enabled = true
|
|
lblNumDensityDisp.enabled = true
|
|
)
|
|
)
|
|
|
|
|
|
|
|
on rdb_GetMethod changed arg do
|
|
(
|
|
if arg == 1 do
|
|
(
|
|
|
|
Strct_UvAutoRatio.numericSwitch = false
|
|
|
|
btn_PickRatio.enabled = true
|
|
lblGeoStats.enabled = true
|
|
lblGeoName.enabled = true
|
|
lblGeoNameDisp.enabled = true
|
|
lblGeoArea.enabled = true
|
|
lblGeoAreaDisp.enabled = true
|
|
lblUVArea.enabled = true
|
|
lblUVAreaDisp.enabled = true
|
|
lblDensity.enabled = true
|
|
lblDensityDisp.enabled = true
|
|
|
|
|
|
|
|
lblWorldMethod.enabled = false
|
|
lblTextureSize.enabled = false
|
|
spn_TextureSze1.enabled = false
|
|
spn_TextureSze2.enabled = false
|
|
spn_WrldMts.enabled = false
|
|
lblUvMethod.enabled = false
|
|
lblDummy3.enabled = false
|
|
lblUvMethod.enabled = false
|
|
spn_Density.enabled = false
|
|
|
|
cbx_worldMtrx.enabled = false
|
|
cbx_worldMtrx.state = false
|
|
cbx_UvSpace.enabled = false
|
|
cbx_UvSpace.state = false
|
|
|
|
lblNumDensity.enabled = false
|
|
lblNumDensityDisp.enabled = false
|
|
)
|
|
if arg == 2 do
|
|
(
|
|
Strct_UvAutoRatio.numericSwitch = true
|
|
|
|
lblNumDensity.enabled = true
|
|
lblNumDensityDisp.enabled = true
|
|
|
|
cbx_worldMtrx.enabled = true
|
|
cbx_worldMtrx.state = true
|
|
cbx_UvSpace.enabled = true
|
|
cbx_UvSpace.state = false
|
|
|
|
btn_PickRatio.enabled = false
|
|
lblGeoStats.enabled = false
|
|
lblGeoName.enabled = false
|
|
lblGeoNameDisp.enabled = false
|
|
lblGeoArea.enabled = false
|
|
lblGeoAreaDisp.enabled = false
|
|
lblUVArea.enabled = false
|
|
lblUVAreaDisp.enabled = false
|
|
lblDensity.enabled = false
|
|
lblDensityDisp.enabled = false
|
|
|
|
|
|
|
|
lblWorldMethod.enabled = true
|
|
lblTextureSize.enabled = true
|
|
spn_TextureSze1.enabled = true
|
|
spn_TextureSze2.enabled = true
|
|
spn_WrldMts.enabled = true
|
|
lblUvMethod.enabled = true
|
|
lblDummy3.enabled = true
|
|
|
|
lblUvMethod.enabled = true
|
|
spn_Density.enabled = false
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
on btn_PickRatio pressed do
|
|
(
|
|
Strct_UvAutoRatio.MyObject = selection[1]
|
|
Strct_UvAutoRatio.RSTA_GetRatio()
|
|
|
|
lblGeoNameDisp.text = Strct_UvAutoRatio.MyObject.name
|
|
lblDensityDisp.text = Strct_UvAutoRatio.DensityRatio as string
|
|
lblUVAreaDisp.text = Strct_UvAutoRatio.areaUVW as string
|
|
lblGeoAreaDisp.text = Strct_UvAutoRatio.areaGeom as string
|
|
|
|
Strct_UvAutoRatio.pickSwitch = true
|
|
)
|
|
|
|
|
|
on btn_PastRatio pressed do
|
|
(
|
|
if Strct_UvAutoRatio.numericSwitch == false do
|
|
(
|
|
if Strct_UvAutoRatio.pickSwitch == true do
|
|
(
|
|
undo off
|
|
disableSceneRedraw()
|
|
Strct_UvAutoRatio.RSTA_PastDansity()
|
|
undo on
|
|
enableSceneRedraw()
|
|
completeRedraw()
|
|
)
|
|
)
|
|
if Strct_UvAutoRatio.numericSwitch == true do
|
|
(
|
|
undo off
|
|
disableSceneRedraw()
|
|
Strct_UvAutoRatio.RSTA_PastDansity()
|
|
undo on
|
|
enableSceneRedraw()
|
|
completeRedraw()
|
|
)
|
|
)
|
|
|
|
|
|
on spn_Density changed arg do
|
|
(
|
|
Strct_UvAutoRatio.DensityRatio = arg
|
|
)
|
|
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
rollout UvMisc "Misc"
|
|
(
|
|
group "Misc"
|
|
(
|
|
button btn_DetachEdgeVert "Detatch edge verts" height:25 width:140 offset:[0,-5]
|
|
button btn_AddUnwrap "Apply Unwrap modifier" height:25 width:140 offset:[0,0]
|
|
)
|
|
|
|
|
|
on btn_DetachEdgeVert pressed do
|
|
(
|
|
actionMan.executeAction 2077580866 "40037"
|
|
)
|
|
on btn_AddUnwrap pressed do
|
|
(
|
|
modPanel.addModToSelection (Unwrap_UVW ()) ui:on
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
try (destroyDialog rsta_UvNumeric) catch()
|
|
rollout rsta_UvNumeric "UvNumeric" width:150
|
|
(
|
|
-- BANNER -------------------------------------------------------------
|
|
--dotNetControl rsBannerPanel "Panel" pos:[2,3] height:32 width:( rsta_UvNumeric.width - 5)
|
|
--local banner = makeRsBanner dn_Panel:rsBannerPanel versionNum:0.01 versionName:"" wiki:"WIKI_NAME" filename:(getThisScriptFilename())
|
|
|
|
|
|
-- LOCAL -----------------------------------------------------------------
|
|
local customU= 0.5
|
|
local customV= 0.5
|
|
local offset = 0.5
|
|
|
|
|
|
group "Set Origin"
|
|
(
|
|
spinner centre_u "U:" width:70 range:[-10000.0,10000.0,0.5] type:#float align:#left across:2
|
|
spinner centre_v "V:" width:70 range:[-10000.0,10000.0,0.5] type:#float align:#left
|
|
button btn_cen_uv "Get Centre" width:60 height:25 align:#left
|
|
button btn_cen_u "U" width:25 height:25 align:#left offset:[69,-30]
|
|
button btn_cen_v "V" width:25 height:25 align:#left offset:[100,-30]
|
|
button btn_piv_uv "Get Pivot" width:60 height:25 align:#left
|
|
button btn_piv_u "U" width:25 height:25 align:#left offset:[69,-30]
|
|
button btn_piv_v "V" width:25 height:25 align:#left offset:[100,-30]
|
|
)
|
|
|
|
group "UV Scale"
|
|
(
|
|
label lbl_UScale "U Scale:" align:#right offset:[0,0] across:4
|
|
button btn_Uscale2 "2.0" width:30 height:25 offset:[0,-5]
|
|
button btn_Uscale05 "0.5" width:30 height:25 offset:[-2,-5]
|
|
button btn_Uscale025 "0.25" width:30 height:25 offset:[0,-5]
|
|
button btn_CustomUScale "Custom:" width:60 height:25 align:#left offset:[-2,-2]
|
|
editText edt1 "" width:80 align:#left offset:[58,-27]
|
|
|
|
label lbl_space "---------------------" offset:[2,0]
|
|
|
|
label lbl_VScale "V Scale:" across:4 offset:[0,0]
|
|
button btn_Vscale2 "2.0" width:30 height:25 offset:[0,-4]
|
|
button btn_Vscale05 "0.5" width:30 height:25 offset:[-2,-4]
|
|
button btn_Vscale025 "0.25" width:30 height:25 offset:[0,-4]
|
|
button btn_CustomVScale "Custom:" width:60 height:25 align:#left offset:[-2,-2]
|
|
editText edt2 "" width:80 align:#left offset:[60,-25]
|
|
label lbl_dummy "" offset:[0,-8]
|
|
)
|
|
|
|
group "Rotate"
|
|
(
|
|
button btn_rot_cw "-90" width:25 height:25 align:#left offset:[104,-2]
|
|
button btn_rot_ccw "+90" width:25 height:25 align:#left offset:[132,-30]
|
|
button btn_rot_custom "Custom:" width:50 height:25 align:#left offset:[-2,-30]
|
|
editText edt_rotation_angle "" width:50 type:#float align:#left offset:[46,-27]
|
|
label lbl_dummy2 "" offset:[0,-8]
|
|
)
|
|
|
|
group "Offset :"
|
|
(
|
|
editText edt3 "" width:50 offset:[-4,-5]
|
|
button btn_UP "Up" width:45 height:25 offset:[25,-25]
|
|
button btn_Left "Left" width:45 across:2 height:25 offset:[32,0]
|
|
button btn_Right "Right" width:45 height:25 offset:[20,0]
|
|
button btn_Down "Down" width:45 height:25 offset:[25,0]
|
|
)
|
|
|
|
group "Align UV Verts"
|
|
(
|
|
label lbl_AlignU "AlignU:" align:#right offset:[-122,5]
|
|
button btn_AlignUMax "Max" height:25 width:40 offset:[-25,-25]
|
|
button btn_AlignUMin "Min" height:25 width:40 offset:[17,-30]
|
|
button btn_AlignUAvrg "Averg" height:25 width:40 offset:[60,-30]
|
|
|
|
label lbl_AlignV "AlignV:" align:#right offset:[-122,10]
|
|
button btn_AlignVMax "Max" height:25 width:40 offset:[-25,-25]
|
|
button btn_AlignVMin "Min" height:25 width:40 offset:[17,-30]
|
|
button btn_AlignVAvrg "Averg" height:25 width:40 offset:[60,-30]
|
|
|
|
Button btn_Reset "Undo" width:125 height:25 align:#right offset:[-13,2] toolTip:""
|
|
)
|
|
|
|
|
|
|
|
|
|
--EVENT-------------------------------------------------------------
|
|
|
|
on btn_cen_u pressed do
|
|
(
|
|
local cen = selection[1].unwrap_uvw.unwrap2.getSelCenter()
|
|
centre_u.value = cen[1]
|
|
)
|
|
|
|
on btn_piv_u pressed do
|
|
(
|
|
local piv = selection[1].unwrap_uvw.unwrap2.getSelCenter() + selection[1].unwrap_uvw.unwrap2.getPivotOffset()
|
|
centre_u.value = piv[1]
|
|
)
|
|
|
|
on btn_cen_v pressed do
|
|
(
|
|
local cen = selection[1].unwrap_uvw.unwrap2.getSelCenter()
|
|
centre_v.value = cen[2]
|
|
)
|
|
|
|
on btn_piv_v pressed do
|
|
(
|
|
local piv = selection[1].unwrap_uvw.unwrap2.getSelCenter() + selection[1].unwrap_uvw.unwrap2.getPivotOffset()
|
|
centre_v.value = piv[2]
|
|
)
|
|
|
|
on btn_cen_uv pressed do
|
|
(
|
|
local cen = selection[1].unwrap_uvw.unwrap2.getSelCenter()
|
|
centre_u.value = cen[1]
|
|
centre_v.value = cen[2]
|
|
)
|
|
|
|
on btn_piv_uv pressed do
|
|
(
|
|
local piv = selection[1].unwrap_uvw.unwrap2.getSelCenter() + selection[1].unwrap_uvw.unwrap2.getPivotOffset()
|
|
centre_u.value = piv[1]
|
|
centre_v.value = piv[2]
|
|
)
|
|
|
|
|
|
|
|
on btn_rot_cw pressed do
|
|
(
|
|
selection[1].unwrap_uvw.unwrap2.rotateSelected (degToRad -90.0) [centre_u.value, centre_v.value, 0.0]
|
|
)
|
|
|
|
on btn_rot_ccw pressed do
|
|
(
|
|
selection[1].unwrap_uvw.unwrap2.rotateSelected (degToRad 90.0) [centre_u.value, centre_v.value, 0.0]
|
|
)
|
|
|
|
on btn_rot_custom pressed do
|
|
(
|
|
selection[1].unwrap_uvw.unwrap2.rotateSelected (degToRad -(edt_rotation_angle.text as integer)) [centre_u.value, centre_v.value, 0.0]
|
|
)
|
|
|
|
|
|
on btn_Reset pressed do
|
|
(
|
|
Strct_UvRandomization.Reload_Ini_Uv()
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
on btn_AlignUMax pressed do
|
|
(
|
|
undo off()
|
|
--try, if you cant it means nothing is selected so do nothing instead of crashing on me you code.
|
|
try (
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
|
|
--same undo button than random rollout so just fetch the functions in it
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
|
|
--One function to govern them all
|
|
Strct_UvNumeric.UmaxTrigger = true
|
|
Strct_UvNumeric.UminTrigger = false
|
|
Strct_UvNumeric.UAvrgTrigger = false
|
|
Strct_UvNumeric.VmaxTrigger = false
|
|
Strct_UvNumeric.VminTrigger = false
|
|
Strct_UvNumeric.VAvrgTrigger = false
|
|
|
|
--get align values and then align
|
|
Strct_UvNumeric.RSTA_GetUvAlignValues()
|
|
Strct_UvNumeric.RSTA_AllignUVverts()
|
|
)
|
|
catch()
|
|
undo on()
|
|
)
|
|
|
|
|
|
on btn_AlignUMin pressed do
|
|
(
|
|
undo off()
|
|
--try, if you cant it means nothing is selected so do nothing instead of crashing on me you code.
|
|
try (
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
|
|
--same undo button than random rollout so just fetch the functions in it
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
|
|
Strct_UvNumeric.UmaxTrigger = false
|
|
Strct_UvNumeric.UminTrigger = true
|
|
Strct_UvNumeric.UAvrgTrigger = false
|
|
Strct_UvNumeric.VmaxTrigger = false
|
|
Strct_UvNumeric.VminTrigger = false
|
|
Strct_UvNumeric.VAvrgTrigger = false
|
|
|
|
Strct_UvNumeric.RSTA_GetUvAlignValues()
|
|
Strct_UvNumeric.RSTA_AllignUVverts()
|
|
)
|
|
catch()
|
|
undo on()
|
|
|
|
)
|
|
|
|
|
|
on btn_AlignUAvrg pressed do
|
|
(
|
|
undo off()
|
|
--try, if you cant it means nothing is selected so do nothing instead of crashing on me you code.
|
|
try (
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
|
|
--same undo button than random rollout so just fetch the functions in it
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
|
|
Strct_UvNumeric.UmaxTrigger = false
|
|
Strct_UvNumeric.UminTrigger = false
|
|
Strct_UvNumeric.UAvrgTrigger = true
|
|
Strct_UvNumeric.VmaxTrigger = false
|
|
Strct_UvNumeric.VminTrigger = false
|
|
Strct_UvNumeric.VAvrgTrigger = false
|
|
|
|
Strct_UvNumeric.RSTA_GetUvAlignValues()
|
|
Strct_UvNumeric.RSTA_AllignUVverts()
|
|
)
|
|
catch()
|
|
undo on()
|
|
)
|
|
|
|
on btn_AlignVMax pressed do
|
|
(
|
|
undo off()
|
|
--try, if you cant it means nothing is selected so do nothing instead of crashing on me you code.
|
|
try (
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
|
|
--same undo button than random rollout so just fetch the functions in it
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
|
|
Strct_UvNumeric.UmaxTrigger = false
|
|
Strct_UvNumeric.UminTrigger = false
|
|
Strct_UvNumeric.UAvrgTrigger = false
|
|
Strct_UvNumeric.VmaxTrigger = true
|
|
Strct_UvNumeric.VminTrigger = false
|
|
Strct_UvNumeric.VAvrgTrigger = false
|
|
|
|
Strct_UvNumeric.RSTA_GetUvAlignValues()
|
|
Strct_UvNumeric.RSTA_AllignUVverts()
|
|
)
|
|
catch()
|
|
undo on()
|
|
)
|
|
on btn_AlignVMin pressed do
|
|
(
|
|
undo off()
|
|
--try, if you cant it means nothing is selected so do nothing instead of crashing on me you code.
|
|
try (
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
|
|
--same undo button than random rollout so just fetch the functions in it
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
|
|
Strct_UvNumeric.UmaxTrigger = false
|
|
Strct_UvNumeric.UminTrigger = false
|
|
Strct_UvNumeric.UAvrgTrigger = false
|
|
Strct_UvNumeric.VmaxTrigger = false
|
|
Strct_UvNumeric.VminTrigger = true
|
|
Strct_UvNumeric.VAvrgTrigger = false
|
|
|
|
Strct_UvNumeric.RSTA_GetUvAlignValues()
|
|
Strct_UvNumeric.RSTA_AllignUVverts()
|
|
)
|
|
catch()
|
|
undo on()
|
|
)
|
|
on btn_AlignVAvrg pressed do
|
|
(
|
|
undo off()
|
|
--try, if you cant it means nothing is selected so do nothing instead of crashing on me you code.
|
|
try (
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
|
|
--same undo button than random rollout so just fetch the functions in it
|
|
Strct_UvRandomization.MyObject = selection[1]
|
|
Strct_UvRandomization.RSTA_Ini_UV()
|
|
|
|
Strct_UvNumeric.UmaxTrigger = false
|
|
Strct_UvNumeric.UminTrigger = false
|
|
Strct_UvNumeric.UAvrgTrigger = false
|
|
Strct_UvNumeric.VmaxTrigger = false
|
|
Strct_UvNumeric.VminTrigger = false
|
|
Strct_UvNumeric.VAvrgTrigger = true
|
|
|
|
Strct_UvNumeric.RSTA_GetUvAlignValues()
|
|
Strct_UvNumeric.RSTA_AllignUVverts()
|
|
)
|
|
catch()
|
|
undo on()
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
on chkBtn_UvDensity changed arg do
|
|
(
|
|
if arg == true do
|
|
(
|
|
--reateDialog UvAutoRatio 170 490 parent:rsta_UvNumeric.hwnd
|
|
createDialog UvAutoRatio 170 490 parent:rsta_UvNumeric.hwnd pos:(getdialogpos rsta_UvNumeric + [185,0])
|
|
setFocus rsta_UvNumeric
|
|
)
|
|
if arg == false do
|
|
(
|
|
destroyDialog UvAutoRatio
|
|
)
|
|
)
|
|
|
|
|
|
|
|
on rsta_UvNumeric open do
|
|
(
|
|
rs_dialogPosition "get" rsta_UvNumeric
|
|
-- banner.setup()
|
|
edt3.text = "0.5"
|
|
edt_rotation_angle.text = "30"
|
|
)
|
|
|
|
|
|
on rsta_UvNumeric rolledUp bState do
|
|
(
|
|
if (bState == true) then
|
|
(
|
|
tab_example.height += rsta_UvNumeric.height
|
|
tab_example.height += 4
|
|
)
|
|
else
|
|
(
|
|
tab_example.height -= rsta_UvNumeric.height
|
|
tab_example.height -= 4
|
|
)
|
|
)
|
|
|
|
|
|
on rsta_UvNumeric moved arg do
|
|
(
|
|
if (UvAutoRatio != undefined) do SetDialogPos UvAutoRatio (arg + [185,0])
|
|
)
|
|
|
|
|
|
|
|
|
|
on rsta_UvNumeric close do
|
|
(
|
|
rs_dialogPosition "set" rsta_UvNumeric
|
|
)
|
|
|
|
on btn_Uscale2 pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 2 1 [centre_u.value, centre_v.value,0]
|
|
)
|
|
on btn_Uscale05 pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 0.5 1 [centre_u.value, centre_v.value,0]
|
|
)
|
|
on btn_Uscale025 pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 0.25 1 [centre_u.value, centre_v.value,0]
|
|
)
|
|
on btn_Vscale2 pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 1 2 [centre_u.value, centre_v.value,0]
|
|
)
|
|
on btn_Vscale05 pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 1 0.5 [centre_u.value, centre_v.value,0]
|
|
)
|
|
on btn_Vscale025 pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 1 0.25 [centre_u.value, centre_v.value,0]
|
|
)
|
|
on btn_UP pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.MoveSelected [0, offset as float ,0]
|
|
)
|
|
on btn_Down pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.MoveSelected [0,(offset as float *-1),0]
|
|
)
|
|
on btn_Right pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.MoveSelected [offset as float ,0,0]
|
|
)
|
|
on btn_Left pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.MoveSelected [(offset as float *-1),0,0]
|
|
)
|
|
|
|
|
|
|
|
on btn_CustomUScale pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
customU = edt1.text AS float
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY customU 1 [centre_u.value, centre_v.value,0]
|
|
)
|
|
|
|
on btn_CustomVScale pressed do
|
|
(
|
|
Strct_UvNumeric.MyObject = selection[1]
|
|
Strct_UvNumeric.RSTA_CheckForUnwrap()
|
|
customV = edt2.text AS float
|
|
Strct_UvNumeric.MyObject.modifiers[#unwrap_uvw].unwrap2.ScaleSelectedXY 1 customV [centre_u.value, centre_v.value,0]
|
|
)
|
|
|
|
|
|
|
|
on edt3 entered text do
|
|
(
|
|
if edt3.text != "" do offset = edt3.text as float
|
|
)
|
|
)
|
|
|
|
--createDialog rsta_UvNumeric 170 490
|
|
|
|
-- createdialog rsta_UvNumeric style:#(#style_titlebar, #style_border, #style_sysmenu,#style_toolwindow)
|
|
|
|
try(destroyDialog tab_example)catch()
|
|
rollout tab_example "UvNumeric" width:180 height:655
|
|
(
|
|
-----------------------------------------------------------------
|
|
-- USER INTERFACE
|
|
-----------------------------------------------------------------
|
|
-- BANNER ------------------------------------------------
|
|
dotNetControl RsBannerPanel "Panel" pos:[0,0] height:32 width:tab_example.width
|
|
-- TAB CONTROL -----------------------------------------
|
|
dotNetControl dnTab "system.windows.forms.tabControl" width:180 height:35 offset:[-17,-2] align:#left
|
|
subRollout tab_subRollout width:190 offset:[-17,-2] height: 340
|
|
-- LOCALS --------------------------------------------------
|
|
local bannerStruct = makeRsBanner dn_Panel:RsBannerPanel versionNum:1.00 wiki:"tab_ui_example"
|
|
local tab_man = RSTA_ui_tabManager dn_Panel:dnTab mRollout:tab_example sRollout:tab_subRollout
|
|
-----------------------------------------------------------------
|
|
-- EVENTS
|
|
-----------------------------------------------------------------
|
|
-- CLICK THE TAB ------------------------------------
|
|
on dnTab Click do
|
|
(
|
|
tab_man.tabClick()
|
|
tab_example.height = 655
|
|
)
|
|
-- OPEN THE ROLLOUT ---------------------------
|
|
on tab_example open do
|
|
(
|
|
-- BANNER SET UP --------------------------
|
|
bannerStruct.setup()
|
|
-- TAB SET UP ----------------------------------
|
|
tab_man.addTab "Transforms" #(rsta_UvNumeric)
|
|
tab_man.addTab "Density" #(UvAutoRatio)
|
|
tab_man.addTab "Random" #(UvRandom)
|
|
tab_man.addTab "Misc" #(UvMisc)
|
|
tab_man.setup()
|
|
tab_man.extendToBottom()
|
|
|
|
dnTab.Multiline = true
|
|
)
|
|
-- WINDOW RESIZING ------------------------------
|
|
on tab_example resized arg do
|
|
(
|
|
-- EXTEND TAB TO BOTTOM ------------
|
|
tab_man.extendToBottom()
|
|
tab_example.width = 180
|
|
)
|
|
)
|
|
|
|
|
|
|
|
createdialog tab_example style:#(#style_titlebar, #style_sysmenu)
|
|
|
|
|