[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: .obj question

Erik wrote:
> Hi, sorry to pollute the list with this stupid question :)
> is there any convention for differentiating between frontface and backface in
> wavefronts .obj model format if normals aren't provided? (I have a couple
> models with only vert lists and face lists, and my viewer is drawing half the
> polygons with the wrong face). All the pertinant links I could find were either
> dead or didn't go into detail :/ Any help would be greatly appreciated, thanks
> :)

I have heard (although I have no personal experience with .obj) that this
is indeed a *fatal* problem with the format.  There is no clockwise/anticlockwise
ordering convention - and also no normals.  The renderer this format was
intended to drive was a non-realtime raytracer kind of a thing - and
backface culling was not an important feature.

There was a long debate about ways to possibly work around this on the
OPENGL-GAMEDEV list maybe a year ago.

There were various hare-brained schemes for presuming (or being told)
that the 'object' you are loading is either a predominantly convex
'solid' thing (like a house-brick or a Thaaarg-Warrior) - or a predominantly
concave 'hollow' thing like the inside of a room.

Armed with that prior information, the tool would walk around the connected
polygons, and figure out what is 'inside' and what is 'outside'.  You can
pick one polygon, and choose which direction it faces arbitarily.  Now, you
look at each edge in turn, find a polygon that shares that edge and if
necessary, flip it to point the way as the first one. Applying that algorithm
everywhere produces an object that is either 100% correct - or 100% inside-out.
It's a relatively simple matter to figure out which is which by counting the
number of edges that are convex edges and the number that are concave - and
ensuring that the majority of them are facing correctly.

Of course this fails completely if the object is not fully connected - or
if it has single disconnected polygons and stuff like that.


I think the short answer is "don't do that".

Steve Baker                  http://web2.airmail.net/sjbaker1
sjbaker1@airmail.net (home)  http://www.woodsoup.org/~sbaker
sjbaker@hti.com      (work)