# 3ds and face cw/ccw

This topic is 4092 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

hi how do I learn whether the vertices in a face in a 3ds file are in CW or CCW order? I know there's a faceflag for each flag, but don't think that's what I'm looking for (I enable back face culling to see whether the object is CW or CCW, but they all have the flag set to 7 (decimal). Any idea where to look? (I'm looking at lib3ds now, but haven't found it yet)

##### Share on other sites
Unless you specifically tell 3DS to reverse the facing of a tile (flip the normal)then they will all be the same direction, and so for the entire mesh you can decide if you need to cull the back or front (usually the back). Lib3ds will load them in the same way they are saved out from 3DS, so it will preserve the direction too.

If needs be, then there is a way of telling if a triangle is cw or ccw. Something to do with computing the area of the triangle I think, but I can't remember off hand.

##### Share on other sites
Quote:
 Original post by DamoclesIf needs be, then there is a way of telling if a triangle is cw or ccw. Something to do with computing the area of the triangle I think, but I can't remember off hand.

This is from the top of my head:
// A, B, C are the three triangle vertex positions in 3D space// N is the (normalized) face normal// If s < 0 then CCW, if s > 0 then CW (or the other way round, depends on your coordsys// If s == 0 then the face is degeneratedfloat s = dot(N, cross(A, B) + cross(B, C) + cross(C, A));

##### Share on other sites
Oh, I see. The problem is I'm loading files I've downloaded from the internet and some have the vertex order messed up (CW instead of CCW) (I compute the normals myself instead of loading them). Also, I believe that while you can tell whether the face is CW or CCW, it depends on the actual point of view and thereby you'd need to know whether a certain tri should be facing you or not when you're standing at some specific point in space. Or did I get it totally wrong?

##### Share on other sites
Only now that I read Yann L's post I get it. I need to compare the loaded normal with the one I compute and see if they're the same or not and depending on that, rearrange the vertices to go CW/CCW (the way I want them)

thanks guys

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 32
• 41
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631743
• Total Posts
3001990
×