6 July 2011 Invert3D VBScript


3D Meshes are built from many triangular faces. Each triangle has a 'normal', which is a direction vector perpendicular to the triangular face. The order of the points around the triangle will determine the normal direction. CamBam uses a 'Right Hand Rule', so that if the fingers of your right hand curl in the direction that the triangle points are ordered, your thumb will point in the direction of the normal.

Normal vectors are used to determine the outside facing direction of each face. When displaying meshes, faces pointing away from the viewer are often ignored by the display routines. If meshes are wound using a 'Left Hand Rule', this can result in the models appearing dark or hard to see in the CamBam drawing display.

The following script will reverse the winding direction of all selected mesh objects.


sub main
  dim tmp as long
  dim tri as TriangleFace

  for each ent as Entity in view.Selection
    if typeof ent is Surface
      dim surf as Surface = ent
      for i as long = 0 to surf.Faces.Length-1
        tri = surf.Faces(i)
        tmp = tri.B
        tri.B = tri.C
        tri.C = tmp
        surf.Faces(i) = tri
      next i
    end if
  next ent
end sub


<< 1 >> 
#  mr.sherman w.suber jr 24/07/2018 19:37:50
Haver a summme suite coutest!
Reply Quote   5  

name: Rate this article

Name, url and e-mail are optional. E-mail addresses will NOT be displayed, but please provide one if you would like a reply.
If your comment or url is not displayed immediately, it may be awaiting approval.
The following BBCode formatting codes are supported : [b], [i], [u], [code], [quote], [list], [*]
Your comments...

Submit Comment