[Bf-committers] [Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14779] trunk/blender/release/scripts/ vrml97_export.py: Reverting vrml97_export.py to it' s state at revision 14751 because:

Chris Want cwant at ualberta.ca
Sat May 10 17:58:44 CEST 2008


Campbell Barton wrote:
> if you cant find tine to maintain a script you should at least varify
> that another persons changes broke somthing that previously worked
> before reverting the changes.
> 
> Before commiting the changes I tried testing with compinations of
> materials and images to make sure they would load in a VRML viewer.
> currently material export is very broken, and not exporting faces that
> have no materials seems ridiciolous.
> 
> A good compromise would be to only apply fixes from the previous commits.

Hi there,

If you actually tested things, you would have noticed that
commit 14757 achieved that exact opposite of what you claimed
you were trying to do. I don't have confidence in what you
are committing and  don't have time to test right now
(seriously, I leave on a plane to Frankfurt in about 4 hours
and I really shouldn't be having this conversation now).
I don't want to get back after a release and be surprised that
the vrml script that I maintain no longer does what I
expect it to. The 'bug' is something that is only
aggravated when the user does something weird (doesn't
assign materials to faces), and I would rather take some
time to devise a good bug fix, rather than just committing
some quick hack in order to reduce the number of open bugs
by one.

Further, I asked you to consult with me about changes to this
script before committing and you did not respect that.

Chris

> 
> On Sat, May 10, 2008 at 4:05 PM, Chris Want <cwant at ualberta.ca> wrote:
>> Revision: 14779
>>          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14779
>> Author:   hos
>> Date:     2008-05-10 16:05:35 +0200 (Sat, 10 May 2008)
>>
>> Log Message:
>> -----------
>> Reverting vrml97_export.py to it's state at revision 14751 because:
>>
>> 1) Bug #6692 is actually a feature request. While I do think that
>> Michalis' patch is a worthy change, we don't have time to test
>> this at this stage in the release cycle (and svn is supposedly
>> closed to new features anyways). I'm sorry Michalis, this will
>> have to wait until after release.
>>
>> 2) I have looked at bug #8814 a while ago, but I have not yet found
>> a good solution (and perhaps the solution is to *not* export faces
>> without materials assigned). I don't have time to assess whether
>> revision 14774 presents a worthwhile change or not, and I have no
>> time to test before release. Also I don't like that the 'fix' for
>> #8814 is mixed with a fix for a previous faulty commit.
>>
>> 3) Again, another commit to a script I maintain without consulting
>> me first. Not cool!
>>
>> Chris
>>
>> Revision Links:
>> --------------
>>    http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14751
>>    http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14774
>>
>> Modified Paths:
>> --------------
>>    trunk/blender/release/scripts/vrml97_export.py
>>
>> Modified: trunk/blender/release/scripts/vrml97_export.py
>> ===================================================================
>> --- trunk/blender/release/scripts/vrml97_export.py      2008-05-10 13:09:34 UTC (rev 14778)
>> +++ trunk/blender/release/scripts/vrml97_export.py      2008-05-10 14:05:35 UTC (rev 14779)
>> @@ -3,6 +3,9 @@
>>  Name: 'VRML97 (.wrl)...'
>>  Blender: 241
>>  Group: 'Export'
>> +Submenu: 'All Objects...' all
>> +Submenu: 'All Objects compressed...' comp
>> +Submenu: 'Selected Objects...' selected
>>  Tooltip: 'Export to VRML97 file (.wrl)'
>>  """
>>
>> @@ -52,7 +55,7 @@
>>
>>  import Blender
>>  from Blender import Object, Mesh, Lamp, Draw, BGL, \
>> -        Image, Text, sys, Mathutils, Registry
>> +        Image, Text, sys, Mathutils
>>  from Blender.Scene import Render
>>
>>  import math
>> @@ -67,9 +70,8 @@
>>  filename = Blender.Get('filename')
>>  _safeOverwrite = True
>>  extension = ''
>> +ARG=''
>>
>> -# Matrices below are used only when export_rotate_z_to_y.val:
>> -#
>>  # Blender is Z up, VRML is Y up, both are right hand coordinate
>>  # systems, so to go from Blender coords to VRML coords we rotate
>>  # by 90 degrees around the X axis. In matrix notation, we have a
>> @@ -206,7 +208,7 @@
>>                if scene != inlines[0]:
>>                        return
>>                else:
>> -                       for i in xrange(allinlines):
>> +                       for i in range(allinlines):
>>                                nameinline=inlines[i].getName()
>>                                if (nameinline not in self.namesStandard) and (i > 0):
>>                                        self.writeIndented("DEF %s Inline {\n" % \
>> @@ -219,7 +221,7 @@
>>        def writeScript(self):
>>                textEditor = Blender.Text.Get()
>>                alltext = len(textEditor)
>> -               for i in xrange(alltext):
>> +               for i in range(alltext):
>>                        nametext = textEditor[i].getName()
>>                        nlines = textEditor[i].getNLines()
>>                        if (self.proto == 1):
>> @@ -227,14 +229,14 @@
>>                                        nametext == "proto.txt") and (nlines != None):
>>                                        nalllines = len(textEditor[i].asLines())
>>                                        alllines = textEditor[i].asLines()
>> -                                       for j in xrange(nalllines):
>> +                                       for j in range(nalllines):
>>                                                self.writeIndented(alllines[j] + "\n")
>>                        elif (self.proto == 0):
>>                                if (nametext == "route" or nametext == "route.js" or \
>>                                        nametext == "route.txt") and (nlines != None):
>>                                        nalllines = len(textEditor[i].asLines())
>>                                        alllines = textEditor[i].asLines()
>> -                                       for j in xrange(nalllines):
>> +                                       for j in range(nalllines):
>>                                                self.writeIndented(alllines[j] + "\n")
>>                self.writeIndented("\n")
>>
>> @@ -449,9 +451,8 @@
>>                # (as a non-face property) and if first material has
>>                # vcol paint set, we export the vertex colors
>>                if (me.vertexColors):
>> -                       materials = [m for m in me.materials if m]
>> -                       if len(materials) > 0:
>> -                               mat = materials[0]
>> +                       if len(me.materials) > 0:
>> +                               mat = me.materials[0]
>>                                if mat:
>>                                        if (mat.mode & Blender.Material.Modes['VCOL_PAINT']):
>>                                                self.vcolors = 1
>> @@ -555,7 +556,7 @@
>>                issmooth = 0
>>
>>                maters = me.materials
>> -               nummats = len([m for m in maters if m])
>> +               nummats = self.getNumMaterials(me)
>>
>>                # Vertex and Face colors trump materials and image textures
>>                if (self.facecolors or self.vcolors):
>> @@ -568,18 +569,18 @@
>>                                self.writeShape(ob, me, -1, None)
>>                # Do meshes with materials, possible with image textures
>>                elif nummats > 0:
>> -                       for matnum in xrange(len(maters)):
>> -                               images = []
>> -                               if me.faceUV:
>> -                                       images = self.getImages(me, matnum)
>> -                                       if len(images) > 0:
>> -                                               for image in images:
>> -                                                       self.writeShape(ob, me, matnum, image)
>> +                       for matnum in range(len(maters)):
>> +                               if maters[matnum]:
>> +                                       images = []
>> +                                       if me.faceUV:
>> +                                               images = self.getImages(me, matnum)
>> +                                               if len(images) > 0:
>> +                                                       for image in images:
>> +                                                               self.writeShape(ob, me, matnum, image)
>> +                                               else:
>> +                                                       self.writeShape(ob, me, matnum, None)
>>                                        else:
>>                                                self.writeShape(ob, me, matnum, None)
>> -                               else:
>> -                                       self.writeShape(ob, me, matnum, None)
>> -
>>                else:
>>                        if me.faceUV:
>>                                images = self.getImages(me, -1)
>> @@ -597,29 +598,25 @@
>>
>>        def getImages(self, me, matnum):
>>                imageNames = {}
>> -               images = {} # make a dict to avoid dealing with images too often.
>> -               if matnum == -1:
>> -                       for face in me.faces:
>> -                               img = face.image
>> -                               if img:
>> -                                       images[img] = img # key is a dummy
>> -               else:
>> -                       for face in me.faces:
>> -                               if face.mat == matnum:
>> -                                       img = face.image
>> -                                       if img:
>> -                                               images[img] = img # key is a dummy
>> -
>> -               images = images.values()
>> -
>> -               for image in images:
>> -                       imName = self.cleanStr(image.name)
>> -                       if not imageNames.has_key(imName):
>> -                               images.append(image)
>> -                               imageNames[imName]=1
>> -
>> +               images = []
>> +               for face in me.faces:
>> +                       if (matnum == -1) or (face.mat == matnum):
>> +                               if (face.image):
>> +                                       imName = self.cleanStr(face.image.name)
>> +                                       if not imageNames.has_key(imName):
>> +                                               images.append(face.image)
>> +                                               imageNames[imName]=1
>>                return images
>>
>> +       def getNumMaterials(self, me):
>> +               # Oh silly Blender, why do you sometimes have 'None' as
>> +               # a member of the me.materials array?
>> +               num = 0
>> +               for mat in me.materials:
>> +                       if mat:
>> +                               num = num + 1
>> +               return num
>> +
>>        def writeCoordinates(self, me, meshName):
>>                coordName = "coord_%s" % (meshName)
>>                # look up coord name, use it if available
>> @@ -636,10 +633,12 @@
>>                meshVertexList = me.verts
>>
>>                for vertex in meshVertexList:
>> -                       vrmlvert = vertex.co
>> -                       if export_rotate_z_to_y.val:
>> -                               vrmlvert = M_blen2vrml * vrmlvert
>> -                       self.writeUnindented("%s %s %s\n " % (vrmlvert[0], vrmlvert[1], vrmlvert[2]))
>> +                       blenvert = Mathutils.Vector(vertex.co)
>> +                       vrmlvert = M_blen2vrml * blenvert
>> +                       self.writeUnindented("%s %s %s\n " % \
>> +                                                                (vrmlvert[0], \
>> +                                                                 vrmlvert[1], \
>> +                                                                 vrmlvert[2]))
>>                self.writeIndented("]\n", -1)
>>                self.writeIndented("}\n", -1)
>>                self.writeIndented("\n")
>> @@ -654,11 +653,10 @@
>>                self.writeIndented("appearance Appearance {\n", 1)
>>                if (matnum != -1):
>>                        mater = me.materials[matnum]
>> -                       if mater:
>> -                               self.writeMaterial(mater, self.cleanStr(mater.name,''))
>> -                               if (mater.mode & Blender.Material.Modes['TEXFACE']):
>> -                                       if image != None:
>> -                                               self.writeImageTexture(image.name, image.filename)
>> +                       self.writeMaterial(mater, self.cleanStr(mater.name,''))
>> +                       if (mater.mode & Blender.Material.Modes['TEXFACE']):
>> +                               if image != None:
>> +                                       self.writeImageTexture(image.name, image.filename)
>>                else:
>>                        if image != None:
>>                                self.writeImageTexture(image.name, image.filename)
>> @@ -704,17 +702,11 @@
>>                for face in me.faces:
>>                        if (matnum == -1) or (face.mat == matnum):
>>                                if (image == None) or (face.image == image):
>> -                                       fv = face.v
>> -
>> -                                       if len(face)==3:
>> -                                                       self.file.write("%i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index))
>> -                                       else:
>> -                                               #if EXPORT_TRI:
>> -                                               #       self.file.write("%i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index))
>> -                                               #       self.file.write("%i %i %i -1, " % (fv[0].index, fv[2].index, fv[3].index))
>> -                                               #else:
>> -                                               self.file.write("%i %i %i %i -1, " % (fv[0].index, fv[1].index, fv[2].index, fv[3].index))
>> -
>> +                                       cordStr=""
>> +                                       for v in face.verts:
>> +                                               indx=v.index
>> +                                               cordStr = cordStr + "%s " % indx
>> +                                       self.writeUnindented(cordStr + "-1, \n")
>>                self.writeIndented("]\n", -1)
>>
>>        def writeTextureCoordinates(self, me, meshName, matnum, image):
>> @@ -730,7 +722,7 @@
>>                        indexStr = ""
>>                        if (matnum == -1) or (face.mat == matnum):
>>                                if (face.image == image):
>> -                                       for i in xrange(len(face.verts)):
>> +                                       for i in range(len(face.verts)):
>>                                                uv = face.uv[i]
>>                                                indexStr += "%s " % (j)
>>                                                coordStr += "%s %s, " % \
>> @@ -1024,10 +1016,7 @@
>>                        return
>>
>>                ob_matrix = Mathutils.Matrix(ob.getMatrix('worldspace'))
>> -               if export_rotate_z_to_y.val:
>> -                       matrix = M_blen2vrml * ob_matrix * M_vrml2blen
>> -               else:
>> -                       matrix = ob_matrix
>> +               matrix = M_blen2vrml * ob_matrix * M_vrml2blen
>>                e      = matrix.rotationPart().toEuler()
>>
>>                v = matrix.translationPart()
>> @@ -1100,7 +1089,7 @@
>>                self.writeFog()
>>                self.proto = 0
>>                allObj = []
>> -               if export_selection_only.val:
>> +               if ARG == 'selected':
>>                        allObj = list(scene.objects.context)
>>                else:
>>                        allObj = list(scene.objects)
>> @@ -1109,7 +1098,7 @@
>>                for thisObj in allObj:
>>                        self.writeObject(thisObj)
>>
>> -               if not export_selection_only.val:
>> +               if ARG != 'selected':
>>                        self.writeScript()
>>                self.cleanup()
>>
>> @@ -1224,58 +1213,26 @@
>>        wrlexport=VRML2Export(filename)
>>        wrlexport.export(scene, world, worldmat)
>>
>> -#########################################################
>> -# UI and Registry utilities
>> -#########################################################
>>
>> -export_selection_only = Draw.Create(0)
>> -export_rotate_z_to_y = Draw.Create(1)
>> -export_compressed = Draw.Create(0)
>> -
>> -def save_to_registry():
>> -       d = {}
>> -       d['selection_only'] = export_selection_only.val
>> -       d['rotate_z_to_y'] = export_rotate_z_to_y.val
>> -       d['compressed'] = export_compressed.val
>> -       Registry.SetKey('vrml97_export', d, True)
>> -
>> -def load_from_registry():
>> -       d = Registry.GetKey('vrml97_export', True)
>> -       if d:
>> -               try:
>> -                       export_selection_only.val = d['selection_only']
>> -                       export_rotate_z_to_y.val = d['rotate_z_to_y']
>> -                       export_compressed.val = d['compressed']
>> -               except: save_to_registry() # If data is not valid, rewrite it.
>> -
>> -def show_popup():
>> -       pup_block = [
>> -               ('Selection Only', export_selection_only, 'Only export objects in visible selection. Else export whole scene.'),
>> -               ('Rotate +Z to +Y', export_rotate_z_to_y, 'Rotate such that +Z axis (Blender up) becomes +Y (VRML up).'),
>> -               ('Compress', export_compressed, 'Generate a .wrz file (normal VRML compressed by gzip).')
>> -               ]
>> -       return Draw.PupBlock('Export VRML 97...', pup_block)
>> -
>>  #########################################################
>>  # main routine
>>  #########################################################
>>
>> -load_from_registry()
>> +try:
>> +       ARG = __script__['arg'] # user selected argument
>> +except:
>> +       print "older version"
>>
>> -# Note that show_popup must be done before Blender.Window.FileSelector,
>> -# because export_compressed affects the suggested extension of resulting
>> -# file.
>> -
>> -if show_popup():
>> -       save_to_registry()
>> -       if export_compressed.val:
>> -               try:
>> -                       extension=".wrz"
>> -                       from gzip import *
>> -               except:
>> -                       print "could not import gzip, file will be exported uncompressed"
>> -                       pass
>> +if Blender.Get('version') < 235:
>> +       print "Warning: VRML97 export failed, wrong blender version!"
>> +       print " You aren't running blender version 2.35 or greater"
>> +       print " download a newer version from http://blender3d.org/"
>> +else:
>> +       if ARG == 'comp':
>> +               extension=".wrz"
>> +               from gzip import *
>>        else:
>>                extension=".wrl"
>>        Blender.Window.FileSelector(select_file, "Export VRML97", \
>>                                                                sys.makename(ext=extension))
>> +
>>
>>
>> _______________________________________________
>> Bf-blender-cvs mailing list
>> Bf-blender-cvs at blender.org
>> http://lists.blender.org/mailman/listinfo/bf-blender-cvs
>>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
> 



More information about the Bf-committers mailing list