Skip to content

Commit

Permalink
Disabled the fix to suppress duplicate geometry in CET exported scene…
Browse files Browse the repository at this point in the history
…s, since it resulted in removal of valid geometry
  • Loading branch information
lfaynshteyn committed Aug 29, 2019
1 parent bf7e7f5 commit 38ba3f0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
4 changes: 3 additions & 1 deletion yulio_gltf_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@
# Passed FOV to gltf from SU
# 2.2.0 Fixed RGBA blending not being supported when a texture was specified for a material
# A fix to suppress duplicate geometry in CET exported scenes
# 2.2.1 Disabled the fix to suppress duplicate geometry in CET exported scenes, since it resulted in removal of valid geometry


module Yulio
module GltfExporter
Expand All @@ -68,7 +70,7 @@ module GltfExporter

ex = SketchupExtension.new(TRANSLATE["title"], 'yulio_gltf_export/gltf_export')
ex.description = TRANSLATE["description"]
ex.version = '2.2.0'
ex.version = '2.2.1'
ex.copyright = '©2019'
ex.creator = 'Yulio Technolgies Inc.'
Sketchup.register_extension(ex, true)
Expand Down
2 changes: 1 addition & 1 deletion yulio_gltf_export/gltf_export.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def export(is_binary, is_microsoft, filename)
asset = {
"version" => "2.0",
"minVersion" => "2.0", #Min version required to load the file (optional field)
"generator" => "Sketchup glTF Exporter v2.2.0 by Yulio Technogies Inc."
"generator" => "Sketchup glTF Exporter v2.2.1 by Yulio Technogies Inc."
}

# set the glTF copyright field, use model.description
Expand Down
34 changes: 20 additions & 14 deletions yulio_gltf_export/mesh_geometry_collect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,26 @@ def collate_geometry(nodeId, transformation, entities, group, group_with_materia
next
end

# Lev: a hack to filter out CET exported geometry representing the insides of objects. Such geometry has a double-sided materials with certain properties:
# Front faces will have a material named "Color_#xxxxxx", where xxxxxx is a hexadecimal RGB value.
# Back faces will have a material name staring the "Transparent" and the opacity value of 0.0.
# Note, that skipping all of the faces of a mesh will likely produce empty parent nodes in the resulting glTF file.
# It's not a big deal (this is not classified as an error in the glTF spec), but we should address it at some point (likely in the common glTF exporter back-end implementation).
if (face.back_material != nil)
# Put the easiest to evaluate conditions on the left for performance reasons
if (#face.back_material.alpha == 0.0 &&
face.back_material.name.match(/^Transparent/) &&
face.material.name.match(/^Color_#([a-fA-F0-9]{6})/))
#puts "CET face match found: " + face.material.name
next
end
end
# Lev: commenting out the hack below as it results in valid geomerty also being removed from CET exported scenes.
# It looks like the CET's SU exporter generates the material face names automatically based on either the assigned texture file name or, if there's no texture assigned, on the diffuse color RGB values
# (e.g. 5H11_1_999 (d01c678dcb795fe0fce65c67e754be7bac9505c54932b973).JPG or Color_#7f7f7f). This naming schema is used equally for both the regular 'outer shell' geometry,
# as well as the 'inner shell' geometry and thus can't be used to differentiate between the two. We'll have to look into geometry topology and/or occlusion heruistics in the future to address this problem.
# ====>
# # Lev: a hack to filter out CET exported geometry representing the insides of objects. Such geometry has a double-sided materials with certain properties:
# # Front faces will have a material named "Color_#xxxxxx", where xxxxxx is a hexadecimal RGB value.
# # Back faces will have a material name staring the "Transparent" and the opacity value of 0.0.
# # Note, that skipping all of the faces of a mesh will likely produce empty parent nodes in the resulting glTF file.
# # It's not a big deal (this is not classified as an error in the glTF spec), but we should address it at some point (likely in the common glTF exporter back-end implementation).
# if (face.back_material != nil)
# # Put the easiest to evaluate conditions on the left for performance reasons
# if (#face.back_material.alpha == 0.0 &&
# face.back_material.name.match(/^Transparent/) &&
# face.material.name.match(/^Color_#([a-fA-F0-9]{6})/))
# #puts "CET face match found: " + face.material.name
# next
# end
# end
# <====
end

material_id = @materials.add_material(faceWithMaterial)
Expand Down

0 comments on commit 38ba3f0

Please sign in to comment.