sanni
September 21st, 2011, 01:59 PM
Hi,
If you have a look at image (1+2) you can see the problem.
http://img7.imagebanana.com/img/e9xvm691/thumb/Unbenannt.PNG (http://img7.imagebanana.com/img/e9xvm691/Unbenannt.PNG)
The vertex that connects the blue, black and green faces intersects the edge of the red face. Tool doesn't like that "special" kind of vertex. :ugh:
To fix that you can either weld the "special" vertex with another one like in image (3) or split the red face into 3 that that all share our special vertex. :woop:
But here comes the twist, what if you have hundreds of such "special" vertices? As an example if you import geometry from other games like Goldeneye 64 this happens alot.
Is there any automated variant to manually fixing all the vertices? Like a max script or so?
Here is another prime example of the problem:
2376
I have found this script that with a few alteration could work, problem is I don't understand maxscript good enough:
How do I remove mid-edge EPoly Vertices?
MAXScript Frequently Asked Questions (http://www.cgplusplus.com/online-reference/maxscript-reference/source/frequently_asked_questions.htm)
A user asked:
I want to filter the edge selection and create arrays containing connected edges, something like "edge selection elements". Edges from two arrays will never be connected, in other words will not share vertices.
Answer:
The following code implements a possible solution:
Script:
macroScript KillMidEdgeVerts category:"MXS Help"
(
--make sure a single EPoly object is selected
on isEnabled return selection.count == 1 and classof selection[1].baseobject == Editable_Poly
on execute do
(
thePoly = selection[1] --get the selected object
select thePoly --select it
max modify mode --switch to modify panel
--set the base object as current level:
modPanel.setCurrentObject selection[1].baseobject
subObjectLevel = 1 --set sub-*object level to vertex level
numVerts = (polyop.getNumVerts thePoly) --get the total vertex count
undo on "KillMidEdgeVerts" --enable undo context
(
--loop backwards from the last to the first vertex
for v = numVerts to 1 by -1 do
(
--get the edges using the vertex to check the count
nVerts = (polyop.getEdgesUsingVert thePoly v) as array
if nVerts.count == 2 do --if only two edges found, then
(
--get the verts of the first egde
edge1verts = (polyop.getVertsUsingEdge thePoly nVerts[1]) as array
--calculate the vector defined by the two vertices in the first edge
vector1 = (polyop.getVert thePoly edge1verts[1]) - (polyop.getVert thePoly edge1verts[2])
--get the verts of the second edge
edge2verts = (polyop.getVertsUsingEdge thePoly nVerts[2] as array)
--calculate the vector defined by the two vertices in the second edge
vector2 = (polyop.getVert thePoly edge2verts[1]) - (polyop.getVert thePoly edge2verts[2])
--calculate the angle between the two normalized vectors
angle = acos (dot (normalize vector1) (normalize vector2))
--if the angle is less than the threashold (change 0.01 to whatever threashold you want!)
if angle < 0.01 do
(
select thePoly.verts[v] --then select the current vertex
thePoly.EditablePoly.buttonOp #Remove --and hit the remove button
)
)--end if
)--end v loop
)--end undo
)--end on
)--end macro
Thank you very much :iamafag:
If you have a look at image (1+2) you can see the problem.
http://img7.imagebanana.com/img/e9xvm691/thumb/Unbenannt.PNG (http://img7.imagebanana.com/img/e9xvm691/Unbenannt.PNG)
The vertex that connects the blue, black and green faces intersects the edge of the red face. Tool doesn't like that "special" kind of vertex. :ugh:
To fix that you can either weld the "special" vertex with another one like in image (3) or split the red face into 3 that that all share our special vertex. :woop:
But here comes the twist, what if you have hundreds of such "special" vertices? As an example if you import geometry from other games like Goldeneye 64 this happens alot.
Is there any automated variant to manually fixing all the vertices? Like a max script or so?
Here is another prime example of the problem:
2376
I have found this script that with a few alteration could work, problem is I don't understand maxscript good enough:
How do I remove mid-edge EPoly Vertices?
MAXScript Frequently Asked Questions (http://www.cgplusplus.com/online-reference/maxscript-reference/source/frequently_asked_questions.htm)
A user asked:
I want to filter the edge selection and create arrays containing connected edges, something like "edge selection elements". Edges from two arrays will never be connected, in other words will not share vertices.
Answer:
The following code implements a possible solution:
Script:
macroScript KillMidEdgeVerts category:"MXS Help"
(
--make sure a single EPoly object is selected
on isEnabled return selection.count == 1 and classof selection[1].baseobject == Editable_Poly
on execute do
(
thePoly = selection[1] --get the selected object
select thePoly --select it
max modify mode --switch to modify panel
--set the base object as current level:
modPanel.setCurrentObject selection[1].baseobject
subObjectLevel = 1 --set sub-*object level to vertex level
numVerts = (polyop.getNumVerts thePoly) --get the total vertex count
undo on "KillMidEdgeVerts" --enable undo context
(
--loop backwards from the last to the first vertex
for v = numVerts to 1 by -1 do
(
--get the edges using the vertex to check the count
nVerts = (polyop.getEdgesUsingVert thePoly v) as array
if nVerts.count == 2 do --if only two edges found, then
(
--get the verts of the first egde
edge1verts = (polyop.getVertsUsingEdge thePoly nVerts[1]) as array
--calculate the vector defined by the two vertices in the first edge
vector1 = (polyop.getVert thePoly edge1verts[1]) - (polyop.getVert thePoly edge1verts[2])
--get the verts of the second edge
edge2verts = (polyop.getVertsUsingEdge thePoly nVerts[2] as array)
--calculate the vector defined by the two vertices in the second edge
vector2 = (polyop.getVert thePoly edge2verts[1]) - (polyop.getVert thePoly edge2verts[2])
--calculate the angle between the two normalized vectors
angle = acos (dot (normalize vector1) (normalize vector2))
--if the angle is less than the threashold (change 0.01 to whatever threashold you want!)
if angle < 0.01 do
(
select thePoly.verts[v] --then select the current vertex
thePoly.EditablePoly.buttonOp #Remove --and hit the remove button
)
)--end if
)--end v loop
)--end undo
)--end on
)--end macro
Thank you very much :iamafag: