~diresu/blender/blender-command-port

« back to all changes in this revision

Viewing changes to release/scripts/lightwave_export.py

  • Committer: Dietrich Bollmann
  • Date: 2009-04-26 06:25:14 UTC
  • mfrom: (184.1.520)
  • Revision ID: diresu@web.de-20090426062514-ly27wepl1t5d7p8s
Update to state of blender repository from 2009-04-26 revision 19927.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
v5.5 format.
40
40
"""
41
41
 
42
 
# $Id: lightwave_export.py 19866 2009-04-22 09:08:57Z campbellbarton $
 
42
# $Id: lightwave_export.py 19926 2009-04-25 17:52:04Z campbellbarton $
43
43
#
44
44
# +---------------------------------------------------------+
45
45
# | Copyright (c) 2002 Anthony D'Agostino                   |
351
351
# === Generate Per-Face UV Coords (VMAD Chunk) ===
352
352
# ================================================
353
353
def generate_vmad_uv(mesh):
354
 
        data = cStringIO.StringIO()
355
 
        data.write("TXUV")                                       # type
356
 
        data.write(struct.pack(">H", 2))                         # dimension
357
 
        data.write(generate_nstring("Blender's UV Coordinates")) # name
 
354
        layers = mesh.getUVLayerNames()
 
355
        org_uv = mesh.activeUVLayer
 
356
        for l in layers:
 
357
                mesh.activeUVLayer = l
 
358
                data = cStringIO.StringIO()
 
359
                data.write("TXUV")                                       # type
 
360
                data.write(struct.pack(">H", 2))                         # dimension
 
361
                data.write(generate_nstring(l)) # name
 
362
                for i, f in enumerate(mesh.faces):
 
363
                        if not i%100:
 
364
                                Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing UV Coordinates")
 
365
                        
 
366
                        uv = f.uv
 
367
                        f_v = f.v
 
368
                        for j in xrange(len(f)-1, -1, -1):             # Reverse order
 
369
                                U,V = uv[j]
 
370
                                v = f_v[j].index
 
371
                                data.write(struct.pack(">H", v)) # vertex index
 
372
                                data.write(struct.pack(">H", i)) # face index
 
373
                                data.write(struct.pack(">ff", U, V))
358
374
        
359
 
        for i, f in enumerate(mesh.faces):
360
 
                if not i%100:
361
 
                        Blender.Window.DrawProgressBar(float(i)/len(mesh.faces), "Writing UV Coordinates")
362
 
                
363
 
                uv = f.uv
364
 
                f_v = f.v
365
 
                for j in xrange(len(f)-1, -1, -1):                      # Reverse order
366
 
                        U,V = uv[j]
367
 
                        v = f_v[j].index
368
 
                        data.write(struct.pack(">H", v)) # vertex index
369
 
                        data.write(struct.pack(">H", i)) # face index
370
 
                        data.write(struct.pack(">ff", U, V))
 
375
        mesh.activeUVLayer = org_uv
371
376
        return data.getvalue()
372
377
 
373
378
# ======================================