Browse Source

added resolveTexturePath

ncannasse 7 years ago
parent
commit
ce17c5ed6a
1 changed files with 9 additions and 4 deletions
  1. 9 4
      h3d/scene/World.hx

+ 9 - 4
h3d/scene/World.hx

@@ -165,6 +165,14 @@ class World extends Object {
 		return Alpha;
 	}
 
+	function resolveTexturePath( r : hxd.res.Model, path : String ) {
+		if( hxd.res.Loader.currentInstance.exists(path) )
+			return path;
+		var dir = r.entry.directory;
+		if( dir != "" ) dir += "/";
+		return dir + path.split("/").pop();
+	}
+
 	function resolveSpecularTexture( path : String ) : hxd.res.Image {
 		path =  path.substr(0, path.length - 4) + "spec.jpg";
 		try {
@@ -175,10 +183,7 @@ class World extends Object {
 	}
 
 	function loadMaterialTexture( r : hxd.res.Model, mat : hxd.fmt.hmd.Data.Material ) : WorldMaterial {
-		var texturePath = r.entry.directory;
-		if( texturePath != "" ) texturePath += "/";
-		texturePath += mat.diffuseTexture.split("/").pop();
-
+		var texturePath = resolveTexturePath(r, mat.diffuseTexture);
 		var m = textures.get(texturePath);
 		if( m != null )
 			return m;