Merge with 2.5 -r 21756:22173.
[blender.git] / release / io / export_ply.py
index ed983c2b1695d8897826de6144170fe35c0d3717..2f10875c9708f9cf4706cef86329694e04f20193 100644 (file)
@@ -64,7 +64,7 @@ def write(filename, scene, ob, \
                raise Exception("Error, Select 1 active object")
                return
        
-       file = open(filename, 'wb')
+       file = open(filename, 'w')
        
        
        #EXPORT_EDGES = Draw.Create(0)
@@ -123,19 +123,17 @@ def write(filename, scene, ob, \
        mesh_verts = mesh.verts # save a lookup
        ply_verts = [] # list of dictionaries
        # vdict = {} # (index, normal, uv) -> new index
-       vdict = [{} for i in xrange(len(mesh_verts))]
-       ply_faces = [[] for f in xrange(len(mesh.faces))]
+       vdict = [{} for i in range(len(mesh_verts))]
+       ply_faces = [[] for f in range(len(mesh.faces))]
        vert_count = 0
        for i, f in enumerate(mesh.faces):
                
                
                smooth = f.smooth
-               # XXX need face normals
-               """
                if not smooth:
-                       normal = tuple(f.no)
+                       normal = tuple(f.normal)
                        normal_key = rvec3d(normal)
-               """
+               
                if faceUV:
                        uv = active_uv_layer[i]
                        uv = uv.uv1, uv.uv2, uv.uv3, uv.uv4 # XXX - crufty :/
@@ -149,12 +147,10 @@ def write(filename, scene, ob, \
                pf= ply_faces[i]
                for j, vidx in enumerate(f_verts):
                        v = mesh_verts[vidx]
-                       """
+                       
                        if smooth:
-                               normal=         tuple(v.no)
+                               normal=         tuple(v.normal)
                                normal_key = rvec3d(normal)
-                       """
-                       normal_key = None # XXX
                        
                        if faceUV:
                                uvcoord=        uv[j][0], 1.0-uv[j][1]
@@ -238,8 +234,9 @@ def write(filename, scene, ob, \
 
 class EXPORT_OT_ply(bpy.types.Operator):
        '''
-       Operator documentatuon text, will be used for the operator tooltip and python docs.
+       Operator documentation text, will be used for the operator tooltip and python docs.
        '''
+       __idname__ = "export.ply"
        __label__ = "Export PLY"
        
        # List of operator properties, the attributes will be assigned