-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathurdf_importer.gd
58 lines (37 loc) · 1.22 KB
/
urdf_importer.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# Implementation of importer plugin
@tool
class_name URDFImporter
extends EditorImportPlugin
func _get_importer_name():
return "urdf.importer"
func _get_visible_name():
return "URDF Importer"
func _get_recognized_extensions():
return ["urdf"]
func _get_save_extension() -> String:
return "tscn"
func _get_resource_type() -> String:
return "PackedScene"
func _import(source: String, save_path: String, options: Dictionary, platform_variants: Array, gen_files: Array) -> Error:
print("Importing URDF file: ", source)
var urdf_parser = URDFParser.new()
var root = urdf_parser.parse(source)
# Save the imported scene as a PackedScene resource
var packed_scene = PackedScene.new()
packed_scene.pack(root)
var p = save_path + "." + _get_save_extension()
var res = ResourceSaver.save(packed_scene, p)
print("URDF Saving: ", res, " to ", p)
var r = packed_scene.instantiate()
print(r.get_child_count())
return OK
func _get_import_options(opt: String, preset: int) -> Array[Dictionary]:
return [{"name": "switch_yz", "default_value": false}]
func _get_priority():
return 1
func _get_import_order():
return 0
func _get_preset_count():
return 1
func _get_preset_name(preset_id: int) -> String:
return "robot"