-
Notifications
You must be signed in to change notification settings - Fork 131
/
Copy pathDAELoader.cs
55 lines (41 loc) · 1.64 KB
/
DAELoader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
using System;
using System.IO;
using UnityEngine;
public class DAELoader {
/// <summary>
/// loads all meshes associated with the dae file
/// </summary>
/// <param name="data">should be the string contents of the dae file</param>
/// <param name="textures">a collection of the names of the textures associated with the meshes, if there are no texture or you do not care about them pass string[0]</param>
/// <returns></returns>
public static Mesh[] Load(string data, ref string[] textures) {
var Meshes = new Mesh[0];
ColladaLite cLite = null;
cLite = new ColladaLite(data);
Meshes = cLite.meshes.ToArray();
if (textures.Length > 0) {
textures = cLite.textureNames.ToArray();
}
return Meshes;
}
/// <summary>
/// loads all meshes associated with the dae file
/// </summary>
/// <param name="data">should be the path to the dae file</param>
/// <param name="textures">a collection of the names of the textures associated with the meshes, if there are no texture or you do not care about them pass string[0]</param>
/// <returns></returns>
public static Mesh[] LoadFromPath(string data, ref string[] textures) {
var Meshes = new Mesh[0];
ColladaLite cLite = null;
if (File.Exists(data)) {
cLite = new ColladaLite(File.ReadAllText(data));
} else {
throw new Exception("File not found at " + data);
}
Meshes = cLite.meshes.ToArray();
if (textures.Length > 0) {
textures = cLite.textureNames.ToArray();
}
return Meshes;
}
}