PDA

View Full Version : 'remove (not quite) isolated verticies'


thom:f
06-01-2003, 10:17 AM
After removing edges on an editable Poly - removing a whole load of edge loops for example - you're still left with the verticies where the edges used to be.

Is there an easy way to remove all these verticies without doing it all manually (i.e. when you have LOTS)?

Ideas? thanks..

mouj
06-01-2003, 10:49 AM
Howdy !

When you have your edgeloops selected, before removing them, convert your selection to vertices, and then switch back to edge, this way after removing the edges, you can just go to vertices subobject level, and remove the extra vertices still selected.

mouj

thom:f
06-01-2003, 11:28 AM
thanks, i did actually think of that work around.. i guess i was just dreaming for a 'Remove useless verts' tool... But i guess you find that in that same toolbar as 'make my model look awesome' and 'extend deadline here'.

Thanks tho. :)

Thom.

googlo
06-01-2003, 02:58 PM
Hey, I was thinking about writing a script for this but never got around to it until your post motivated me to do so.

open a new maxscript editor window (Maxscript->New Script), copy the below contents into it and hit ctrl-e to run it or select 'Evaluate All' from the file menu drop down in the maxscript editor window.

You can also highlight it all from within the editor window and then right click and drag the contents onto a blank spot on a toolbar to make it into a macroscript.

You can give the macroscript a label by right clicking on it and selecting the 'edit button appearence' option, and then selecting the text option and typing in whatever label you want for it in the text field.

Make sure you copy and past the whole thing, don't miss the paranthesis at the top and bottom :).

(
fn dotAngle v1 v2 = ( acos (dot v1 v2)/(length v1)*(length v2) )

bit32=(bit.set 0 32 true)
getEdgesUsingVert=polyOp.getEdgesUsingVert
getVertsUsingEdge=polyOp.getVertsUsingEdge
getVertPosition=polyOp.getVert

allverts=(for i=1 to $.numverts collect i) as bitarray

suspectVerts=for i in allverts collect ( if ((getEdgesUsingVert $ i) as array).count==2 then i else dontCollect)

vertsToRemove=for i in suspectVerts collect (
testEdges=getEdgesUsingVert $ i
testVerts=(getVertsUsingEdge $ testEdges)-(#{i})
testVerts=testVerts as array

v1=((getVertPosition $ testVerts[1])-(getVertPosition $ i))
v2=((getVertPosition $ testVerts[2])-(getVertPosition $ i))
if (dotAngle v1 v2)==180.0 then i else dontCollect
)


polyOp.setVertFlags $ vertsToRemove bit32 mask:bit32
$.remove selLevel:#Vertex flag:bit32
)

Stroker
06-01-2003, 03:25 PM
What's wrong with using `Remove Isolated Vertices'?

As far as I know, it's available in sub-vert mode for EMesh and EPoly.

Or am I missing something?

googlo
06-01-2003, 04:04 PM
thom, can you let me know if any bugs or errors are encounterd?

stroker,
Isolated vertices are different. Isolated vertices are vertices that are in the mesh or poly that have no edges or faces/polygons associated with them. They are still part of the object but they just look like vertices out in space.

When you remove edges from a poly object, the vertices that made them are still there in the mesh, often not really contributing to the mesh in any meaningful way, like if say a vertice that is on an edge that would still be there and remain straight if that vertice was removed. So that vertice is just there, just being extraneous.

See in the picture?

Stroker
06-01-2003, 04:14 PM
Wow, I really was missing something.
I thought he was deleting edges - not removing.
Thanks for clarifying, googlo.

googlo
06-01-2003, 04:26 PM
np.

Bobo
06-01-2003, 05:54 PM
Originally posted by thom:f
thanks, i did actually think of that work around.. i guess i was just dreaming for a 'Remove useless verts' tool... But i guess you find that in that same toolbar as 'make my model look awesome' and 'extend deadline here'.

Thanks tho. :)

Thom.


Add a "Turn To Poly" modifier.
By default, it has a checkbox checked saying "Remove Mid-Edge Vertices"-

It does the trick...

