LDraw.org Discussion Forums

Full Version: BFCing
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Does anyone of you have an executable of WINDZ available to give me?
It seems to not be downloadable anywhere anymore.
I've been BFCing parts in the past some time, always using the "manual method", i.e.,
looking at the part in LDView, identifying the wrongly oriented faces, coloring them in MLCad,
then changing their winding in LDDP, or inserting INVERTNEXT's.
When I look at parts in red/green BFC checking mode in LDView, I always thought
that the BFCing process - to a certain extent - should be easily automatable;
I think that's what WINDZ also does:
just render the part from various perspectives, and flip all faces that appear "red" during that.
Of course, if a surface gets flipped twice this way, it cannot automatically be oriented correctly,
and manual post-correction is needed. However, for a majority of parts, the described
method should trivially work like a breeze.
Does anyone of you know of software which does that?
I want to speedup my BFCing processing...
Having such a software would allow us to instantly BFC big amounts of our library,
and reduce the remaining manual work to the parts which really require attention.
My best preference would be a tool like edger, command line based,
and simply taking an input file, outputting a result file where all faces are oriented correctly,
and the file otherwise unchanged. Undecidable surfaces should be colored in a user-selected color,
so they can be taken care of manually.
Check your email.
Windz is also included in latest LETGUI package.
It works fairly well on closed volume, but has trouble with open stuff (eg. subparts). Another quirck is that it inserts an invertnext in front of flat primitives instead of flipping them.
Thanks Orion, will try it.
Philo, the 2 problems you mentioned appear easily fixable to me.
Flipping primitives instead of inserting INVERTNEXT should be trivial.
And regarding the open surfaces, this can be cured as well: the tool should simply detect
if a surface is visible from 2 sides, and if yes, colorize it specially and keeps fingers of that,
since it cannot know in which orientation it is desired.
Sad that the tools seems to be no longer actively developed, applying these 2 fixes seems
nearly trivial to me.
I will use this message to collect the bugs I further discover in the tool.

Bug #1:
On Win7 64bit, crashes immediately when invoked with empty command line:
Code:
Problem Event Name:    APPCRASH
  Application Name:    windz.exe
  Application Version:    0.0.0.0
  Application Timestamp:    3d81e30a
  Fault Module Name:    windz.exe
  Fault Module Version:    0.0.0.0
  Fault Module Timestamp:    3d81e30a
  Exception Code:    c0000005
  Exception Offset:    0000162d
  OS Version:    6.1.7601.2.1.0.256.1
  Locale ID:    1031
  Additional Information 1:    aefb
  Additional Information 2:    aefbda89c057c86b72e54293b84f7f43
  Additional Information 3:    a82d
  Additional Information 4:    a82d76f570636604c9c9bb7b313890f2
When invoked with file as parameter, does not crash.
the result is unsatisfying.

the strange thing here is that the tool works correctly on one side of the part,
but on its other side, which is completely symmetric, does not work correctly.
This lets me suspect that there is a +/-1 multiplication error somewhere in its internal matrix formulae,
which lets it work correctly in some quadrant of the coordinate system, but not in another.
The problem with 3229b.dat is that it contains two concave quads, and it seems this bothers Windz... Correct them first, and windz will do it's thing fine!
I have a few questions concerning BFC.
First of all: What does BFC stand for?
Does the orientation concern the part only or the pattern also? Since I'm just doing patterns I don't know if I have to do anything. I looked at the part in LDView in BFC Mode but I don't have a clue what I'm looking at. Could someone enlighten me, please?
BFC means Back Face Culling. See the related LDraw specification, and Wikipedia defintion.
The best way to have a feel for it is to look at a part LDView in BFC Mode (use BFC red back face / green front face option). If you see red, it means you see the facet from the wrong side. Have a look to a subpart (they are generally not closed so you may look "from inside")...
For your pattern, LPC does the work for you... you just have to change the "0 BFC NOCERTIFY" to "0 BFC CERTIFY CCW"
Philippe \Philo\" Hurbain Wrote:For your pattern, LPC does the work for you... you just have to change the "0 BFC NOCERTIFY" to "0 BFC CERTIFY CCW"

Thank you, Philo. Do I just have to change it in File -> Metadata, or somewhere else, too?
I generally do that sort of modification using a text editor! Mainly LDraw Design Pad that has LDraw syntax highlighting, inlining possibilities, etc...

You may also change BFC statement in MLCad (double click on statement line), or use DatHeader. I highly recommend the use of Datheader anyway before submitting to parts tracker, this tool does a lot validity checks on your file.
Wouldn't it be possible to implement more of DatHeader's functions in the Submit function of the tracker?
Not directly the same code (because I believe DATheader needs the .NET framework), but running the header checks would be possible. In fact, I do run a Perl header checker against all the certified files prior to releasing a Parts Update. That's why you'll often see a bunch of Admin Edits immediately prior to the update, as I find things that have been missed by manual review.

