Bläddra i källkod

renamed Model to FbxModel, added AwdModel (started)

ncannasse 11 år sedan
förälder
incheckning
00a41affd2
5 ändrade filer med 41 tillägg och 27 borttagningar
  1. 4 4
      hxd/res/Any.hx
  2. 9 0
      hxd/res/AwdModel.hx
  3. 1 1
      hxd/res/FbxModel.hx
  4. 3 1
      hxd/res/FileTree.hx
  5. 24 21
      hxd/res/Loader.hx

+ 4 - 4
hxd/res/Any.hx

@@ -27,12 +27,12 @@ class Any extends Resource {
 		this.loader = loader;
 	}
 	
-	public function toModel() {
-		return loader.loadModel(entry.path);
+	public function toFbx() {
+		return loader.loadFbxModel(entry.path).toFbx();
 	}
 	
-	public function toFbx() {
-		return loader.loadModel(entry.path).toFbx();
+	public function toAwd() {
+		return loader.loadAwdModel(entry.path);
 	}
 
 	public function toTexture() {

+ 9 - 0
hxd/res/AwdModel.hx

@@ -0,0 +1,9 @@
+package hxd.res;
+
+class AwdModel extends Resource {
+	
+	public function load() {
+		return false;
+	}
+	
+}

+ 1 - 1
hxd/res/Model.hx → hxd/res/FbxModel.hx

@@ -1,6 +1,6 @@
 package hxd.res;
 
-class Model extends Resource {
+class FbxModel extends Resource {
 	
 	public static var isLeftHanded = true;
 	

+ 3 - 1
hxd/res/FileTree.hx

@@ -311,7 +311,9 @@ class FileTree {
 		case "jpg", "png":
 			return { e : macro loader.loadImage($epath), t : macro : hxd.res.Image };
 		case "fbx", "xbx":
-			return { e : macro loader.loadModel($epath), t : macro : hxd.res.Model };
+			return { e : macro loader.loadFbxModel($epath), t : macro : hxd.res.FbxModel };
+		case "awd":
+			return { e : macro loader.loadAwdModel($epath), t : macro : hxd.res.AwdModel };
 		case "ttf":
 			return { e : macro loader.loadFont($epath), t : macro : hxd.res.Font };
 		case "fnt":

+ 24 - 21
hxd/res/Loader.hx

@@ -3,17 +3,11 @@ package hxd.res;
 class Loader {
 	
 	public var fs(default,null) : FileSystem;
-	var modelCache : Map<String,Model>;
-	var imageCache : Map<String,Image>;
-	var soundCache : Map<String,Sound>;
-	var fontCache : Map<String,BitmapFont>;
+	var cache : Map<String,Dynamic>;
 	
 	public function new(fs) {
 		this.fs = fs;
-		modelCache = new Map();
-		imageCache = new Map();
-		soundCache = new Map();
-		fontCache = new Map();
+		cache = new Map<String,Dynamic>();
 	}
 
 	public function exists( path : String ) : Bool {
@@ -24,29 +18,38 @@ class Loader {
 		return new Any(this, fs.get(path));
 	}
 	
-	function loadModel( path : String ) : Model {
-		var m = modelCache.get(path);
+	function loadFbxModel( path : String ) : FbxModel {
+		var m : FbxModel = cache.get(path);
 		if( m == null ) {
-			m = new Model(fs.get(path));
-			modelCache.set(path, m);
+			m = new FbxModel(fs.get(path));
+			cache.set(path, m);
+		}
+		return m;
+	}
+	
+	function loadAwdModel( path : String ) : AwdModel {
+		var m : AwdModel = cache.get(path);
+		if( m == null ) {
+			m = new AwdModel(fs.get(path));
+			cache.set(path, m);
 		}
 		return m;
 	}
 	
 	function loadImage( path : String ) : Image {
-		var t = imageCache.get(path);
-		if( t == null ) {
-			t = new Image(fs.get(path));
-			imageCache.set(path, t);
+		var i : Image = cache.get(path);
+		if( i == null ) {
+			i = new Image(fs.get(path));
+			cache.set(path, i);
 		}
-		return t;
+		return i;
 	}
 	
 	function loadSound( path : String ) : Sound {
-		var s = soundCache.get(path);
+		var s : Sound = cache.get(path);
 		if( s == null ) {
 			s = new Sound(fs.get(path));
-			soundCache.set(path, s);
+			cache.set(path, s);
 		}
 		return s;
 	}
@@ -57,10 +60,10 @@ class Loader {
 	}
 
 	function loadBitmapFont( path : String ) : BitmapFont {
-		var f = fontCache.get(path);
+		var f : BitmapFont = cache.get(path);
 		if( f == null ) {
 			f = new BitmapFont(this,fs.get(path));
-			fontCache.set(path, f);
+			cache.set(path, f);
 		}
 		return f;
 	}