LFShade
06-01-2003, 07:59 PM
Thanks for the tip, Bobo, but it's easier just to do it all with a keystroke. IIRC, csPolyTools' "dissolve" tool automatically cleaned up the leftover verts. I have a modified version that works without Meshtools in Max5.x, which is what I use for killing off edge loops:)


RH

thom:f
06-01-2003, 08:46 PM
wow, nice one on the code googlo. I tried it and it works, fair play!!.. so after wishing for my magic button it magically appears for me. Cheers Dude!!

Thats pretty magic. Although, it does miss a few though! I think it might be the ones that perhaps dont have exactly the 180º angle if im reading the code right.. but i really dont know much in this area at all. I tried an variant to see if it might clean up the remainder:


(
fn dotAngle v1 v2 = ( acos (dot v1 v2)/(length v1)*(length v2) )

bit32=(bit.set 0 32 true)
getEdgesUsingVert=polyOp.getEdgesUsingVert
getVertsUsingEdge=polyOp.getVertsUsingEdge
getVertPosition=polyOp.getVert

allverts=(for i=1 to $.numverts collect i) as bitarray

suspectVerts=for i in allverts collect ( if ((getEdgesUsingVert $ i) as array).count==2 then i else dontCollect)

vertsToRemove=for i in suspectVerts collect (
testEdges=getEdgesUsingVert $ i
testVerts=(getVertsUsingEdge $ testEdges)-(#{i})
testVerts=testVerts as array

v1=((getVertPosition $ testVerts[1])-(getVertPosition $ i))
v2=((getVertPosition $ testVerts[2])-(getVertPosition $ i))
if (dotAngle v1 v2)>170 and if (dotAngle v1 v2)<190.0 then i else i -- dontCollect
-- if (dotAngle v1 v2)==180.0 then i else dontCollect
)

polyOp.setVertFlags $ vertsToRemove bit32 mask:bit32
$.remove selLevel:#Vertex flag:bit32
)


but it just cleans the same verticies (misses about 5-10%). In fact its possible to REM out that entire line and it performs the same? In fact, when you run the script a second time, it removes a few more that were neighbours to the verts just removed (as the verts condition has now changed)..

Any ideas on this or have i totally got the wrong idea here.. does it miss some verts (i) in the first place? Just a thought.

What about making that 'Make-My-Model-Look-Better-Than-My-Mates' button? please.

:) thom.

googlo
06-01-2003, 09:54 PM
Thanks. Yeah I thought the only extra verts someone would get rid of are the ones that lie on a straight line between two other vertices with no other edges connecting them. Can you show me a picture of verts that don't fit this criteria but are still considered extraneous?

Oh I see what you did now to the code. You put a range in there. Doesn't that remove verts that are necessary though? I thought even if a vert only has a two edges in it but the angle between those edges is anything but 180, then it's not considered extraneous anymore because it's actually contributing to the shape of a polygon?

thom:f
06-04-2003, 12:55 AM
yeah i see what you mean.. the range however seems to do exactly the same thing.?. .. not that i understand why exatly.. (ill leave that up to you!!). In fact, removing the line out still does exactly the same thing? Or im going nuts. ..say 50/50..

Say on a curved surface, when removing an edgeloop, the remainding verts will not be at 180 exactly, but will still only have two edges coming from each vert. You would loose the curve shape a bit of course but i guess your trying to do that to keep the poly count down (where meshsmooth will fill it back in hopefully to what you're after).

I'd show a picture but im on a duff laptop at my mates house, sorry. (and sorry mate).

Top magic button though.. ;) solve the niggles and could find itself well placed next to 'remove isolated verticies'. I've found mouj's idea good too if you keep systematic, a few well placed keyboard shortcuts (like alt-1 for convert to vertx where 1 is selet vertex, alt-2 for convert to edge etc.) well useful.

Thom. :)

xynaria
06-04-2003, 05:49 AM
There actually is an 'erase edgeloop' script (on scriptspot I think) that erases the loop and cleans up the vertices afterwards.. works well for that....though it doesn't like open eges very much. :)

CGTalk Moderation
01-15-2006, 07:00 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.