[Closed] Any way to reindex EPoly verts?
I need to take existing epoly meshes and reindex their vertex indices sequentially based on world space position (ie, bottom to top, back to front, etc.)
My first instinct is that I’m going to have to rebuild the mesh and it’s mapping a vert at a time, but I wanted to see if anyone had an easier way to go about it.
Thanks.
That’d be my first instinct too, kdaug. If there exists a way to re-number vertices, I don’t know of it without reconstructing the entire mesh.
-------------------------------
-------------------------------
-- --
-- Recreate Object Numbers --
-- --
-------------------------------
-------------------------------
if RecreateDialog != undefined then destroyDialog RecreateDialog
--Dialog:------------------------------------------------------------------------
rollout RecreateDialog " Recreate Object Numbers v0.1" width:300 height:108
(
-----------------------------------------------------------------------------
/* Locals */
-----------------------------------------------------------------------------
Local x
-----------------------------------------------------------------------------
GroupBox grpProp "Progress: " pos:[4,4] width:292 height:100
button btnDestroy "Destroy" pos:[12,76] width:72 height:20
button btnCompile "Compile" pos:[216,76] width:72 height:20
progressBar pbProgb "ProgressBar" pos:[12,32] width:276 height:24
-----------------------------------------------------------------------------
/* Functions */
-----------------------------------------------------------------------------
fn destroyObject =
(
local start = timeStamp()
sel = (selection as array)
if sel[1] == undefined do return false
if (classOf sel[1].baseObject != Editable_Poly and classOf sel[1].baseObject != Editable_Mesh) do return false
local fcount = sel[1].faces.count
local theRest = copy fcount
for i=fcount to 1 by-1 do
(
local theName = uniqueName "renumber"
polyOp.detachFaces sel[1] i asNode:true name:theName
--sleep 0.3
execute ("$" + theName + ".wirecolor =(random white black)")
redrawViews()
--Progress Bar
theRest-=1
pbProgb.color = red
pbProgb.value = 100-(100.*theRest/fcount)
grpProp.text= "Progress: " + (pbProgb.value as string) + "%"
)
delete sel[1]
grpProp.text = "Finished: 100%"
pbProgb.value = 0
local end = timeStamp()
format "Processing took % seconds
" ((end - start) / 1000.0)
)
fn attachInGrow =
(
local start = timeStamp()
sel = (selection as array)
if sel[1] == undefined do return false
if (classOf sel[1].baseObject != Editable_Poly and classOf sel[1].baseObject != Editable_Mesh) do return false
for o in sel do (o.pivot = ((o.max + o.min)/2))
local dist = 1
local selCount = sel.count
local theRest = copy selCount
local theObj = sel[1]
while theRest > 1 do
(
for f=theRest to 2 by -1 where (distance theObj sel[f]) < dist do
(
polyOp.attach theObj sel[f]
deleteItem sel f
--sleep 0.3
redrawViews()
--Progress Bar
theRest-=1
pbProgb.color = green
pbProgb.value = 100-(100.*theRest/selCount)
grpProp.text= "Progress: " + (pbProgb.value as string) + "%"
)
dist+=1
)
grpProp.text = "Finished: 100%"
pbProgb.value = 100
local end = timeStamp()
format "Processing took % seconds
" ((end - start) / 1000.0)
)
-----------------------------------------------------------------------------
/* DialogProp */
-----------------------------------------------------------------------------
--ON OPEN
on RecreateDialog open do
(
)
--ON Close
on RecreateDialog close do
(
)
--ON RMB
on RecreateDialog rbuttonup pos do
(
DestroyDialog RecreateDialog
)
-----------------------------------------------------------------------------
/* Actions */
-----------------------------------------------------------------------------
on btnDestroy pressed do undo "destroy" on ( destroyObject() )
on btnCompile pressed do undo "compile" on( attachInGrow() )
)
---------------------------------------------------------------------------------
CreateDialog RecreateDialog style:#(#style_titlebar)
---------------------------------------------------------------------------------
--**\ Created by Merlin el' 7/10/2006 2:55:33 PM /**--
for speed up progress: turn off visualization (is mutch more faster)
Interesting… I hadn’t thought about just detaching the faces and re-attaching… it’d let Max handle the map verts internally, and although it wouldn’t be exact (verts at the top edge of a face would still get a lower index than the verts at the bottom of the next face attached), it may well be close enough for what I need.
I’ll give it a shot. Thanks, MerlinEl!
-K