Skip to content

Commit

Permalink
Use static funcs so no ObjParse instance is needed
Browse files Browse the repository at this point in the history
also update the README accordingly
  • Loading branch information
kb173 committed Jul 13, 2021
1 parent c263f88 commit 38e8b1c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@ As of Godot 3.2, Godot is unable to import `.obj` files outside of the `res://`
gd-obj allows either or both of these features. gd-obj supports uvs, faces, normals, and non triangulated meshes.

## How to use?
Create a new instance of `ObjParse`.
Call `.parse_file(path_to_file)` or `.parse_str(str_content)` from it. It will return a `Mesh` instance.
Call `ObjParse.parse_file(path_to_obj, path_to_mtl)`. This will return a `Mesh` which can, for example, be placed into the `mesh` field of a `MeshInstance`.
7 changes: 4 additions & 3 deletions addons/obj-parse/ObjParse.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extends Node
class_name ObjParse

# Obj parser made by Ezcha
# Created on 7/11/2018
Expand All @@ -8,7 +9,7 @@ extends Node
# https://github.com/Ezcha/gd-obj/blob/master/LICENSE

# Returns an array of materials from a MTL file
func _parse_mtl_file(path):
static func _parse_mtl_file(path):
print("Parsing mtl file " + path)
var file = File.new()
file.open(path, File.READ)
Expand Down Expand Up @@ -51,7 +52,7 @@ func _parse_mtl_file(path):

return mats

func _get_texture(mtl_filepath, tex_filename):
static func _get_texture(mtl_filepath, tex_filename):
print(" Debug: Mapping texture file " + tex_filename)
var texfilepath = mtl_filepath.get_base_dir() + "/" + tex_filename
var filetype = texfilepath.get_extension()
Expand All @@ -63,7 +64,7 @@ func _get_texture(mtl_filepath, tex_filename):
print(" Debug: texture is " + str(tex))
return tex

func parse_obj(obj_path, mtl_path):
static func parse_obj(obj_path, mtl_path):
var file = File.new()
file.open(obj_path, File.READ)
var obj = file.get_as_text()
Expand Down

0 comments on commit 38e8b1c

Please sign in to comment.