[Bf-extensions-cvs] SVN commit: /data/svn/bf-extensions [2194] trunk/py/scripts/addons/ io_scene_x3d/export_x3d.py: patch [#27769] Small fixes for X3D exporter: not existing IndexedTriangleSet.creaseAngle, zero Viewpoint.orientation, . ..

Campbell Barton ideasman42 at gmail.com
Fri Jul 29 01:22:12 CEST 2011


Revision: 2194
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-extensions&revision=2194
Author:   campbellbarton
Date:     2011-07-28 23:22:11 +0000 (Thu, 28 Jul 2011)
Log Message:
-----------
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).

Modified Paths:
--------------
    trunk/py/scripts/addons/io_scene_x3d/export_x3d.py

Modified: trunk/py/scripts/addons/io_scene_x3d/export_x3d.py
===================================================================
--- trunk/py/scripts/addons/io_scene_x3d/export_x3d.py	2011-07-28 23:01:09 UTC (rev 2193)
+++ trunk/py/scripts/addons/io_scene_x3d/export_x3d.py	2011-07-28 23:22:11 UTC (rev 2194)
@@ -514,7 +514,10 @@
 
                     # 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 @@
 
                             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 @@
                         # --- 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 @@
             filepath_base = os.path.basename(filepath_full)
 
             images = [
+                filepath_ref,
                 filepath_base,
-                filepath_ref,
                 filepath_full,
             ]
 



More information about the Bf-extensions-cvs mailing list