Skip to content

Commit

Permalink
Fix high-density models.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelTallet committed Jan 17, 2020
1 parent d9ce7c4 commit ca7e3b1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion source/universal_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
# Universal Importer plugin namespace.
module UniversalImporter

VERSION = '1.1.3'.freeze
VERSION = '1.1.4'.freeze

# Load translation if it's available for current locale.
TRANSLATE = LanguageHandler.new('uir.strings')
Expand Down
2 changes: 1 addition & 1 deletion source/universal_importer/gltf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def initialize(file_path)

end

# Returns buffers paths if they exist.
# If they exist: returns buffers paths.
#
# @return [Array<String>]
def buffers_paths
Expand Down
38 changes: 24 additions & 14 deletions source/universal_importer/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ def initialize

export_to_dae_format

fix_faces_in_dae_export

import_from_dae_format

end
Expand Down Expand Up @@ -164,11 +166,10 @@ def ask_for_model_height

end

# Copies 3D model, textures and texture atlas to
# Copies textures, 3D model & associated files to
# Universal Importer program data temp directory.
#
# XXX Required to avoid invalid characters in path.
# Assimp doesn't support whitespaces in path (mac).
#
# @return [nil]
def copy_to_prog_data_dir
Expand Down Expand Up @@ -196,7 +197,8 @@ def copy_to_prog_data_dir
SESSION[:temp_dir] # destination
)

# Renames 3D model in place.
# Renames 3D model without whitespace.
# XXX Assimp doesn't support whitespaces in path (macOS).

temp_import_file_path = File.join(
SESSION[:temp_dir],
Expand Down Expand Up @@ -276,17 +278,6 @@ def copy_to_prog_data_dir

end

# If it exists: copies texture atlas to temp directory.

if !@import_texture_atlas_file_path.nil?

FileUtils.cp(
@import_texture_atlas_file_path, # source
SESSION[:temp_dir] # destination
)

end

nil

end
Expand Down Expand Up @@ -505,6 +496,25 @@ def export_to_dae_format

end

# Fix faces in DAE export.
#
# @return [nil]
def fix_faces_in_dae_export

dae_export = File.read(@dae_export_file_path)

double_sided_face_fix = '<extra><technique profile="GOOGLEEARTH">'
double_sided_face_fix += '<double_sided>1</double_sided>'
double_sided_face_fix += "</technique></extra>\n</profile_COMMON>"

dae_export.gsub!('</profile_COMMON>', double_sided_face_fix)

File.write(@dae_export_file_path, dae_export)

nil

end

# Imports 3D model from DAE format.
#
# @return [Boolean]
Expand Down

0 comments on commit ca7e3b1

Please sign in to comment.