diff --git a/material_maker/panels/preview_3d/preview_3d.gd b/material_maker/panels/preview_3d/preview_3d.gd index ef691b1fc..457d600cd 100644 --- a/material_maker/panels/preview_3d/preview_3d.gd +++ b/material_maker/panels/preview_3d/preview_3d.gd @@ -110,7 +110,9 @@ func do_load_custom_mesh(file_path) -> void: mm_globals.config.set_value("path", "mesh", file_path.get_base_dir()) var id = objects.get_child_count()-1 #var mesh = $ObjLoader.load_obj_file(file_path) - var mesh = load(file_path) + var mesh : Mesh = null + var obj_loader = load("res://material_maker/tools/obj_loader/obj_loader.gd") + mesh = obj_loader.load_obj_file(file_path) if mesh != null: var object : MeshInstance3D = objects.get_child(id) object.mesh = mesh diff --git a/material_maker/tools/obj_loader/obj_loader.gd b/material_maker/tools/obj_loader/obj_loader.gd index deae2b7d8..f8e3bc2de 100644 --- a/material_maker/tools/obj_loader/obj_loader.gd +++ b/material_maker/tools/obj_loader/obj_loader.gd @@ -1,9 +1,6 @@ -extends Node +extends Object -func _ready(): - pass # Replace with function body. - -func load_obj_file(path : String) -> ArrayMesh: +static func load_obj_file(path : String) -> ArrayMesh: if path == null: return null var ext := path.get_extension() @@ -53,7 +50,7 @@ func load_obj_file(path : String) -> ArrayMesh: return mdl -func _obj_rel_indice(indice : Vector3, cur_vArr_size : int) -> Vector3: +static func _obj_rel_indice(indice : Vector3, cur_vArr_size : int) -> Vector3: var output := Vector3.ZERO var indSign := indice.sign() output.x = indice.x - 1 if (indSign.x >= 0) else cur_vArr_size + indice.x @@ -62,7 +59,7 @@ func _obj_rel_indice(indice : Vector3, cur_vArr_size : int) -> Vector3: return output -func _import_obj(mdlFile : FileAccess) -> TriMesh: +static func _import_obj(mdlFile : FileAccess) -> TriMesh: var newMsh := TriMesh.new() while !mdlFile.eof_reached():