[Closed] Convert UVW code to meshOp.setMapVert, meshop.setMapFace
I have made a script that is working now very well – It applies a certain type of UVW map to every element of an editable poly. But If the object is big (has many elements) then the script is taking to long to apply an UVW map to every element and to collapse.
Please help to convert the code from using UVW map modifier to smth like meshOp.setMapVert, meshop.setMapFace.
I have never used them and I don’t understand how it works from autodesk help.
at the moment I have
fn collectVertElements node = if iskindof node PolyMeshObject or iskindof node Editable_Poly do
(
getelement = polyop.getelementsusingface
elements = #()
faces = #{1..node.numfaces}
while not faces.isEmpty do
for f in faces while
(
ee = getelement node f
faces -= ee
append elements ee
off
)
do()
elements
)
fn polyVertsToMinmax poly verts ElDimension = if iskindof poly PolyMeshObject or iskindof poly Editable_Poly do
(
local bmin = [1e9,1e9,1e9], bmax = -[1e9,1e9,1e9]
getpolyvert = polyop.getvert
for v in verts do
(
p = getpolyvert poly v
for k=1 to 3 do
(
if p[k] < bmin[k] do bmin[k] = p[k]
if p[k] > bmax[k] do bmax[k] = p[k]
)
)
if ElDimension == yes then
--#([bmax.x-bmin.x,bmax.y-bmin.y,bmax.z-bmin.z], 6)
#(bmin,bmax)
else
minmax bmin:bmin bmax:bmax
)
ee = collectVertElements $
--print ee
BminBmax = for e in ee collect polyVertsToMinmax $ (polyop.getvertsusingface $ e) yes
--print bb
and here is a piece of code that I don’t understand how to convert to avoid collapsing:
if (node.modifiers.count > 0) and isKindOf (local temp_mod = node.modifiers[1]) Uvwmap then --(classof node.modifiers[1] == Uvwmap) then
for i = 1 to elements.count do
(
maxOps.CollapseNodeTo node 1 true -- collapse
node.selectedFaces = elements[i]
max modify mode
subObjectLevel = 5
local planeMap = Uvwmap()
planeMap.maptype = temp_mod.maptype
planeMap.length=temp_mod.length
planeMap.width=temp_mod.width
planeMap.height=temp_mod.height
planeMap.realWorldMapSize=temp_mod.realWorldMapSize
planeMap.mapChannel=temp_mod.mapChannel
planeMap.axis=temp_mod.axis
modPanel.addModToSelection planeMap
UVWa = #(0, 90, -90, 180)
rnd = random 1 4
UVWr = UVWa[rnd]
planeMap.gizmo.rotation = (angleaxis UVWr [0,0,1]) as quat
planeMap.gizmo.pos += [random -rangex rangex, random -rangey rangey, random -rangez rangez]
)
I thaught may be it is easier to use polyop.[i]applyUVWMap ???
I need to use for elements. Please help me understand the equivalents for
[/i] maptype planeMap.length planeMap.width planeMap.height planeMap.realWorldMapSize planeMap.mapChannel planeMap.axis
planeMap.gizmo.rotation planeMap.gizmo.pos