forked from neil3d/Unity-glTF-Exporter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGlTF_Primitive.cs
38 lines (34 loc) · 968 Bytes
/
GlTF_Primitive.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
#if UNITY_EDITOR
using UnityEngine;
using System.Collections;
public class GlTF_Primitive : GlTF_Writer {
public GlTF_Attributes attributes = new GlTF_Attributes();
public GlTF_Accessor indices;
public int materialIndex;
public int primitive = 4;
public int semantics = 4;
public int index = 0;
public static string GetNameFromObject(Object o, int index)
{
return "primitive_" + index + "_" + GlTF_Writer.GetNameFromObject(o, true);
}
public void Populate (Mesh m)
{
// attributes.Populate (m);
indices.Populate (m.GetTriangles(index), true);
}
public override void Write ()
{
IndentIn();
CommaNL();
if (attributes != null)
attributes.Write();
CommaNL();
Indent(); jsonWriter.Write ("\"indices\": " + GlTF_Writer.accessors.IndexOf(indices) + ",\n");
Indent(); jsonWriter.Write ("\"material\": " + materialIndex + ",\n");
Indent(); jsonWriter.Write ("\"mode\": " + primitive + "\n");
// semantics
IndentOut();
}
}
#endif