[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [31611] trunk/blender/release/scripts/io/ export_x3d.py: bugfix [#23220] .x3d export not exporting UV correctly
Campbell Barton
ideasman42 at gmail.com
Fri Aug 27 09:32:58 CEST 2010
Revision: 31611
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=31611
Author: campbellbarton
Date: 2010-08-27 09:32:58 +0200 (Fri, 27 Aug 2010)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/release/scripts/io/export_x3d.py
Modified: trunk/blender/release/scripts/io/export_x3d.py
===================================================================
--- trunk/blender/release/scripts/io/export_x3d.py 2010-08-27 07:06:37 UTC (rev 31610)
+++ trunk/blender/release/scripts/io/export_x3d.py 2010-08-27 07:32:58 UTC (rev 31611)
@@ -183,7 +183,7 @@
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 @@
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,41 +457,39 @@
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
# user selected BOUNDS=1, SOLID=3, SHARED=4, or TEXTURE=5
@@ -523,10 +521,9 @@
#--- 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 @@
#--- 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 @@
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
More information about the Bf-blender-cvs
mailing list