PDA

View Full Version : Display Open Edges


bcavett
11-01-2006, 01:51 AM
Id like a script that displays open edges all the time when Im modeling. I have come up with a script but its incredibly slow and is not always correct if the object's xform is not reset. How would I get this to run faster? How would I get it to loop through all my objects? Or should I just have it work on only one at a time? I'm also at a loss on how to get it to work if there are modifiers on top. I'd really like to know what direction to go in for making faster. Thanks for any help.

(
fn displayOpenEdges =
(
OpenEdges=polyop.getopenedges $ as array
gw.setTransform(Matrix3 1)
gw.setcolor #line (color 2 228 240)
for i in 1 to OpenEdges.count do
(
PolyLinePos=#() -- clear array for every vertex pair
EdgeVerts=polyop.getvertsusingedge $ OpenEdges[i] as array
for v in 1 to EdgeVerts.count do
(
VertPos = (polyop.getvert $.baseobject EdgeVerts[v]) * $.transform
append PolyLinePos VertPos
print vertpos
)
gw.polyline PolyLinePos false -- make each set of verts it's own polyline
)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
registerRedrawViewsCallback displayOpenEdges
)

Light
11-01-2006, 01:59 AM
Hi,

In order to make something visible all the time, you need to use redrawViews callbacks which tend to be slow because of being updated with each redraw. However in this example, you can get more performance by removing the print line.




Light

bcavett
11-01-2006, 02:30 AM
ahh yea... the print line was there just for me to see the coordinates it was printing out. I dont know if Im getting the worldspace coords right. It only works if the xforms are rest.

So is there not another way of doing it besides the way I have it now?

How does the wireframe overlay work? Why is it so fast? Im mainly just using this to understand these methods better.

edit: I'd also like to cull out the edges when they are behind geometry.

Light
11-01-2006, 02:52 AM
You can get the backfaces for culling purposes using a fn like this:

fn getBackFaces = for i = 1 to polyOp.getNumFaces selection[1].baseObject where (in coordsys (inverse (viewport.getTM())) polyOp.getFaceNormal selection[1] i).z < 0 collect i


As for the wireframe overlay, they use different methods, whereas redrawViews callbacks just implements an interface to let you display stuff on top of this.

If you want to see another comparison, check out the show statistics command in max 9, which doesn't flicker, unlike the default poly counter script.




Light

CGTalk Moderation
11-01-2006, 02:53 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.