diff options
author | rodgersgb <[email protected]> | 2008-04-29 19:49:13 +0000 |
---|---|---|
committer | rodgersgb <[email protected]> | 2008-04-29 19:49:13 +0000 |
commit | 30fadee2f591d5b80558ef9defd2ec271ad3af5a (patch) | |
tree | c0ce5aa20fbf7526eee1f0ec03a58e119c48420a /src/net/java/joglutils/model/loader/LoaderFactory.java | |
parent | 273f6cd707d1805fe42025e65556875526a4a96f (diff) |
Added a folder remotely
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/joglutils/trunk@87 83d24430-9974-4f80-8418-2cc3294053b9
Diffstat (limited to 'src/net/java/joglutils/model/loader/LoaderFactory.java')
-rw-r--r-- | src/net/java/joglutils/model/loader/LoaderFactory.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/src/net/java/joglutils/model/loader/LoaderFactory.java b/src/net/java/joglutils/model/loader/LoaderFactory.java new file mode 100644 index 0000000..59a680f --- /dev/null +++ b/src/net/java/joglutils/model/loader/LoaderFactory.java @@ -0,0 +1,62 @@ +/*
+ * LoaderFactory.java
+ *
+ * Created on February 27, 2008, 10:35 PM
+ *
+ * To change this template, choose Tools | Template Manager
+ * and open the template in the editor.
+ */
+
+package net.java.joglutils.model.loader;
+
+import net.java.joglutils.model.ModelLoadException;
+import net.java.joglutils.model.geometry.Model;
+
+/**
+ *
+ * @author Brian Wood
+ */
+public class LoaderFactory {
+ private static final int FILETYPE_UNKNOWN = -1;
+ private static final int FILETYPE_3DS = 1;
+ private static final int FILETYPE_OBJ = 2;
+
+ public static Model load(String source) throws ModelLoadException {
+ iLoader loader = getLoader(source);
+ if (loader == null)
+ return null;
+
+ return loader.load(source);
+ }
+
+ private static iLoader getLoader(String path) {
+ switch(determineFiletype(path)) {
+ case FILETYPE_3DS:
+ return new MaxLoader();
+
+ case FILETYPE_OBJ:
+ return new WaveFrontLoader();
+
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * Parses the file suffix to determine what file format the model is in.
+ *
+ * @param path File path info
+ * @returns int Constant indicating file type
+ */
+ private static int determineFiletype(String path) {
+ int type = FILETYPE_UNKNOWN;
+ String tokens[] = path.split("\\.");
+
+ if(tokens[tokens.length - 1].equals("3ds"))
+ type = FILETYPE_3DS;
+ else if(tokens[tokens.length - 1].equals("obj"))
+ type = FILETYPE_OBJ;
+
+ return type;
+ }
+}
|