You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.5 KiB
GDScript

2 years ago
@tool
extends EditorImportPlugin
const VoxImporterCommon = preload("./vox-importer-common.gd");
func _init():
11 months ago
print('MagicaVoxel Mesh Importer: Ready')
2 years ago
func _get_importer_name():
11 months ago
return 'MagicaVoxel.With.Extensions.To.Mesh'
2 years ago
func _get_visible_name():
11 months ago
return 'MagicaVoxel Mesh'
2 years ago
func _get_recognized_extensions():
11 months ago
return [ 'vox' ]
2 years ago
func _get_resource_type():
11 months ago
return 'Mesh'
2 years ago
func _get_save_extension():
11 months ago
return 'mesh'
2 years ago
func _get_preset_count():
11 months ago
return 0
2 years ago
func _get_preset_name(_preset):
11 months ago
return 'Default'
2 years ago
func _get_import_order():
11 months ago
return 0
2 years ago
func _get_priority() -> float:
11 months ago
return 1.0
2 years ago
func _get_import_options(path, preset):
11 months ago
return [
{
'name': 'Scale',
'default_value': 0.1
},
{
'name': 'GreedyMeshGenerator',
'default_value': true
},
{
'name': 'SnapToGround',
'default_value': false
},
{
'name': 'FirstKeyframeOnly',
'default_value': true
}
]
2 years ago
func _get_option_visibility(path, option, options):
11 months ago
return true
2 years ago
func _import(source_path, destination_path, options, _platforms, _gen_files):
11 months ago
var meshes = VoxImporterCommon.new().import(source_path, destination_path, options, _platforms, _gen_files);
var full_path = "%s.%s" % [ destination_path, _get_save_extension() ]
var res = ResourceSaver.save(meshes[0], full_path)
Util.refresh_mesh_library([full_path])
return res