51 lines
1.1 KiB
C#
51 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
using org.budnhead.core;
|
|
using org.budnhead.tools;
|
|
|
|
namespace org.budnhead.graphics
|
|
{
|
|
public class ModelManager
|
|
{
|
|
public static readonly ModelManager instance = new ModelManager();
|
|
|
|
Dictionary<string, Model3D> knownModels;
|
|
List<string> searchPaths;
|
|
|
|
protected ModelManager()
|
|
{
|
|
knownModels = new Dictionary<string, Model3D>();
|
|
searchPaths = new List<string>();
|
|
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];
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|