프로젝트

일반

사용자정보

통계
| 개정판:

t1 / TFDContents / Assets / KinectScripts / AvatarControllerClassic.cs @ 3

이력 | 보기 | 이력해설 | 다운로드 (3.25 KB)

1
using UnityEngine;
2
//using Windows.Kinect;
3

    
4
using System;
5
using System.Collections;
6
using System.Collections.Generic;
7
using System.Runtime.InteropServices;
8
using System.IO;
9
using System.Text; 
10

    
11

    
12
/// <summary>
13
/// Avatar controller is the component that transfers the captured user motion to a humanoid model (avatar). Avatar controller classic allows manual assignment of model's rigged bones to the Kinect's tracked joints.
14
/// </summary>
15
public class AvatarControllerClassic : AvatarController
16
{	
17
	// Public variables that will get matched to bones. If empty, the Kinect will simply not track it.
18
	public Transform HipCenter;
19
	public Transform Spine;
20
	public Transform ShoulderCenter;
21
	public Transform Neck;
22
//	public Transform Head;
23

    
24
	public Transform ClavicleLeft;
25
	public Transform ShoulderLeft;
26
	public Transform ElbowLeft; 
27
	public Transform HandLeft;
28
	public Transform FingersLeft;
29
//	private Transform FingerTipsLeft = null;
30
	public Transform ThumbLeft;
31

    
32
	public Transform ClavicleRight;
33
	public Transform ShoulderRight;
34
	public Transform ElbowRight;
35
	public Transform HandRight;
36
	public Transform FingersRight;
37
//	private Transform FingerTipsRight = null;
38
	public Transform ThumbRight;
39
	
40
	public Transform HipLeft;
41
	public Transform KneeLeft;
42
	public Transform FootLeft;
43
//	private Transform ToesLeft = null;
44
	
45
	public Transform HipRight;
46
	public Transform KneeRight;
47
	public Transform FootRight;
48
//	private Transform ToesRight = null;
49

    
50
	[Tooltip("The body root node (optional).")]
51
	public Transform BodyRoot;
52

    
53
	// Offset node this transform is relative to, if any (optional)
54
	//public GameObject OffsetNode;
55

    
56

    
57
	// If the bones to be mapped have been declared, map that bone to the model.
58
	protected override void MapBones()
59
	{
60
		bones[0] = HipCenter;
61
		bones[1] = Spine;
62
		bones[2] = ShoulderCenter;
63
		bones[3] = Neck;
64
//		bones[4] = Head;
65
	
66
		bones[5] = ShoulderLeft;
67
		bones[6] = ElbowLeft;
68
		bones[7] = HandLeft;
69
//		bones[8] = FingersLeft;
70
//		bones[9] = FingerTipsLeft;
71
//		bones[10] = ThumbLeft;
72
	
73
		bones[11] = ShoulderRight;
74
		bones[12] = ElbowRight;
75
		bones[13] = HandRight;
76
//		bones[14] = FingersRight;
77
//		bones[15] = FingerTipsRight;
78
//		bones[16] = ThumbRight;
79
	
80
		bones[17] = HipLeft;
81
		bones[18] = KneeLeft;
82
		bones[19] = FootLeft;
83
//		bones[20] = ToesLeft;
84
	
85
		bones[21] = HipRight;
86
		bones[22] = KneeRight;
87
		bones[23] = FootRight;
88
//		bones[24] = ToesRight;
89

    
90
		// special bones
91
		bones[25] = ClavicleLeft;
92
		bones[26] = ClavicleRight;
93

    
94
		bones[27] = FingersLeft;
95
		bones[28] = FingersRight;
96
		bones[29] = ThumbLeft;
97
		bones[30] = ThumbRight;
98
		
99
		// body root and offset
100
		bodyRoot = BodyRoot;
101
		//offsetNode = OffsetNode;
102

    
103
//		if(offsetNode == null)
104
//		{
105
//			offsetNode = new GameObject(name + "Ctrl") { layer = transform.gameObject.layer, tag = transform.gameObject.tag };
106
//			offsetNode.transform.position = transform.position;
107
//			offsetNode.transform.rotation = transform.rotation;
108
//			offsetNode.transform.parent = transform.parent;
109
//			
110
//			transform.parent = offsetNode.transform;
111
//			transform.localPosition = Vector3.zero;
112
//			transform.localRotation = Quaternion.identity;
113
//		}
114

    
115
//		if(bodyRoot == null)
116
//		{
117
//			bodyRoot = transform;
118
//		}
119
	}
120
	
121
}
122