Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2011-05-30 06:20:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-05-30 06:20:59 +0400
commit5ef4c45015d4529c7068c6cc9f5c0b5d75176978 (patch)
tree188561d11e29a70a2d85edefb1876b0e1b93f174 /io_scene_x3d
parent783eb14685ec1d2815bfc06acf6615f33b5856b1 (diff)
support for optionally exporting geometry as IndexedTriangleSet rather then IndexedFaceSet.
Diffstat (limited to 'io_scene_x3d')
-rw-r--r--io_scene_x3d/__init__.py2
-rw-r--r--io_scene_x3d/export_x3d.py66
2 files changed, 49 insertions, 19 deletions
diff --git a/io_scene_x3d/__init__.py b/io_scene_x3d/__init__.py
index 7437f375..492de10c 100644
--- a/io_scene_x3d/__init__.py
+++ b/io_scene_x3d/__init__.py
@@ -96,7 +96,7 @@ class ExportX3D(bpy.types.Operator, ExportHelper):
use_selection = BoolProperty(name="Selection Only", description="Export selected objects only", default=False)
use_apply_modifiers = BoolProperty(name="Apply Modifiers", description="Use transformed mesh data from each object", default=True)
- use_triangulate = BoolProperty(name="Triangulate", description="Triangulate quads.", default=False)
+ use_triangulate = BoolProperty(name="Triangulate", description="Write quads into 'IndexedTriangleSet'", default=False)
use_compress = BoolProperty(name="Compress", description="GZip the resulting file, requires a full python install", default=False)
axis_forward = EnumProperty(
diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py
index 08018712..441ffbc9 100644
--- a/io_scene_x3d/export_x3d.py
+++ b/io_scene_x3d/export_x3d.py
@@ -424,8 +424,10 @@ def export(file,
fw("%s</Appearance>\n" % ident)
#-- IndexedFaceSet or IndexedLineSet
-
- fw("%s<IndexedFaceSet " % ident)
+ if EXPORT_TRI:
+ fw("%s<IndexedTriangleSet " % ident)
+ else:
+ fw("%s<IndexedFaceSet " % ident)
ident += "\t"
# --- Write IndexedFaceSet Attributes
@@ -438,16 +440,29 @@ def export(file,
fw("creaseAngle=\"%.4g\" " % mesh.auto_smooth_angle)
if is_uv:
- # "texCoordIndex"
- fw("%stexCoordIndex=\"" % ident)
+ if EXPORT_TRI:
+ fw("%stexIndex=\"" % ident)
+ else:
+ fw("%stexCoordIndex=\"" % ident)
+
j = 0
- for i in face_group:
- if len(mesh_faces[i].vertices) == 4:
- fw("%d %d %d %d -1, " % (j, j + 1, j + 2, j + 3))
- j += 4
- else:
- fw("%d %d %d -1, " % (j, j + 1, j + 2))
- j += 3
+ if EXPORT_TRI:
+ for i in face_group:
+ if len(mesh_faces[i].vertices) == 4:
+ fw("%d %d %d " % (j, j + 1, j + 2))
+ fw("%d %d %d " % (j, j + 2, j + 3))
+ j += 4
+ else:
+ fw("%d %d %d " % (j, j + 1, j + 2))
+ j += 3
+ else:
+ for i in face_group:
+ if len(mesh_faces[i].vertices) == 4:
+ fw("%d %d %d %d -1, " % (j, j + 1, j + 2, j + 3))
+ j += 4
+ else:
+ fw("%d %d %d -1, " % (j, j + 1, j + 2))
+ j += 3
fw("\" ")
# --- end texCoordIndex
@@ -456,15 +471,19 @@ def export(file,
if True:
# "coordIndex"
- fw("coordIndex=\"")
+ if EXPORT_TRI:
+ fw("index=\"")
+ else:
+ fw("coordIndex=\"")
+
if EXPORT_TRI:
for i in face_group:
fv = mesh_faces[i].vertices[:]
if len(fv) == 3:
- fw("%i %i %i -1, " % fv)
+ fw("%i %i %i " % fv)
else:
- fw("%i %i %i -1, " % (fv[0], fv[1], fv[2]))
- fw("%i %i %i -1, " % (fv[0], fv[2], fv[3]))
+ fw("%i %i %i " % (fv[0], fv[1], fv[2]))
+ fw("%i %i %i " % (fv[0], fv[2], fv[3]))
else:
for i in face_group:
fv = mesh_faces[i].vertices[:]
@@ -504,8 +523,14 @@ def export(file,
fw("%s<Color color=\"" % ident)
# XXX, 1 color per face, only
mesh_faces_col = mesh.vertex_colors.active.data
- for i in face_group:
- fw("%.3g %.3g %.3g, " % mesh_faces_col[i].color1[:])
+ if EXPORT_TRI:
+ for i in face_group:
+ fw("%.3g %.3g %.3g, " % mesh_faces_col[i].color1[:])
+ if len(mesh_faces[i].vertices) == 4:
+ fw("%.3g %.3g %.3g, " % mesh_faces_col[i].color1[:])
+ else:
+ for i in face_group:
+ fw("%.3g %.3g %.3g, " % mesh_faces_col[i].color1[:])
del mesh_faces_col
fw("\" />\n")
@@ -513,7 +538,12 @@ def export(file,
#--- output closing braces
ident = ident[:-1]
- fw("%s</IndexedFaceSet>\n" % ident)
+
+ if EXPORT_TRI:
+ fw("%s</IndexedTriangleSet>\n" % ident)
+ else:
+ fw("%s</IndexedFaceSet>\n" % ident)
+
ident = ident[:-1]
fw("%s</Shape>\n" % ident)