public Dictionary <string, int> GetMaterialsList(string fileName) { Dictionary <string, ModelBase.MaterialDef> materials = new Dictionary <string, ModelBase.MaterialDef>(); string modelFormat = fileName.Substring(fileName.Length - 3, 3).ToLower(); switch (modelFormat) { case "obj": materials = new OBJLoader(fileName).GetModelMaterials(); break; case "dae": materials = new DAELoader(fileName).GetModelMaterials(); break; case "imd": materials = new NITROIntermediateModelDataLoader(fileName).GetModelMaterials(); break; default: materials = new OBJLoader(fileName).GetModelMaterials(); break; } Dictionary <string, int> matColTypes = new Dictionary <string, int>(); foreach (string key in materials.Keys) { matColTypes.Add(key, 0); } return(matColTypes); }
public static BCA ConvertAnimatedDAEToBCA(ref NitroFile animationFile, string fileName, BMDImporter.BCAImportationOptions bcaImportationOptions, bool save = true) { ModelBase loadedModel = new DAELoader(fileName).LoadModel(); BCA importedAnimation = CallBCAWriter(ref animationFile, loadedModel, bcaImportationOptions, save); return(importedAnimation); }
public static KCL ConvertDAEToKCL(NitroFile modelFile, string fileName, float scale, float faceSizeThreshold, Dictionary <string, int> matColTypes, bool save = true) { KCL importedModel = new KCL(modelFile); ModelBase loadedModel = new DAELoader(fileName).LoadModel(); importedModel = CallKCLWriter(modelFile, loadedModel, scale, faceSizeThreshold, matColTypes, save); return(importedModel); }
public static BMD ConvertDAEToBMD(ref NitroFile modelFile, string fileName, float scale, BMDExtraImportOptions extraOptions, bool save = true) { BMD importedModel = new BMD(modelFile); ModelBase loadedModel = new DAELoader(fileName).LoadModel(scale); importedModel = CallBMDWriter(ref modelFile, loadedModel, extraOptions, save); return(importedModel); }
// Default mesh loading function that can // load STLs from file public static void LoadMesh(string path, System.Action <Mesh[], Material[]> done) { string fileType = Path.GetExtension(path).ToLower().Replace(".", ""); if (fileType == "stl") { print("building stl file " + path); done(StlLoader.Load(path), null); } else if (fileType == "dae") { print("building dae file " + path); var empty = new string[0]; done(DAELoader.Load(path, ref empty), null); } else { throw new System.Exception("Filetype '" + fileType + "' not supported"); } }
// Default mesh loading function that can // load STLs from file public static void LoadMesh(string path, string ext, Action <GameObject[]> done) { Mesh[] meshes = null; if (ext == "stl") { print("building stl file " + path); meshes = StlLoader.Load(path); } else if (ext == "dae") { print("building dae file " + path); var empty = new string[0]; meshes = DAELoader.LoadFromPath(path, ref empty); } if (meshes == null) { throw new Exception("Filetype '" + ext + "' not supported"); } else { GameObject[] res = new GameObject[meshes.Length]; for (int i = 0; i < meshes.Length; i++) { var mesh = meshes[i]; Renderer r = GameObject .CreatePrimitive(PrimitiveType.Cube) .GetComponent <Renderer>(); r.GetComponent <MeshFilter>().mesh = mesh; res[i] = r.gameObject; } done(res); } }