I was initially reluctant to implement that in the Submit process for fear that authors would just get frustrated with trying to meet the needs of the then "new" header format, and we would lose files or even authors.

Maybe the format has had sufficient time to gain acceptance that it would be OK to implement it now.
I think it would be great to have. If I was told my header was wrong when I tried to submit I'd fix it immediately. Thus saving work for all reviewers.

Tim
I tried to BFC this part. Did I do it right? I used a lot of "BFC INVERTNEXT" since "reverse winding" didn't work on the primitives. That was all I could do with my limited knowledge.
Nearly. Your solution is correct in the way that all faces are correctly oriented now.
One can check that by looking at the part in LDView, with BFC checking mode enabled.
To do that, you can put a "BFC" button into the toolbar (using LDView's toolbar customization).

However, your solution solves the problem in an inefficient way, it can be done better:
Relax: BFCing is nothing else than orienting every surface in the file "properly",
such that its "front" points "outside", and its "back" points "inside" the part.

Quads can be re-oriented by reordering their points reversly:
This will make inside outside and vice versa. LDDP has a button for this, it is the one with the red/green color flipping.
That button simply takes a quad and reverses its order of points.

Your misunderstanding is regarding primitives. There, you currently wrote:
0 BFC INVERTNEXT
1 16 2 4 -2 0 1 0 -1.75 0 0 0 0 -1.75 1-4ring7.dat
Let's look at this in more detail, i.e., look at the matrix.
Without the BFC instruction, your ring primitive lies in the Y/Z plane, as you for example can see
directly from the matrix with some experience, or in MLCad when looking at it.
When looking at the ring in LDView with BFC checking enabled, you'll notice that it is simply
pointing "in the wrong X direction": when looking at it in X direction, you see its backside (in red).
Instead of now inverting the whole primitive by an extra BFC INVERTNEXT statement, you can simply
mirror the primitive at the Y/Z-plane, making it pointing "the other direction on the X axis".
This is easily achieved by flipping the sign of the X scaling: change
1 16 2 4 -2 0 1 0 -1.75 0 0 0 0 -1.75 1-4ring7.dat
to
1 16 2 4 -2 0 -1 0 -1.75 0 0 0 0 -1.75 1-4ring7.dat
, and voila, the primitive now is mirrored, and this means that its front now correctly points to the viewer.

This technique can generally be applied for all flat primitives, where the mirroring at the axis in which they are "flat"
will not warp their geometry.
(Sadly, BTW, tool WINDZ does not do that. It inserts all these BFC INVERTNEXT statements always.)

For non-flat primitives, like e.g. cylinders, things are a little different, and this mirroring technique cannot be applied,
as the mirroring will yield a completely different appearance in the part file which uses the primitive.
For these, the
0 BFC INVERTNEXT
statement cannot be avoided and must be used.

I hope this helps you a little. Once you've gotten more used to BFCing, it will become very, very simple to you.
Just the start is confusing. Don't let this frustrate you.
Always think simple of this. In the mathematical sense, each surface has an orientation, i.e., a "front" and a "back",
and this can be used for performance optimization when rendering such a part, because a surface which points
to the viewer with its "back" side will always be on an invisible "rear" side of a part, and can be left out from rendering
completely. Only the surfaces which show their "front" to the viewer need to be rendered. For the high number
of polygons our parts have, this effect can significantly speed up painting.
BFCing means nothing else than properly orienting all the surfaces of a part this way.
Wait... there's a tool for that?!? I changed the quads and triangles all manually in LDDP.

I already knew BFC in LDView, but thank you anyway. I was just curious about the BFC INVERTNEXT.
I'll have another look at it tomorrow.
Excellent summary!
BTW, maybe this forum is missing a "tutorial" section where this kind of discussions could be placed for reference in the future?

Quote:This will make inside outside and vice versa. LDDP has a button for this, it is the one with the red/green color flipping.
...and there is a keyboard shortcut too, Ctrl+W.
Quote:Sadly, BTW, tool WINDZ does not do that. It inserts all these BFC INVERTNEXT statements always
Windz does have several shortcomings,eg. it doesn't behave very well on open parts that have no clear inside/outside (eg. subparts), but it's often a big time saver. Windz is included in LETGUI distribution.
Despite its shortcomings, I would like to see it included in the AIOI as well - dunno if it's in there already.
At some point in the future, we might have an improved version.
As it is a very specialized tool to be used only by a handful of people, I don't see the need to put it in AIOI...
ah, sorry, yes, I forgot:
your tools aren't included there as well.
the AIOI doesn't aim at part authors.
that's fine for me. different part authors need/prefer different tools probably.
Erased BFC Invertnext where possible and sent the part to PTAdmin. There are still a lot of flaws which are beyond my knowledge to correct, but at least it's BFCd now. ;-)
(2012-03-13, 10:36)Daniel Goerner Wrote: [ -> ]I have a few questions concerning BFC.
First of all: What does BFC stand for?

A wiki page about BFC now has been added:
https://wiki.ldraw.org/wiki/BFC