Skip to content

Commit

Permalink
try to fit mat by idx if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
deakcor committed Dec 4, 2021
1 parent 2888eb7 commit b4ffc57
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion obj-parse/ObjParse.gd
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ static func _create_obj(obj:String,mats:Dictionary)->Mesh:

var firstSurface = true
var mat_name := "default"

var count_mtl:=0

# Parse
var lines = obj.split("\n", false)
for line in lines:
Expand All @@ -173,11 +174,19 @@ static func _create_obj(obj:String,mats:Dictionary)->Mesh:
uvs.append(n_uv)
"usemtl":
# Material group
count_mtl+=1
mat_name = parts[1]
if(not faces.has(mat_name)):
var mats_keys:=mats.keys()
if !mats.has(mat_name):
if mats_keys.size()>count_mtl:
mat_name=mats_keys[count_mtl]
faces[mat_name] = []
"f":
if(not faces.has(mat_name)):
var mats_keys:=mats.keys()
if mats_keys.size()>count_mtl:
mat_name=mats_keys[count_mtl]
faces[mat_name] = []
# Face
if (parts.size() == 4):
Expand Down

0 comments on commit b4ffc57

Please sign in to comment.