2019-05-09 22:38:50 +02:00
|
|
|
package arm.util;
|
|
|
|
|
|
2019-06-20 12:30:31 +02:00
|
|
|
using StringTools;
|
|
|
|
|
|
2019-05-09 22:38:50 +02:00
|
|
|
class Path {
|
|
|
|
|
|
|
|
|
|
public static function toRelative(from:String, to:String):String {
|
|
|
|
|
from = haxe.io.Path.normalize(from);
|
|
|
|
|
to = haxe.io.Path.normalize(to);
|
|
|
|
|
var a = from.split("/");
|
|
|
|
|
var b = to.split("/");
|
|
|
|
|
while (a[0] == b[0]) {
|
|
|
|
|
a.shift();
|
|
|
|
|
b.shift();
|
|
|
|
|
if (a.length == 0 || b.length == 0) break;
|
|
|
|
|
}
|
|
|
|
|
var base = "";
|
|
|
|
|
for (i in 0...a.length - 1) base += "../";
|
|
|
|
|
base += b.join("/");
|
|
|
|
|
return haxe.io.Path.normalize(base);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function baseDir(path:String):String {
|
|
|
|
|
path = haxe.io.Path.normalize(path);
|
|
|
|
|
var base = path.substr(0, path.lastIndexOf("/") + 1);
|
2019-06-16 21:42:58 +02:00
|
|
|
#if krom_windows
|
|
|
|
|
base = base.substr(0, 2) + "\\" + base.substr(3);
|
|
|
|
|
#end
|
2019-05-09 22:38:50 +02:00
|
|
|
return base;
|
|
|
|
|
}
|
2019-06-19 22:42:17 +02:00
|
|
|
|
|
|
|
|
public static function checkMeshFormat(path:String):Bool {
|
|
|
|
|
var p = path.toLowerCase();
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith(".obj") ||
|
|
|
|
|
p.endsWith(".fbx") ||
|
|
|
|
|
p.endsWith(".blend") ||
|
|
|
|
|
p.endsWith(".gltf");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkTextureFormat(path:String):Bool {
|
|
|
|
|
var p = path.toLowerCase();
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith(".jpg") ||
|
|
|
|
|
p.endsWith(".png") ||
|
|
|
|
|
p.endsWith(".tga") ||
|
|
|
|
|
p.endsWith(".hdr");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkFontFormat(path:String):Bool {
|
|
|
|
|
var p = path.toLowerCase();
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith(".ttf");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkProjectFormat(path:String):Bool {
|
|
|
|
|
var p = path.toLowerCase();
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith(".arm");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkBaseTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_albedo") ||
|
|
|
|
|
p.endsWith("_alb") ||
|
|
|
|
|
p.endsWith("_basecol") ||
|
|
|
|
|
p.endsWith("_basecolor") ||
|
|
|
|
|
p.endsWith("_diffuse") ||
|
|
|
|
|
p.endsWith("_diff") ||
|
|
|
|
|
p.endsWith("_base") ||
|
|
|
|
|
p.endsWith("_bc") ||
|
|
|
|
|
p.endsWith("_d") ||
|
|
|
|
|
p.endsWith("_color") ||
|
|
|
|
|
p.endsWith("_col");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkOpacTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_opac") ||
|
|
|
|
|
p.endsWith("_alpha") ||
|
|
|
|
|
p.endsWith("_opacity") ||
|
|
|
|
|
p.endsWith("_mask");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkNorTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_normal") ||
|
|
|
|
|
p.endsWith("_nor") ||
|
|
|
|
|
p.endsWith("_n") ||
|
|
|
|
|
p.endsWith("_nrm");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkOccTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_ao") ||
|
|
|
|
|
p.endsWith("_occlusion") ||
|
|
|
|
|
p.endsWith("_o") ||
|
|
|
|
|
p.endsWith("_occ");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkRoughTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_roughness") ||
|
|
|
|
|
p.endsWith("_roug") ||
|
|
|
|
|
p.endsWith("_r") ||
|
|
|
|
|
p.endsWith("_rough") ||
|
|
|
|
|
p.endsWith("_rgh");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkMetTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_metallic") ||
|
|
|
|
|
p.endsWith("_metal") ||
|
|
|
|
|
p.endsWith("_metalness") ||
|
|
|
|
|
p.endsWith("_m") ||
|
|
|
|
|
p.endsWith("_met");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function checkDispTex(p:String):Bool {
|
2019-06-20 12:30:31 +02:00
|
|
|
return p.endsWith("_displacement") ||
|
|
|
|
|
p.endsWith("_height") ||
|
|
|
|
|
p.endsWith("_h") ||
|
|
|
|
|
p.endsWith("_disp");
|
2019-06-19 22:42:17 +02:00
|
|
|
}
|
2019-05-09 22:38:50 +02:00
|
|
|
}
|