Skip to content
Snippets Groups Projects
Commit 2a9841dc authored by Campbell Barton's avatar Campbell Barton
Browse files

patch [#27769] Small fixes for X3D exporter: not existing...

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).
parent 44a94e93
No related branches found
No related tags found
No related merge requests found
...@@ -514,7 +514,10 @@ def export(file, ...@@ -514,7 +514,10 @@ def export(file,
# UV's and VCols split verts off which effects smoothing # UV's and VCols split verts off which effects smoothing
# force writing normals in this case. # 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: if use_h3d:
gpu_shader = gpu_shader_cache.get(material) # material can be 'None', uses dummy cache gpu_shader = gpu_shader_cache.get(material) # material can be 'None', uses dummy cache
...@@ -559,6 +562,7 @@ def export(file, ...@@ -559,6 +562,7 @@ def export(file,
ident_step = ident + (' ' * (-len(ident) + \ ident_step = ident + (' ' * (-len(ident) + \
fw('%s<TextureTransform ' % ident))) fw('%s<TextureTransform ' % ident)))
fw('\n')
# fw('center="%.6g %.6g" ' % (0.0, 0.0)) # fw('center="%.6g %.6g" ' % (0.0, 0.0))
fw(ident_step + 'translation="%.6g %.6g"\n' % loc) fw(ident_step + 'translation="%.6g %.6g"\n' % loc)
fw(ident_step + 'scale="%.6g %.6g"\n' % (sca_x, sca_y)) fw(ident_step + 'scale="%.6g %.6g"\n' % (sca_x, sca_y))
...@@ -588,11 +592,11 @@ def export(file, ...@@ -588,11 +592,11 @@ def export(file,
# --- Write IndexedTriangleSet Attributes (same as IndexedFaceSet) # --- Write IndexedTriangleSet Attributes (same as IndexedFaceSet)
fw('solid="%s"\n' % ('true' if mesh.show_double_sided else 'false')) fw('solid="%s"\n' % ('true' if mesh.show_double_sided else 'false'))
# creaseAngle unsupported for IndexedTriangleSet's
if use_normals or is_force_normals: if use_normals or is_force_normals:
# currently not optional, could be made so:
fw(ident_step + 'normalPerVertex="true"\n') 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_uv = None
slot_col = None slot_col = None
...@@ -1142,8 +1146,8 @@ def export(file, ...@@ -1142,8 +1146,8 @@ def export(file,
filepath_base = os.path.basename(filepath_full) filepath_base = os.path.basename(filepath_full)
images = [ images = [
filepath_base,
filepath_ref, filepath_ref,
filepath_base,
filepath_full, filepath_full,
] ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment