diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-08-27 11:32:58 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-08-27 11:32:58 +0400 |
commit | 26e71929d8b73315e04c68556075029cdb589769 (patch) | |
tree | b6eb8f9e20a1891d8aab7034ee108588bfcd1830 /release | |
parent | b0b787ef38f9947b3176642556f5282eb3518f69 (diff) |
bugfix [#23220] .x3d export not exporting UV correctly
- UV texture coords were never written.
- TexFace with no material resulted in an invalid XML file (unclosed tag)
- freewrl wouldn't parse "FALSE", needs to be "false"
- the ID data name was being written as the filename, so in many cases images wouldn't load.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/io/export_x3d.py | 60 |
1 files changed, 28 insertions, 32 deletions
diff --git a/release/scripts/io/export_x3d.py b/release/scripts/io/export_x3d.py index 12fe63f5296..2fa6a0015c7 100644 --- a/release/scripts/io/export_x3d.py +++ b/release/scripts/io/export_x3d.py @@ -183,7 +183,7 @@ class x3d_class: self.file.write("<head>\n") self.file.write("\t<meta name=\"filename\" content=\"%s\" />\n" % os.path.basename(bfile)) # self.file.write("\t<meta name=\"filename\" content=\"%s\" />\n" % sys.basename(bfile)) - self.file.write("\t<meta name=\"generator\" content=\"Blender %s\" />\n" % '2.5') + self.file.write("\t<meta name=\"generator\" content=\"Blender %s\" />\n" % bpy.app.version_string) # self.file.write("\t<meta name=\"generator\" content=\"Blender %s\" />\n" % Blender.Get('version')) self.file.write("\t<meta name=\"translator\" content=\"X3D exporter v1.55 (2006/01/17)\" />\n") self.file.write("</head>\n") @@ -274,7 +274,7 @@ class x3d_class: return def writeNavigationInfo(self, scene): - self.file.write('<NavigationInfo headlight="FALSE" visibilityLimit="0.0" type=\'"EXAMINE","ANY"\' avatarSize="0.25, 1.75, 0.75" />\n') + self.file.write('<NavigationInfo headlight="false" visibilityLimit="0.0" type=\'"EXAMINE","ANY"\' avatarSize="0.25, 1.75, 0.75" />\n') def writeSpotLight(self, ob, mtx, lamp, world): safeName = self.cleanStr(ob.name) @@ -457,40 +457,38 @@ class x3d_class: self.writeIndented("<Shape>\n",1) maters=mesh.materials - hasImageTexture=0 + hasImageTexture = False is_smooth = False if len(maters) > 0 or mesh.uv_textures.active: # if len(maters) > 0 or mesh.faceUV: self.writeIndented("<Appearance>\n", 1) # right now this script can only handle a single material per mesh. - if len(maters) >= 1: - mat=maters[0] - # matFlags = mat.getMode() - if not mat.use_face_texture: - # if not matFlags & Blender.Material.Modes['TEXFACE']: - self.writeMaterial(mat, self.cleanStr(mat.name,''), world) - # self.writeMaterial(mat, self.cleanStr(maters[0].name,''), world) - if len(maters) > 1: - print("Warning: mesh named %s has multiple materials" % meshName) - print("Warning: only one material per object handled") + if len(maters) >= 1 and maters[0].use_face_texture == False: + self.writeMaterial(mat, self.cleanStr(mat.name,''), world) + if len(maters) > 1: + print("Warning: mesh named %s has multiple materials" % meshName) + print("Warning: only one material per object handled") + if not len(maters) or maters[0].use_face_texture: #-- textures - face = None + image = None if mesh.uv_textures.active: - # if mesh.faceUV: for face in mesh.uv_textures.active.data: - # for face in mesh.faces: - if face.image: - # if (hasImageTexture == 0) and (face.image): - self.writeImageTexture(face.image) - # hasImageTexture=1 # keep track of face texture - break - if self.tilenode == 1 and face and face.image: - # if self.tilenode == 1: - self.writeIndented("<TextureTransform scale=\"%s %s\" />\n" % (face.image.xrep, face.image.yrep)) - self.tilenode = 0 - self.writeIndented("</Appearance>\n", -1) + if face.use_image: + image = face.image + if image: + self.writeImageTexture(image) + break + + if image: + hasImageTexture = True + + if self.tilenode == 1: + self.writeIndented("<TextureTransform scale=\"%s %s\" />\n" % (image.xrep, image.yrep)) + self.tilenode = 0 + + self.writeIndented("</Appearance>\n", -1) #-- IndexedFaceSet or IndexedLineSet @@ -523,10 +521,9 @@ class x3d_class: #--- output textureCoordinates if UV texture used if mesh.uv_textures.active: - # if mesh.faceUV: if self.matonly == 1 and self.share == 1: self.writeFaceColors(mesh) - elif hasImageTexture == 1: + elif hasImageTexture == True: self.writeTextureCoordinates(mesh) #--- output coordinates self.writeCoordinates(ob, mesh, meshName, EXPORT_TRI) @@ -539,7 +536,7 @@ class x3d_class: #--- output textureCoordinates if UV texture used if mesh.uv_textures.active: # if mesh.faceUV: - if hasImageTexture == 1: + if hasImageTexture == True: self.writeTextureCoordinates(mesh) elif self.matonly == 1 and self.share == 1: self.writeFaceColors(mesh) @@ -714,14 +711,13 @@ class x3d_class: def writeImageTexture(self, image): name = image.name - filename = image.filepath.split('/')[-1].split('\\')[-1] + filename = os.path.basename(image.filepath) if name in self.texNames: self.writeIndented("<ImageTexture USE=\"%s\" />\n" % self.cleanStr(name)) self.texNames[name] += 1 - return else: self.writeIndented("<ImageTexture DEF=\"%s\" " % self.cleanStr(name), 1) - self.file.write("url=\"%s\" />" % name) + self.file.write("url=\"%s\" />" % filename) self.writeIndented("\n",-1) self.texNames[name] = 1 |