using System; using System.Collections.Generic; namespace org.niclasundharald.engine.graphics { public class ModelManager { public static readonly ModelManager instance = new ModelManager(); Dictionary knownModels; List searchPaths; protected ModelManager() { knownModels = new Dictionary(); searchPaths = new List(); searchPaths.Add("."); } public void addSearchPath(string sPath){ searchPaths.Add(sPath); } public void removeSearchPath(string sPath){ searchPaths.Remove(sPath); } public Model3D loadModel(String mName,float scale){ string fullName = FileHelper.findFile(String.Format("{0}.obj",mName),searchPaths.ToArray()); if (fullName != null){ Console.WriteLine("Model found: {0}",fullName); return Model3D.loadObjFile(fullName,scale); } return null; } public Model3D findModel(String mName){ if (!knownModels.ContainsKey(mName)){ return loadModel(mName,1); } else { return knownModels[mName]; } } } }