glTF_VRM_FirstPerson.cs
4.12 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using System;
using System.Collections.Generic;
using UniGLTF;
using UnityEngine;
using UniJSON;
namespace VRM
{
[Serializable]
[JsonSchema(Title = "vrm.firstperson.degreemap")]
public class glTF_VRM_DegreeMap : UniGLTF.JsonSerializableBase
{
[JsonSchema(Description = "None linear mapping params. time, value, inTangent, outTangent")]
public float[] curve;
[JsonSchema(Description = "Look at input clamp range degree.")]
public float xRange = 90.0f;
[JsonSchema(Description = "Look at map range degree from xRange.")]
public float yRange = 10.0f;
protected override void SerializeMembers(GLTFJsonFormatter f)
{
if (curve != null)
{
f.KeyValue(() => curve);
}
f.KeyValue(() => xRange);
f.KeyValue(() => yRange);
}
}
public enum FirstPersonFlag
{
Auto, // Create headlessModel
Both, // Default layer
ThirdPersonOnly,
FirstPersonOnly,
}
[Serializable]
[JsonSchema(Title = "vrm.firstperson.meshannotation")]
public class glTF_VRM_MeshAnnotation : JsonSerializableBase
{
// When the value is -1, it means that no target mesh is found.
[JsonSchema(Minimum = 0)]
public int mesh;
public string firstPersonFlag;
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => mesh);
f.KeyValue(() => firstPersonFlag);
}
}
public enum LookAtType
{
None,
Bone,
BlendShape,
}
[Serializable]
[JsonSchema(Title = "vrm.firstperson")]
public class glTF_VRM_Firstperson : UniGLTF.JsonSerializableBase
{
// When the value is -1, it means that no bone for first person is found.
[JsonSchema(Description = "The bone whose rendering should be turned off in first-person view. Usually Head is specified.", Minimum = 0, ExplicitIgnorableValue = -1)]
public int firstPersonBone = -1;
[JsonSchema(Description = @"The target position of the VR headset in first-person view. It is assumed that an offset from the head bone to the VR headset is added.")]
public Vector3 firstPersonBoneOffset;
[JsonSchema(Description = "Switch display / undisplay for each mesh in first-person view or the others.")]
public List<glTF_VRM_MeshAnnotation> meshAnnotations = new List<glTF_VRM_MeshAnnotation>();
// lookat
[JsonSchema(Description = "Eye controller mode.", EnumValues = new object[] {
"Bone",
"BlendShape",
}, EnumSerializationType = EnumSerializationType.AsString)]
public string lookAtTypeName = "Bone";
public LookAtType lookAtType
{
get
{
return EnumUtil.TryParseOrDefault<LookAtType>(lookAtTypeName);
}
set { lookAtTypeName = value.ToString(); }
}
[JsonSchema(Description = "Eye controller setting.")]
public glTF_VRM_DegreeMap lookAtHorizontalInner = new glTF_VRM_DegreeMap();
[JsonSchema(Description = "Eye controller setting.")]
public glTF_VRM_DegreeMap lookAtHorizontalOuter = new glTF_VRM_DegreeMap();
[JsonSchema(Description = "Eye controller setting.")]
public glTF_VRM_DegreeMap lookAtVerticalDown = new glTF_VRM_DegreeMap();
[JsonSchema(Description = "Eye controller setting.")]
public glTF_VRM_DegreeMap lookAtVerticalUp = new glTF_VRM_DegreeMap();
protected override void SerializeMembers(GLTFJsonFormatter f)
{
f.KeyValue(() => firstPersonBone);
f.KeyValue(() => firstPersonBoneOffset);
f.Key("meshAnnotations"); f.GLTFValue(meshAnnotations);
f.KeyValue(() => lookAtTypeName);
f.Key("lookAtHorizontalInner"); f.GLTFValue(lookAtHorizontalInner);
f.Key("lookAtHorizontalOuter"); f.GLTFValue(lookAtHorizontalOuter);
f.Key("lookAtVerticalDown"); f.GLTFValue(lookAtVerticalDown);
f.Key("lookAtVerticalUp"); f.GLTFValue(lookAtVerticalUp);
}
}
}