From 2a9841dc56d9a7d1df773c4114f6805674471dd3 Mon Sep 17 00:00:00 2001 From: Campbell Barton <ideasman42@gmail.com> Date: Thu, 28 Jul 2011 23:22:11 +0000 Subject: [PATCH] patch [#27769] Small fixes for X3D exporter: not existing IndexedTriangleSet.creaseAngle, zero Viewpoint.orientation, ... *Info from the tracker submission this patch resolves* 3. When exporting texture URL, new Blender 2.58 exporter writes URLs in the order: [basename, result of bpy_extras.io_utils.path_reference, absolute]. I propose to change this order to write the result of bpy_extras.io_utils.path_reference *first*. Reasons: -- Result of bpy_extras.io_utils.path_reference is controlled by user (through path_mode). By setting it correctly, user can make sure that 1st url matches (which is nice for 3d viewer, also avoids warnings from view3dcene that one url along the way was not available). -- This also makes the results of 2.58 exporter more similar to how 2.57 behaved. In 2.57, the relative path "os.path.relpath(filepath_full, relpath)" was first, then basename, then absolute name. And that was good, in my opinion, as relative path has the best chance of success and is more directly controlled by user. (New "bpy_extras.io_utils.path_reference" is even better, so kudos for implementing it.) 4. Finally, a trivial fix to the formatting of output "<TextureTransform..." in X3D. Without this fix, "<TextureTransform" and "translation=" are on the same output line, separated by a lot of whitespaces (taken from ident_step). --- io_scene_x3d/export_x3d.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/io_scene_x3d/export_x3d.py b/io_scene_x3d/export_x3d.py index e39ed07e2..52f19a931 100644 --- a/io_scene_x3d/export_x3d.py +++ b/io_scene_x3d/export_x3d.py @@ -514,7 +514,10 @@ def export(file, # UV's and VCols split verts off which effects smoothing # force writing normals in this case. - is_force_normals = use_triangulate and is_smooth and (is_uv or is_col) + # Also, creaseAngle is not supported for IndexedTriangleSet, + # so write normals when is_smooth (otherwise + # IndexedTriangleSet can have only all smooth/all flat shading). + is_force_normals = use_triangulate and (is_smooth or is_uv or is_col) if use_h3d: gpu_shader = gpu_shader_cache.get(material) # material can be 'None', uses dummy cache @@ -559,6 +562,7 @@ def export(file, ident_step = ident + (' ' * (-len(ident) + \ fw('%s<TextureTransform ' % ident))) + fw('\n') # fw('center="%.6g %.6g" ' % (0.0, 0.0)) fw(ident_step + 'translation="%.6g %.6g"\n' % loc) fw(ident_step + 'scale="%.6g %.6g"\n' % (sca_x, sca_y)) @@ -588,11 +592,11 @@ def export(file, # --- Write IndexedTriangleSet Attributes (same as IndexedFaceSet) fw('solid="%s"\n' % ('true' if mesh.show_double_sided else 'false')) - # creaseAngle unsupported for IndexedTriangleSet's - if use_normals or is_force_normals: - # currently not optional, could be made so: fw(ident_step + 'normalPerVertex="true"\n') + else: + # Tell X3D browser to generate flat (per-face) normals + fw(ident_step + 'normalPerVertex="false"\n') slot_uv = None slot_col = None @@ -1142,8 +1146,8 @@ def export(file, filepath_base = os.path.basename(filepath_full) images = [ - filepath_base, filepath_ref, + filepath_base, filepath_full, ] -- GitLab