Bug/mirrored instances

Correct the exported vertex order (winding) for flipped instances. 
Hi Thomas,

Slightly related question on sketchup's polygon mesh and reversing sketchup faces.
from testing I now understand the behavior. However, I must say a was quite puzzled when I found out that reversing the sketchup face actually kept the polygon indices untouched while it did change the returned underlaying points. 

I have a use case were I need make set of manifold faces 'orientable' (all mesh polygons of the connected faces in the same clock order).   However, I do not want to do this on the actual faces in sketchup, but on my own structures. 
therefor, I tried to understand and mimic the transformation (on reversing a face) that is done to the point order of the returned mesh.points
Since I couldn't find that one out, spooked me,  I now implemented my own mymesh.polygons.reverse! method, acting on the indices of the polygons in the mesh instead of the points. 

My question: what do you think would be a good solution to detect wether two connected faces are 'orientable'? 
I was thinking to look into both face's meshes, look for 2 connected polygon triangles and see if the endpoints of the shared edge are referenced in opposite order in both respective mesh polygon triangles.
Is there a simpler method you know of to do it?

Thanks,

Jeroen



Op 2-jul.-2014, om 11:45 heeft Thomas Thomassen <notifications@github.com> het volgende geschreven:

> In src/sketchup-stl/exporter.rb:
> 
> > @@ -208,6 +212,16 @@ def self.scale_factor(unit_key)
> >          factor
> >        end
> >  
> > +      def self.get_vertex_order(vertices, normal)
> > +        n = (vertices[1] - vertices[0]).cross( (vertices[2] - vertices[0]) )
> > +        n.normalize!
> > +        order = [0, 1, 2]
> > +        if n != normal
> > +          order = [0, 2, 1]
> Would perhaps order.reverse! read better? As when the normal is flipped the order need to be reversed. The way with the hard coded indices [0, 2, 1] it looks somewhat "magic".
> 
> —
> Reply to this email directly or view it on GitHub.
>