質問編集履歴
2
エラーについて追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,6 +14,14 @@
|
|
14
14
|
|
15
15
|
|
16
16
|
|
17
|
+
このようなエラーも出ます。Vector3が問題なのはわかるのですが…
|
18
|
+
|
19
|
+
NullReferenceException: Object reference not set to an instance of an object
|
20
|
+
|
21
|
+
RiggedFinger.Update () (at Assets/LeapMotion/Scripts/Hands/RiggedFinger.cs:77)
|
22
|
+
|
23
|
+
|
24
|
+
|
17
25
|
```C#
|
18
26
|
|
19
27
|
using UnityEngine;
|
@@ -386,13 +394,11 @@
|
|
386
394
|
|
387
395
|
|
388
396
|
|
389
|
-
|
397
|
+
|
390
398
|
|
391
399
|
Vector3 stop = new Vector3(palm.position.x, palm.position.y, palm.position.z);
|
392
400
|
|
393
|
-
|
401
|
+
|
394
|
-
|
395
|
-
//Vector3 newStop = GetPalmNormal();
|
396
402
|
|
397
403
|
Quaternion stop1 = GetPalmRotation() * Reorientation();
|
398
404
|
|
1
コード追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -10,12 +10,150 @@
|
|
10
10
|
|
11
11
|
|
12
12
|
|
13
|
-
先輩からの引継ぎで、今は直接質問できないのでここで質問させていただきます。どこに問題があるのか見当がつかないのでとりあえず直接関わりがありそうなコードを
|
13
|
+
先輩からの引継ぎで、今は直接質問できないのでここで質問させていただきます。どこに問題があるのか見当がつかないのでとりあえず直接関わりがありそうなコードを貼りました。判断材料が足りないようでしたら適宜追加します。どうぞよろしくお願いいたします。
|
14
14
|
|
15
15
|
|
16
16
|
|
17
17
|
```C#
|
18
18
|
|
19
|
+
using UnityEngine;
|
20
|
+
|
21
|
+
using System.Collections;
|
22
|
+
|
23
|
+
using Leap;
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
public class RiggedFinger : FingerModel
|
28
|
+
|
29
|
+
{
|
30
|
+
|
31
|
+
public bool deformPosition = false;
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
public Vector3 modelFingerPointing = Vector3.forward;
|
36
|
+
|
37
|
+
public Vector3 modelPalmFacing = -Vector3.up;
|
38
|
+
|
39
|
+
private GameObject centerObj;
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
public Quaternion Reorientation()
|
44
|
+
|
45
|
+
{
|
46
|
+
|
47
|
+
return Quaternion.Inverse(Quaternion.LookRotation(modelFingerPointing, -modelPalmFacing));
|
48
|
+
|
49
|
+
}
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
/** Updates the bone rotations. */
|
54
|
+
|
55
|
+
public override void UpdateFinger()
|
56
|
+
|
57
|
+
{
|
58
|
+
|
59
|
+
for (int i = 0; i < bones.Length; ++i)
|
60
|
+
|
61
|
+
{
|
62
|
+
|
63
|
+
if (bones[i] != null)
|
64
|
+
|
65
|
+
{
|
66
|
+
|
67
|
+
bones[i].rotation = GetBoneRotation(i) * Reorientation();
|
68
|
+
|
69
|
+
if (deformPosition)
|
70
|
+
|
71
|
+
{
|
72
|
+
|
73
|
+
bones[i].position = GetBoneCenter(i);
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
}
|
80
|
+
|
81
|
+
}
|
82
|
+
|
83
|
+
private void Start()
|
84
|
+
|
85
|
+
{
|
86
|
+
|
87
|
+
print("2");
|
88
|
+
|
89
|
+
centerObj = GameObject.Find("Brush1"); //試しのコメントアウト
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
centerObj.transform.position = new Vector3(centerObj.transform.position.x, centerObj.transform.position.y, centerObj.transform.position.z);
|
94
|
+
|
95
|
+
}
|
96
|
+
|
97
|
+
public void Update()
|
98
|
+
|
99
|
+
{
|
100
|
+
|
101
|
+
Hand righthand = GetLeapHand();
|
102
|
+
|
103
|
+
//print(111);
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
if (righthand.IsRight)
|
108
|
+
|
109
|
+
{
|
110
|
+
|
111
|
+
Finger finger = GetLeapFinger();
|
112
|
+
|
113
|
+
Finger.FingerType fType = fingerType;
|
114
|
+
|
115
|
+
if (fType == Finger.FingerType.TYPE_INDEX)
|
116
|
+
|
117
|
+
{
|
118
|
+
|
119
|
+
Vector3 pencilposition = this.bones[3].position;
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
Quaternion pencilrotation = GetBoneRotation(3) * Reorientation();
|
124
|
+
|
125
|
+
pencilrotation = Quaternion.Euler(20, 0, 80);
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
Vector3 position = this.centerObj.transform.position;
|
132
|
+
|
133
|
+
centerObj.transform.position = new Vector3(pencilposition.x, pencilposition.y, pencilposition.z);
|
134
|
+
|
135
|
+
centerObj.transform.rotation = new Quaternion(pencilrotation.w, pencilrotation.x, pencilrotation.y, pencilrotation.z);
|
136
|
+
|
137
|
+
}
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
}
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
```C#
|
156
|
+
|
19
157
|
RiggedHand.cs
|
20
158
|
|
21
159
|
using UnityEngine;
|