CustomSkeletonHelper.cs
3.06 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
//======= Copyright (c) Valve Corporation, All rights reserved. ===============
using UnityEngine;
using System.Collections;
using Valve.VR;
using UnityEngine.Serialization;
namespace Valve.VR.InteractionSystem.Sample
{
public class CustomSkeletonHelper : MonoBehaviour
{
public Retargetable wrist;
public Finger[] fingers;
public Thumb[] thumbs;
private void Update()
{
for (int fingerIndex = 0; fingerIndex < fingers.Length; fingerIndex++)
{
Finger finger = fingers[fingerIndex];
finger.metacarpal.destination.rotation = finger.metacarpal.source.rotation;
finger.proximal.destination.rotation = finger.proximal.source.rotation;
finger.middle.destination.rotation = finger.middle.source.rotation;
finger.distal.destination.rotation = finger.distal.source.rotation;
}
for (int thumbIndex = 0; thumbIndex < thumbs.Length; thumbIndex++)
{
Thumb thumb = thumbs[thumbIndex];
thumb.metacarpal.destination.rotation = thumb.metacarpal.source.rotation;
thumb.middle.destination.rotation = thumb.middle.source.rotation;
thumb.distal.destination.rotation = thumb.distal.source.rotation;
}
wrist.destination.position = wrist.source.position;
wrist.destination.rotation = wrist.source.rotation;
}
public enum MirrorType
{
None,
LeftToRight,
RightToLeft
}
[System.Serializable]
public class Retargetable
{
public Transform source;
public Transform destination;
public Retargetable(Transform source, Transform destination)
{
this.source = source;
this.destination = destination;
}
}
[System.Serializable]
public class Thumb
{
public Retargetable metacarpal;
public Retargetable middle;
public Retargetable distal;
public Transform aux;
public Thumb(Retargetable metacarpal, Retargetable middle, Retargetable distal, Transform aux)
{
this.metacarpal = metacarpal;
this.middle = middle;
this.distal = distal;
this.aux = aux;
}
}
[System.Serializable]
public class Finger
{
public Retargetable metacarpal;
public Retargetable proximal;
public Retargetable middle;
public Retargetable distal;
public Transform aux;
public Finger(Retargetable metacarpal, Retargetable proximal, Retargetable middle, Retargetable distal, Transform aux)
{
this.metacarpal = metacarpal;
this.proximal = proximal;
this.middle = middle;
this.distal = distal;
this.aux = aux;
}
}
}
}