Sha256: 31dbf604045dec16846dc27d8019b46fbf532db6d712d9c7870d0a0b9629b6df

Contents?: true

Size: 1.75 KB

Versions: 4

Compression:

Stored size: 1.75 KB

Contents

#!/usr/bin/env ruby

# frozen_string_literal: true

require_relative '../lib/engine/importers/font_importer'
require_relative '../lib/engine/importers/obj_importer'
require_relative '../lib/engine/importers/obj_file'
require_relative '../lib/engine/path'
require_relative '../lib/engine/tangent_calculator'

require 'fileutils'
require "rmagick"
require "matrix"

assets_path = ARGV[0]

puts "importing assets from #{assets_path}"
FileUtils.mkdir_p(File.join(assets_path, '_imported'))

fonts = Dir.glob("#{assets_path}/**/*.ttf")
puts "found #{fonts.size} fonts"
fonts.each do |font|
  puts "importing #{font}"
  destination_image = (font.delete_prefix(assets_path)).gsub(/\.ttf$/, '.png')
  destination_font_metrics = (font.delete_prefix(assets_path)).gsub(/\.ttf$/, '.json')

  destination_path = File.join(assets_path, '_imported', destination_image)
  destination_font_metrics_file = File.join(assets_path, '_imported', destination_font_metrics)

  puts "  -> #{destination_path}, #{destination_font_metrics_file}"
  Engine::FontImporter.new(font, destination_path, destination_font_metrics_file).import
end

obj_files = Dir.glob("#{assets_path}/**/*.obj")
puts "found #{obj_files.size} obj files"
obj_files.each do |obj_file|
  puts "importing #{obj_file}"
  destination_vertex = (obj_file.delete_prefix(assets_path)).gsub(/\.obj$/, '.vertex_data')
  destination_index = (obj_file.delete_prefix(assets_path)).gsub(/\.obj$/, '.index_data')
  destination_vertex_path = File.join(assets_path, '_imported', destination_vertex)
  destination_index_path = File.join(assets_path, '_imported', destination_index)
  puts "  -> #{destination_vertex_path}, #{destination_index_path}"
  Engine::ObjImporter.new(obj_file.gsub(".obj", ""), destination_vertex_path, destination_index_path).import
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruby_rpg-0.0.4 bin/import
ruby_rpg-0.0.3 bin/import
ruby_rpg-0.0.2 bin/import
ruby_rpg-0.0.1 bin/import