Does what its name says:
It matches the orientation of a face to any connected 'co-edged' faces.
It mimics SketchUp's "Orient Faces" Tool.
It can sometimes produce slightly different results when more than two
connected faces share a common edge. Its results are equally logical,
and who's to say how they should orient anyway ?
You can call it from other scripts thus: face.orient_faces
Feedback please...
EDIT:
v1.1 20090808 Algorithms improved - much faster.
v1.2 20120204 Checks of existing method!
[Code] orient_faces.rb v1.2
9 posts
• Page 1 of 1
[Code] orient_faces.rb v1.2Last edited by TIG on Sat Aug 08, 2009 10:55 am, edited 2 times in total.
TIG
Re: [Plugin] orient_faces.rb
Here's some timely feedback ![]() Hey, great script. Can I include it in a little plugin package for a game exporter (free, using other pre-made plugins that are all licensed to distribute freely). I just thought I'd ask though. And, I am having some issues where if does not quite reverse all faces. My test model is a very messy triangluated mound of faces, but it is a clean model. I've attached it if you want to play with it. I hope to comprehend how it works some day. It is completely different than my face.normal vector comparison approach (which was too mathematically intense for me right now). So if you don't mind sharing the trick to what its doing .... I'd be happy ![]() Thanks TIG! Chris Chris
Re: [Code] orient_faces.rbI have just updated the script to v1.1 viewtopic.php?p=15273#p15273 - which has slightly different algorithms and is much faster and more reliable... Please try it...
![]() Feel free to use the ideas in other scripts - an 'acknowledgement' would be nice... ![]() Basically it takes the face (self) and makes an array of 'all_connected' faces. It then makes other arrays of 'awaiting', 'processed' and 'done' faces. Some are initially empty, whilst others =[self] It then goes through those faces 'awaiting'. It has a subfunc 'flip_face' which compares if a face is 'reversed in the edge' with that of a neighbor-face - if match it reverses the neighbor-face; and moves faces between arrays. Then that face is 'done' and no longer 'awaiting'. It moves faces between the various arrays to reduce the lists to be processed or so as not to reprocess a face that's been already 'done'. It looks at the next face that's 'processed' but not 'done' etc etc. 'Done' faces are removed from the 'awaiting' array until it's empty - when it's done... Clear as mud... ![]() TIG
Re: [Code] orient_faces.rbAwesome TIG!, it now works much more reliably and much faster, as advertised!
And I will definitely give acknowledgements for your script ![]() ![]() Chris
Re: [Code] orient_faces.rbThe 'reversed_in' function looks to see if a face's edge direction is equal to its normal. Like drawing edges clockwise and anticlockwise give different face normals. If both of an edge's faces have equal "reversed-ness" [doesn't matter whether they are 'reversed_in' the edge or not - it's their equality that we test for...] then one of the faces is reversed in it's normal compared to the other... since we know that the first face we have is already the way round we want it to be, we reverse! the second one... The algorithm takes face1 that we are orient-matching and finds all of its connected_faces and also its immediate_neighbor_faces and it reverses those if needed, then it finds those neighbor_faces' neighbor_faces and so on... until all of the connected_faces are oriented to match face1.
TIG
Re: [Code] orient_faces.rbThats great TIG, I had no idea what the reversed_in method was for. I was trying to figure that all out using face.normal, angle_between, linear_combination, on and on. It was not working out.
But reversed_in, I like how that works. Thanks for having put this together and thanks for the update on it, it will be most useful in cleaning up models for game export! Chris
Re: [Code] orient_faces.rb
This script is going my API doghouse list. ![]()
Re: [Code] orient_faces.rbThanks for pointing this out...
In may defense, it was written a long time ago "before I 'saw the light'" [> 4 years!] ... I'd all but forgotten about it; when I do use the basis of this code's ideas I have cannibalized bits of it into new methods anyway... At the moment there isn't a native face.orient or face.orient_faces method [or anyone else's that I know of]... so we are safe ! ![]() BUT it was easy enough to add the simple existing-method check... I've now adjusted the code in v1.2, so it only adds to the base class IF the method face.orient_faces doesn't already exist. Again any developer's can use the 'code' ideas in any way they see fit... See here viewtopic.php?p=15273#p15273 for v1.2... TIG
Re: [Code] orient_faces.rb
There should be warning, in the OP, and probably the file header doc. ![]()
I knew you'd fix it promptly. ![]()
Couldn't resist teasing. ![]() I still believe that adding methods like this, belong in a community project, like SKX. (I still have hopes of reviving that project, or starting a similar one.)
I really do not have a "script dog house" list. (Have thought of doing one though.) ![]()
9 posts
• Page 1 of 1
|
Who is online
Users browsing this forum: No registered users and 16 guests