Skip to content

Commit

Permalink
Support more embedded textures.
Browse files Browse the repository at this point in the history
  • Loading branch information
SamuelTallet committed Jan 12, 2020
1 parent bf07b8d commit e99a88f
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 8 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.0.8'.freeze
VERSION = '1.0.9'.freeze

# Load translation if it's available for current locale.
TRANSLATE = LanguageHandler.new('uir.strings')
Expand Down
7 changes: 7 additions & 0 deletions source/universal_importer/Resources/es/uir.strings
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@

"Import with"="Importar con";

//
// File: model_observer.rb
//

"Face count before reduction:"="Número de caras antes reducción:";
"Face count after reduction:"="Número de caras después reducción:";

//
// File: polyreducer.rb
//
Expand Down
7 changes: 7 additions & 0 deletions source/universal_importer/Resources/fr/uir.strings
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@

"Import with"="Importer avec";

//
// File: model_observer.rb
//

"Face count before reduction:"="Nombre de faces avant réduction :";
"Face count after reduction:"="Nombre de faces après réduction :";

//
// File: polyreducer.rb
//
Expand Down
14 changes: 9 additions & 5 deletions source/universal_importer/importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def ask_for_poly_reduction
@poly_reduction_params = UI.inputbox(

[ TRANSLATE['Target face number'] + ' ' ], # Prompt
[ 60000 ], # Default
[ 40000 ], # Default
TRANSLATE['Polygon Reduction'] + ' - ' + NAME # Title

)
Expand Down Expand Up @@ -265,7 +265,7 @@ def export_to_obj_format

end

# Fixes embedded textures in OBJ export?
# Fixes embedded textures in Assimp OBJ export?
#
# @return [nil]
def fix_e_tex_in_obj_export
Expand All @@ -282,7 +282,11 @@ def fix_e_tex_in_obj_export
File.join(SESSION[:temp_dir], 'assimp.log')
)

for texture_index in 0..9
texture_index = 1000

1000.times do

texture_index -= 1

next if !obj_mtl_export.include?('*' + texture_index.to_s)

Expand Down Expand Up @@ -323,7 +327,7 @@ def fix_e_tex_in_obj_export

end

# Fixes texture atlas in OBJ export?
# Fixes texture atlas in Assimp OBJ export?
#
# @return [nil]
def fix_atlas_in_obj_export
Expand All @@ -345,7 +349,7 @@ def fix_atlas_in_obj_export

end

# Applies polygon reduction on OBJ export.
# Applies polygon reduction on Assimp OBJ export.
#
# @return [nil]
def apply_polygon_reduction
Expand Down
20 changes: 20 additions & 0 deletions source/universal_importer/model_observer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ModelObserver < Sketchup::ModelObserver
# When a component is “placed” into the model:
def onPlaceComponent(component)

# Scales component according to user input.
if !SESSION[:model_height_in_cm].nil?

Components.scale_down(component, SESSION[:model_height_in_cm])
Expand All @@ -42,6 +43,7 @@ def onPlaceComponent(component)

end

# Names component with source filename.
if !SESSION[:source_filename].nil?

component.definition.name = SESSION[:source_filename]
Expand All @@ -50,6 +52,24 @@ def onPlaceComponent(component)

end

# Displays face count before/after reduction.
if !SESSION[:faces_num_before_reduc].nil?

UI.messagebox(

TRANSLATE['Face count before reduction:'] + ' ' +
SESSION[:faces_num_before_reduc].to_s + "\n" +

TRANSLATE['Face count after reduction:'] + ' ' +
(Sketchup.active_model.number_faces\
- SESSION[:faces_num_before_reduc]).to_s

)

SESSION[:faces_num_before_reduc] = nil

end

end

end
Expand Down
17 changes: 15 additions & 2 deletions source/universal_importer/polyreducer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def initialize
# Aborts if user cancelled operation.
return if @poly_reduction_params == false

face_count_before_reduc

reset_prog_data_tmp_dir

convert_from_skp_to_dae
Expand Down Expand Up @@ -116,15 +118,26 @@ def get_poly_reduc_params
@poly_reduction_params = UI.inputbox(

[ TRANSLATE['Target face number'] + ' ' ], # Prompt
[ 60000 ], # Default
TRANSLATE['Polygon Reduction'] + ' - ' + NAME # Title
[ 40000 ], # Default
TRANSLATE['Polygon Reduction'] # Title

)

nil

end

# Memorizes face count before polygon reduction.
#
# @return nil
def face_count_before_reduc

SESSION[:faces_num_before_reduc] = Sketchup.active_model.number_faces

nil

end

# Resets Universal Importer program data temporary directory.
#
# @return [nil]
Expand Down

0 comments on commit e99a88f

Please sign in to comment.