Showing
242 changed files
with
1232 additions
and
0 deletions
... | @@ -68,3 +68,5 @@ crashlytics-build.properties | ... | @@ -68,3 +68,5 @@ crashlytics-build.properties |
68 | # Temporary auto-generated Android Assets | 68 | # Temporary auto-generated Android Assets |
69 | /[Aa]ssets/[Ss]treamingAssets/aa.meta | 69 | /[Aa]ssets/[Ss]treamingAssets/aa.meta |
70 | /[Aa]ssets/[Ss]treamingAssets/aa/* | 70 | /[Aa]ssets/[Ss]treamingAssets/aa/* |
71 | + | ||
72 | +*.meta | ||
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!21 &2100000 | ||
4 | +Material: | ||
5 | + serializedVersion: 6 | ||
6 | + m_ObjectHideFlags: 0 | ||
7 | + m_CorrespondingSourceObject: {fileID: 0} | ||
8 | + m_PrefabInstance: {fileID: 0} | ||
9 | + m_PrefabAsset: {fileID: 0} | ||
10 | + m_Name: clothingSet_04_tex | ||
11 | + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} | ||
12 | + m_ShaderKeywords: | ||
13 | + m_LightmapFlags: 4 | ||
14 | + m_EnableInstancingVariants: 0 | ||
15 | + m_DoubleSidedGI: 0 | ||
16 | + m_CustomRenderQueue: -1 | ||
17 | + stringTagMap: {} | ||
18 | + disabledShaderPasses: [] | ||
19 | + m_SavedProperties: | ||
20 | + serializedVersion: 3 | ||
21 | + m_TexEnvs: | ||
22 | + - _BumpMap: | ||
23 | + m_Texture: {fileID: 0} | ||
24 | + m_Scale: {x: 1, y: 1} | ||
25 | + m_Offset: {x: 0, y: 0} | ||
26 | + - _DetailAlbedoMap: | ||
27 | + m_Texture: {fileID: 0} | ||
28 | + m_Scale: {x: 1, y: 1} | ||
29 | + m_Offset: {x: 0, y: 0} | ||
30 | + - _DetailMask: | ||
31 | + m_Texture: {fileID: 0} | ||
32 | + m_Scale: {x: 1, y: 1} | ||
33 | + m_Offset: {x: 0, y: 0} | ||
34 | + - _DetailNormalMap: | ||
35 | + m_Texture: {fileID: 0} | ||
36 | + m_Scale: {x: 1, y: 1} | ||
37 | + m_Offset: {x: 0, y: 0} | ||
38 | + - _EmissionMap: | ||
39 | + m_Texture: {fileID: 0} | ||
40 | + m_Scale: {x: 1, y: 1} | ||
41 | + m_Offset: {x: 0, y: 0} | ||
42 | + - _MainTex: | ||
43 | + m_Texture: {fileID: 2800000, guid: 784c78924e5396744953169847d21860, type: 3} | ||
44 | + m_Scale: {x: 1, y: 1} | ||
45 | + m_Offset: {x: 0, y: 0} | ||
46 | + - _MetallicGlossMap: | ||
47 | + m_Texture: {fileID: 0} | ||
48 | + m_Scale: {x: 1, y: 1} | ||
49 | + m_Offset: {x: 0, y: 0} | ||
50 | + - _OcclusionMap: | ||
51 | + m_Texture: {fileID: 0} | ||
52 | + m_Scale: {x: 1, y: 1} | ||
53 | + m_Offset: {x: 0, y: 0} | ||
54 | + - _ParallaxMap: | ||
55 | + m_Texture: {fileID: 0} | ||
56 | + m_Scale: {x: 1, y: 1} | ||
57 | + m_Offset: {x: 0, y: 0} | ||
58 | + m_Floats: | ||
59 | + - _BumpScale: 1 | ||
60 | + - _Cutoff: 0.5 | ||
61 | + - _DetailNormalMapScale: 1 | ||
62 | + - _DstBlend: 0 | ||
63 | + - _GlossMapScale: 1 | ||
64 | + - _Glossiness: 0.5 | ||
65 | + - _GlossyReflections: 1 | ||
66 | + - _Metallic: 0 | ||
67 | + - _Mode: 0 | ||
68 | + - _OcclusionStrength: 1 | ||
69 | + - _Parallax: 0.02 | ||
70 | + - _SmoothnessTextureChannel: 0 | ||
71 | + - _SpecularHighlights: 1 | ||
72 | + - _SrcBlend: 1 | ||
73 | + - _UVSec: 0 | ||
74 | + - _ZWrite: 1 | ||
75 | + m_Colors: | ||
76 | + - _Color: {r: 1, g: 1, b: 1, a: 1} | ||
77 | + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!21 &2100000 | ||
4 | +Material: | ||
5 | + serializedVersion: 6 | ||
6 | + m_ObjectHideFlags: 0 | ||
7 | + m_CorrespondingSourceObject: {fileID: 0} | ||
8 | + m_PrefabInstance: {fileID: 0} | ||
9 | + m_PrefabAsset: {fileID: 0} | ||
10 | + m_Name: girl_texture_01 | ||
11 | + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} | ||
12 | + m_ShaderKeywords: | ||
13 | + m_LightmapFlags: 4 | ||
14 | + m_EnableInstancingVariants: 0 | ||
15 | + m_DoubleSidedGI: 0 | ||
16 | + m_CustomRenderQueue: -1 | ||
17 | + stringTagMap: {} | ||
18 | + disabledShaderPasses: [] | ||
19 | + m_SavedProperties: | ||
20 | + serializedVersion: 3 | ||
21 | + m_TexEnvs: | ||
22 | + - _BumpMap: | ||
23 | + m_Texture: {fileID: 0} | ||
24 | + m_Scale: {x: 1, y: 1} | ||
25 | + m_Offset: {x: 0, y: 0} | ||
26 | + - _DetailAlbedoMap: | ||
27 | + m_Texture: {fileID: 0} | ||
28 | + m_Scale: {x: 1, y: 1} | ||
29 | + m_Offset: {x: 0, y: 0} | ||
30 | + - _DetailMask: | ||
31 | + m_Texture: {fileID: 0} | ||
32 | + m_Scale: {x: 1, y: 1} | ||
33 | + m_Offset: {x: 0, y: 0} | ||
34 | + - _DetailNormalMap: | ||
35 | + m_Texture: {fileID: 0} | ||
36 | + m_Scale: {x: 1, y: 1} | ||
37 | + m_Offset: {x: 0, y: 0} | ||
38 | + - _EmissionMap: | ||
39 | + m_Texture: {fileID: 0} | ||
40 | + m_Scale: {x: 1, y: 1} | ||
41 | + m_Offset: {x: 0, y: 0} | ||
42 | + - _MainTex: | ||
43 | + m_Texture: {fileID: 2800000, guid: e955f1ae9549b1f418ecd6aa9ba99082, type: 3} | ||
44 | + m_Scale: {x: 1, y: 1} | ||
45 | + m_Offset: {x: 0, y: 0} | ||
46 | + - _MetallicGlossMap: | ||
47 | + m_Texture: {fileID: 0} | ||
48 | + m_Scale: {x: 1, y: 1} | ||
49 | + m_Offset: {x: 0, y: 0} | ||
50 | + - _OcclusionMap: | ||
51 | + m_Texture: {fileID: 0} | ||
52 | + m_Scale: {x: 1, y: 1} | ||
53 | + m_Offset: {x: 0, y: 0} | ||
54 | + - _ParallaxMap: | ||
55 | + m_Texture: {fileID: 0} | ||
56 | + m_Scale: {x: 1, y: 1} | ||
57 | + m_Offset: {x: 0, y: 0} | ||
58 | + m_Floats: | ||
59 | + - _BumpScale: 1 | ||
60 | + - _Cutoff: 0.5 | ||
61 | + - _DetailNormalMapScale: 1 | ||
62 | + - _DstBlend: 0 | ||
63 | + - _GlossMapScale: 1 | ||
64 | + - _Glossiness: 0.5 | ||
65 | + - _GlossyReflections: 1 | ||
66 | + - _Metallic: 0 | ||
67 | + - _Mode: 0 | ||
68 | + - _OcclusionStrength: 1 | ||
69 | + - _Parallax: 0.02 | ||
70 | + - _SmoothnessTextureChannel: 0 | ||
71 | + - _SpecularHighlights: 1 | ||
72 | + - _SrcBlend: 1 | ||
73 | + - _UVSec: 0 | ||
74 | + - _ZWrite: 1 | ||
75 | + m_Colors: | ||
76 | + - _Color: {r: 1, g: 1, b: 1, a: 1} | ||
77 | + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!21 &2100000 | ||
4 | +Material: | ||
5 | + serializedVersion: 6 | ||
6 | + m_ObjectHideFlags: 0 | ||
7 | + m_CorrespondingSourceObject: {fileID: 0} | ||
8 | + m_PrefabInstance: {fileID: 0} | ||
9 | + m_PrefabAsset: {fileID: 0} | ||
10 | + m_Name: hair1 | ||
11 | + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} | ||
12 | + m_ShaderKeywords: | ||
13 | + m_LightmapFlags: 4 | ||
14 | + m_EnableInstancingVariants: 0 | ||
15 | + m_DoubleSidedGI: 0 | ||
16 | + m_CustomRenderQueue: -1 | ||
17 | + stringTagMap: {} | ||
18 | + disabledShaderPasses: [] | ||
19 | + m_SavedProperties: | ||
20 | + serializedVersion: 3 | ||
21 | + m_TexEnvs: | ||
22 | + - _BumpMap: | ||
23 | + m_Texture: {fileID: 0} | ||
24 | + m_Scale: {x: 1, y: 1} | ||
25 | + m_Offset: {x: 0, y: 0} | ||
26 | + - _DetailAlbedoMap: | ||
27 | + m_Texture: {fileID: 0} | ||
28 | + m_Scale: {x: 1, y: 1} | ||
29 | + m_Offset: {x: 0, y: 0} | ||
30 | + - _DetailMask: | ||
31 | + m_Texture: {fileID: 0} | ||
32 | + m_Scale: {x: 1, y: 1} | ||
33 | + m_Offset: {x: 0, y: 0} | ||
34 | + - _DetailNormalMap: | ||
35 | + m_Texture: {fileID: 0} | ||
36 | + m_Scale: {x: 1, y: 1} | ||
37 | + m_Offset: {x: 0, y: 0} | ||
38 | + - _EmissionMap: | ||
39 | + m_Texture: {fileID: 0} | ||
40 | + m_Scale: {x: 1, y: 1} | ||
41 | + m_Offset: {x: 0, y: 0} | ||
42 | + - _MainTex: | ||
43 | + m_Texture: {fileID: 2800000, guid: f8b7dc5e8d3dff3479902cbf2cf50f42, type: 3} | ||
44 | + m_Scale: {x: 1, y: 1} | ||
45 | + m_Offset: {x: 0, y: 0} | ||
46 | + - _MetallicGlossMap: | ||
47 | + m_Texture: {fileID: 0} | ||
48 | + m_Scale: {x: 1, y: 1} | ||
49 | + m_Offset: {x: 0, y: 0} | ||
50 | + - _OcclusionMap: | ||
51 | + m_Texture: {fileID: 0} | ||
52 | + m_Scale: {x: 1, y: 1} | ||
53 | + m_Offset: {x: 0, y: 0} | ||
54 | + - _ParallaxMap: | ||
55 | + m_Texture: {fileID: 0} | ||
56 | + m_Scale: {x: 1, y: 1} | ||
57 | + m_Offset: {x: 0, y: 0} | ||
58 | + m_Floats: | ||
59 | + - _BumpScale: 1 | ||
60 | + - _Cutoff: 0.5 | ||
61 | + - _DetailNormalMapScale: 1 | ||
62 | + - _DstBlend: 0 | ||
63 | + - _GlossMapScale: 1 | ||
64 | + - _Glossiness: 0.5 | ||
65 | + - _GlossyReflections: 1 | ||
66 | + - _Metallic: 0 | ||
67 | + - _Mode: 0 | ||
68 | + - _OcclusionStrength: 1 | ||
69 | + - _Parallax: 0.02 | ||
70 | + - _SmoothnessTextureChannel: 0 | ||
71 | + - _SpecularHighlights: 1 | ||
72 | + - _SrcBlend: 1 | ||
73 | + - _UVSec: 0 | ||
74 | + - _ZWrite: 1 | ||
75 | + m_Colors: | ||
76 | + - _Color: {r: 1, g: 1, b: 1, a: 1} | ||
77 | + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} |
No preview for this file type
This file is too large to display.
780 KB
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!91 &9100000 | ||
4 | +AnimatorController: | ||
5 | + m_ObjectHideFlags: 0 | ||
6 | + m_CorrespondingSourceObject: {fileID: 0} | ||
7 | + m_PrefabInstance: {fileID: 0} | ||
8 | + m_PrefabAsset: {fileID: 0} | ||
9 | + m_Name: girlAC | ||
10 | + serializedVersion: 5 | ||
11 | + m_AnimatorParameters: [] | ||
12 | + m_AnimatorLayers: | ||
13 | + - serializedVersion: 5 | ||
14 | + m_Name: Base Layer | ||
15 | + m_StateMachine: {fileID: 1107184895931894816} | ||
16 | + m_Mask: {fileID: 0} | ||
17 | + m_Motions: [] | ||
18 | + m_Behaviours: [] | ||
19 | + m_BlendingMode: 0 | ||
20 | + m_SyncedLayerIndex: -1 | ||
21 | + m_DefaultWeight: 0 | ||
22 | + m_IKPass: 0 | ||
23 | + m_SyncedLayerAffectsTiming: 0 | ||
24 | + m_Controller: {fileID: 9100000} | ||
25 | +--- !u!1102 &1102235434097723244 | ||
26 | +AnimatorState: | ||
27 | + serializedVersion: 5 | ||
28 | + m_ObjectHideFlags: 1 | ||
29 | + m_CorrespondingSourceObject: {fileID: 0} | ||
30 | + m_PrefabInstance: {fileID: 0} | ||
31 | + m_PrefabAsset: {fileID: 0} | ||
32 | + m_Name: New State | ||
33 | + m_Speed: 1 | ||
34 | + m_CycleOffset: 0 | ||
35 | + m_Transitions: [] | ||
36 | + m_StateMachineBehaviours: [] | ||
37 | + m_Position: {x: 50, y: 50, z: 0} | ||
38 | + m_IKOnFeet: 0 | ||
39 | + m_WriteDefaultValues: 1 | ||
40 | + m_Mirror: 0 | ||
41 | + m_SpeedParameterActive: 0 | ||
42 | + m_MirrorParameterActive: 0 | ||
43 | + m_CycleOffsetParameterActive: 0 | ||
44 | + m_TimeParameterActive: 0 | ||
45 | + m_Motion: {fileID: 7400002, guid: a5e11101db1088e47b2aef562350ae30, type: 3} | ||
46 | + m_Tag: | ||
47 | + m_SpeedParameter: | ||
48 | + m_MirrorParameter: | ||
49 | + m_CycleOffsetParameter: | ||
50 | + m_TimeParameter: | ||
51 | +--- !u!1107 &1107184895931894816 | ||
52 | +AnimatorStateMachine: | ||
53 | + serializedVersion: 5 | ||
54 | + m_ObjectHideFlags: 1 | ||
55 | + m_CorrespondingSourceObject: {fileID: 0} | ||
56 | + m_PrefabInstance: {fileID: 0} | ||
57 | + m_PrefabAsset: {fileID: 0} | ||
58 | + m_Name: Base Layer | ||
59 | + m_ChildStates: | ||
60 | + - serializedVersion: 1 | ||
61 | + m_State: {fileID: 1102235434097723244} | ||
62 | + m_Position: {x: 302.25, y: 74, z: 0} | ||
63 | + m_ChildStateMachines: [] | ||
64 | + m_AnyStateTransitions: [] | ||
65 | + m_EntryTransitions: [] | ||
66 | + m_StateMachineTransitions: {} | ||
67 | + m_StateMachineBehaviours: [] | ||
68 | + m_AnyStatePosition: {x: 50, y: 20, z: 0} | ||
69 | + m_EntryPosition: {x: 50, y: 120, z: 0} | ||
70 | + m_ExitPosition: {x: 800, y: 120, z: 0} | ||
71 | + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} | ||
72 | + m_DefaultState: {fileID: 1102235434097723244} |
1.46 MB
492 KB
No preview for this file type
No preview for this file type
12 KB
780 KB
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 | +%YAML 1.1 | ||
2 | +%TAG !u! tag:unity3d.com,2011: | ||
3 | +--- !u!21 &2100000 | ||
4 | +Material: | ||
5 | + serializedVersion: 6 | ||
6 | + m_ObjectHideFlags: 0 | ||
7 | + m_CorrespondingSourceObject: {fileID: 0} | ||
8 | + m_PrefabInstance: {fileID: 0} | ||
9 | + m_PrefabAsset: {fileID: 0} | ||
10 | + m_Name: BoneMaterial | ||
11 | + m_Shader: {fileID: 200, guid: 0000000000000000f000000000000000, type: 0} | ||
12 | + m_ShaderKeywords: | ||
13 | + m_LightmapFlags: 4 | ||
14 | + m_EnableInstancingVariants: 0 | ||
15 | + m_DoubleSidedGI: 0 | ||
16 | + m_CustomRenderQueue: -1 | ||
17 | + stringTagMap: {} | ||
18 | + disabledShaderPasses: [] | ||
19 | + m_SavedProperties: | ||
20 | + serializedVersion: 3 | ||
21 | + m_TexEnvs: | ||
22 | + - _MainTex: | ||
23 | + m_Texture: {fileID: 0} | ||
24 | + m_Scale: {x: 1, y: 1} | ||
25 | + m_Offset: {x: 0, y: 0} | ||
26 | + m_Floats: | ||
27 | + - _InvFade: 1 | ||
28 | + m_Colors: | ||
29 | + - _Color: {r: 1, g: 1, b: 1, a: 1} | ||
30 | + - _TintColor: {r: 0.5, g: 0.5, b: 0.5, a: 0.5} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public class BodySourceManager : MonoBehaviour | ||
6 | +{ | ||
7 | + private KinectSensor _Sensor; | ||
8 | + private BodyFrameReader _Reader; | ||
9 | + private Body[] _Data = null; | ||
10 | + | ||
11 | + public Body[] GetData() | ||
12 | + { | ||
13 | + return _Data; | ||
14 | + } | ||
15 | + | ||
16 | + | ||
17 | + void Start () | ||
18 | + { | ||
19 | + _Sensor = KinectSensor.GetDefault(); | ||
20 | + | ||
21 | + if (_Sensor != null) | ||
22 | + { | ||
23 | + _Reader = _Sensor.BodyFrameSource.OpenReader(); | ||
24 | + | ||
25 | + if (!_Sensor.IsOpen) | ||
26 | + { | ||
27 | + _Sensor.Open(); | ||
28 | + } | ||
29 | + } | ||
30 | + } | ||
31 | + | ||
32 | + void Update () | ||
33 | + { | ||
34 | + if (_Reader != null) | ||
35 | + { | ||
36 | + var frame = _Reader.AcquireLatestFrame(); | ||
37 | + if (frame != null) | ||
38 | + { | ||
39 | + if (_Data == null) | ||
40 | + { | ||
41 | + _Data = new Body[_Sensor.BodyFrameSource.BodyCount]; | ||
42 | + } | ||
43 | + | ||
44 | + frame.GetAndRefreshBodyData(_Data); | ||
45 | + | ||
46 | + frame.Dispose(); | ||
47 | + frame = null; | ||
48 | + } | ||
49 | + } | ||
50 | + } | ||
51 | + | ||
52 | + void OnApplicationQuit() | ||
53 | + { | ||
54 | + if (_Reader != null) | ||
55 | + { | ||
56 | + _Reader.Dispose(); | ||
57 | + _Reader = null; | ||
58 | + } | ||
59 | + | ||
60 | + if (_Sensor != null) | ||
61 | + { | ||
62 | + if (_Sensor.IsOpen) | ||
63 | + { | ||
64 | + _Sensor.Close(); | ||
65 | + } | ||
66 | + | ||
67 | + _Sensor = null; | ||
68 | + } | ||
69 | + } | ||
70 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using System.Collections.Generic; | ||
4 | +using Kinect = Windows.Kinect; | ||
5 | + | ||
6 | +public class BodySourceView : MonoBehaviour | ||
7 | +{ | ||
8 | + public Material BoneMaterial; | ||
9 | + public GameObject BodySourceManager; | ||
10 | + | ||
11 | + private Dictionary<ulong, GameObject> _Bodies = new Dictionary<ulong, GameObject>(); | ||
12 | + private BodySourceManager _BodyManager; | ||
13 | + | ||
14 | + private Dictionary<Kinect.JointType, Kinect.JointType> _BoneMap = new Dictionary<Kinect.JointType, Kinect.JointType>() | ||
15 | + { | ||
16 | + { Kinect.JointType.FootLeft, Kinect.JointType.AnkleLeft }, | ||
17 | + { Kinect.JointType.AnkleLeft, Kinect.JointType.KneeLeft }, | ||
18 | + { Kinect.JointType.KneeLeft, Kinect.JointType.HipLeft }, | ||
19 | + { Kinect.JointType.HipLeft, Kinect.JointType.SpineBase }, | ||
20 | + | ||
21 | + { Kinect.JointType.FootRight, Kinect.JointType.AnkleRight }, | ||
22 | + { Kinect.JointType.AnkleRight, Kinect.JointType.KneeRight }, | ||
23 | + { Kinect.JointType.KneeRight, Kinect.JointType.HipRight }, | ||
24 | + { Kinect.JointType.HipRight, Kinect.JointType.SpineBase }, | ||
25 | + | ||
26 | + { Kinect.JointType.HandTipLeft, Kinect.JointType.HandLeft }, | ||
27 | + { Kinect.JointType.ThumbLeft, Kinect.JointType.HandLeft }, | ||
28 | + { Kinect.JointType.HandLeft, Kinect.JointType.WristLeft }, | ||
29 | + { Kinect.JointType.WristLeft, Kinect.JointType.ElbowLeft }, | ||
30 | + { Kinect.JointType.ElbowLeft, Kinect.JointType.ShoulderLeft }, | ||
31 | + { Kinect.JointType.ShoulderLeft, Kinect.JointType.SpineShoulder }, | ||
32 | + | ||
33 | + { Kinect.JointType.HandTipRight, Kinect.JointType.HandRight }, | ||
34 | + { Kinect.JointType.ThumbRight, Kinect.JointType.HandRight }, | ||
35 | + { Kinect.JointType.HandRight, Kinect.JointType.WristRight }, | ||
36 | + { Kinect.JointType.WristRight, Kinect.JointType.ElbowRight }, | ||
37 | + { Kinect.JointType.ElbowRight, Kinect.JointType.ShoulderRight }, | ||
38 | + { Kinect.JointType.ShoulderRight, Kinect.JointType.SpineShoulder }, | ||
39 | + | ||
40 | + { Kinect.JointType.SpineBase, Kinect.JointType.SpineMid }, | ||
41 | + { Kinect.JointType.SpineMid, Kinect.JointType.SpineShoulder }, | ||
42 | + { Kinect.JointType.SpineShoulder, Kinect.JointType.Neck }, | ||
43 | + { Kinect.JointType.Neck, Kinect.JointType.Head }, | ||
44 | + }; | ||
45 | + | ||
46 | + void Update () | ||
47 | + { | ||
48 | + if (BodySourceManager == null) | ||
49 | + { | ||
50 | + return; | ||
51 | + } | ||
52 | + | ||
53 | + _BodyManager = BodySourceManager.GetComponent<BodySourceManager>(); | ||
54 | + if (_BodyManager == null) | ||
55 | + { | ||
56 | + return; | ||
57 | + } | ||
58 | + | ||
59 | + Kinect.Body[] data = _BodyManager.GetData(); | ||
60 | + if (data == null) | ||
61 | + { | ||
62 | + return; | ||
63 | + } | ||
64 | + | ||
65 | + List<ulong> trackedIds = new List<ulong>(); | ||
66 | + foreach(var body in data) | ||
67 | + { | ||
68 | + if (body == null) | ||
69 | + { | ||
70 | + continue; | ||
71 | + } | ||
72 | + | ||
73 | + if(body.IsTracked) | ||
74 | + { | ||
75 | + trackedIds.Add (body.TrackingId); | ||
76 | + } | ||
77 | + } | ||
78 | + | ||
79 | + List<ulong> knownIds = new List<ulong>(_Bodies.Keys); | ||
80 | + | ||
81 | + // First delete untracked bodies | ||
82 | + foreach(ulong trackingId in knownIds) | ||
83 | + { | ||
84 | + if(!trackedIds.Contains(trackingId)) | ||
85 | + { | ||
86 | + Destroy(_Bodies[trackingId]); | ||
87 | + _Bodies.Remove(trackingId); | ||
88 | + } | ||
89 | + } | ||
90 | + | ||
91 | + foreach(var body in data) | ||
92 | + { | ||
93 | + if (body == null) | ||
94 | + { | ||
95 | + continue; | ||
96 | + } | ||
97 | + | ||
98 | + if(body.IsTracked) | ||
99 | + { | ||
100 | + if(!_Bodies.ContainsKey(body.TrackingId)) | ||
101 | + { | ||
102 | + _Bodies[body.TrackingId] = CreateBodyObject(body.TrackingId); | ||
103 | + | ||
104 | + } | ||
105 | + RefreshBodyObject(body, _Bodies[body.TrackingId]); | ||
106 | + } | ||
107 | + } | ||
108 | + } | ||
109 | + | ||
110 | + private GameObject CreateBodyObject(ulong id) | ||
111 | + { | ||
112 | + GameObject body = new GameObject("Body:" + id); | ||
113 | + | ||
114 | + for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) | ||
115 | + { | ||
116 | + GameObject jointObj = GameObject.CreatePrimitive(PrimitiveType.Cube); | ||
117 | + | ||
118 | + LineRenderer lr = jointObj.AddComponent<LineRenderer>(); | ||
119 | + lr.SetVertexCount(2); | ||
120 | + lr.material = BoneMaterial; | ||
121 | + lr.SetWidth(0.05f, 0.05f); | ||
122 | + | ||
123 | + jointObj.transform.localScale = new Vector3(0.3f, 0.3f, 0.3f); | ||
124 | + jointObj.name = jt.ToString(); | ||
125 | + jointObj.transform.parent = body.transform; | ||
126 | + } | ||
127 | + | ||
128 | + return body; | ||
129 | + } | ||
130 | + | ||
131 | + private void RefreshBodyObject(Kinect.Body body, GameObject bodyObject) | ||
132 | + { | ||
133 | + | ||
134 | + for (Kinect.JointType jt = Kinect.JointType.SpineBase; jt <= Kinect.JointType.ThumbRight; jt++) | ||
135 | + { | ||
136 | + Kinect.Joint sourceJoint = body.Joints[jt]; | ||
137 | + Debug.Log(body.Joints[jt].JointType); | ||
138 | + Debug.Log(sourceJoint.Position.X * 10); | ||
139 | + Debug.Log(sourceJoint.Position.Y * 10); | ||
140 | + Debug.Log(sourceJoint.Position.Z * 10); | ||
141 | + Kinect.Joint? targetJoint = null; | ||
142 | + | ||
143 | + if(_BoneMap.ContainsKey(jt)) | ||
144 | + { | ||
145 | + targetJoint = body.Joints[_BoneMap[jt]]; | ||
146 | + } | ||
147 | + Transform jointObj = bodyObject.transform.Find(jt.ToString()); | ||
148 | + jointObj.localPosition = GetVector3FromJoint(sourceJoint); | ||
149 | + | ||
150 | + LineRenderer lr = jointObj.GetComponent<LineRenderer>(); | ||
151 | + if(targetJoint.HasValue) | ||
152 | + { | ||
153 | + lr.SetPosition(0, jointObj.localPosition); | ||
154 | + lr.SetPosition(1, GetVector3FromJoint(targetJoint.Value)); | ||
155 | + lr.SetColors(GetColorForState (sourceJoint.TrackingState), GetColorForState(targetJoint.Value.TrackingState)); | ||
156 | + } | ||
157 | + else | ||
158 | + { | ||
159 | + lr.enabled = false; | ||
160 | + } | ||
161 | + } | ||
162 | + } | ||
163 | + | ||
164 | + private static Color GetColorForState(Kinect.TrackingState state) | ||
165 | + { | ||
166 | + switch (state) | ||
167 | + { | ||
168 | + case Kinect.TrackingState.Tracked: | ||
169 | + return Color.green; | ||
170 | + | ||
171 | + case Kinect.TrackingState.Inferred: | ||
172 | + return Color.red; | ||
173 | + | ||
174 | + default: | ||
175 | + return Color.black; | ||
176 | + } | ||
177 | + } | ||
178 | + | ||
179 | + private static Vector3 GetVector3FromJoint(Kinect.Joint joint) | ||
180 | + { | ||
181 | + return new Vector3(joint.Position.X * 10, joint.Position.Y * 10, joint.Position.Z * 10); | ||
182 | + } | ||
183 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public class ColorSourceManager : MonoBehaviour | ||
6 | +{ | ||
7 | + public int ColorWidth { get; private set; } | ||
8 | + public int ColorHeight { get; private set; } | ||
9 | + | ||
10 | + private KinectSensor _Sensor; | ||
11 | + private ColorFrameReader _Reader; | ||
12 | + private Texture2D _Texture; | ||
13 | + private byte[] _Data; | ||
14 | + | ||
15 | + public Texture2D GetColorTexture() | ||
16 | + { | ||
17 | + return _Texture; | ||
18 | + } | ||
19 | + | ||
20 | + void Start() | ||
21 | + { | ||
22 | + _Sensor = KinectSensor.GetDefault(); | ||
23 | + | ||
24 | + if (_Sensor != null) | ||
25 | + { | ||
26 | + _Reader = _Sensor.ColorFrameSource.OpenReader(); | ||
27 | + | ||
28 | + var frameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba); | ||
29 | + ColorWidth = frameDesc.Width; | ||
30 | + ColorHeight = frameDesc.Height; | ||
31 | + | ||
32 | + _Texture = new Texture2D(frameDesc.Width, frameDesc.Height, TextureFormat.RGBA32, false); | ||
33 | + _Data = new byte[frameDesc.BytesPerPixel * frameDesc.LengthInPixels]; | ||
34 | + | ||
35 | + if (!_Sensor.IsOpen) | ||
36 | + { | ||
37 | + _Sensor.Open(); | ||
38 | + } | ||
39 | + } | ||
40 | + } | ||
41 | + | ||
42 | + void Update () | ||
43 | + { | ||
44 | + if (_Reader != null) | ||
45 | + { | ||
46 | + var frame = _Reader.AcquireLatestFrame(); | ||
47 | + | ||
48 | + if (frame != null) | ||
49 | + { | ||
50 | + frame.CopyConvertedFrameDataToArray(_Data, ColorImageFormat.Rgba); | ||
51 | + _Texture.LoadRawTextureData(_Data); | ||
52 | + _Texture.Apply(); | ||
53 | + | ||
54 | + frame.Dispose(); | ||
55 | + frame = null; | ||
56 | + } | ||
57 | + } | ||
58 | + } | ||
59 | + | ||
60 | + void OnApplicationQuit() | ||
61 | + { | ||
62 | + if (_Reader != null) | ||
63 | + { | ||
64 | + _Reader.Dispose(); | ||
65 | + _Reader = null; | ||
66 | + } | ||
67 | + | ||
68 | + if (_Sensor != null) | ||
69 | + { | ||
70 | + if (_Sensor.IsOpen) | ||
71 | + { | ||
72 | + _Sensor.Close(); | ||
73 | + } | ||
74 | + | ||
75 | + _Sensor = null; | ||
76 | + } | ||
77 | + } | ||
78 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public class ColorSourceView : MonoBehaviour | ||
6 | +{ | ||
7 | + public GameObject ColorSourceManager; | ||
8 | + private ColorSourceManager _ColorManager; | ||
9 | + | ||
10 | + void Start () | ||
11 | + { | ||
12 | + gameObject.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(-1, 1)); | ||
13 | + } | ||
14 | + | ||
15 | + void Update() | ||
16 | + { | ||
17 | + if (ColorSourceManager == null) | ||
18 | + { | ||
19 | + return; | ||
20 | + } | ||
21 | + | ||
22 | + _ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>(); | ||
23 | + if (_ColorManager == null) | ||
24 | + { | ||
25 | + return; | ||
26 | + } | ||
27 | + | ||
28 | + gameObject.GetComponent<Renderer>().material.mainTexture = _ColorManager.GetColorTexture(); | ||
29 | + } | ||
30 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public class DepthSourceManager : MonoBehaviour | ||
6 | +{ | ||
7 | + private KinectSensor _Sensor; | ||
8 | + private DepthFrameReader _Reader; | ||
9 | + private ushort[] _Data; | ||
10 | + | ||
11 | + public ushort[] GetData() | ||
12 | + { | ||
13 | + return _Data; | ||
14 | + } | ||
15 | + | ||
16 | + void Start () | ||
17 | + { | ||
18 | + _Sensor = KinectSensor.GetDefault(); | ||
19 | + | ||
20 | + if (_Sensor != null) | ||
21 | + { | ||
22 | + _Reader = _Sensor.DepthFrameSource.OpenReader(); | ||
23 | + _Data = new ushort[_Sensor.DepthFrameSource.FrameDescription.LengthInPixels]; | ||
24 | + } | ||
25 | + } | ||
26 | + | ||
27 | + void Update () | ||
28 | + { | ||
29 | + if (_Reader != null) | ||
30 | + { | ||
31 | + var frame = _Reader.AcquireLatestFrame(); | ||
32 | + if (frame != null) | ||
33 | + { | ||
34 | + frame.CopyFrameDataToArray(_Data); | ||
35 | + frame.Dispose(); | ||
36 | + frame = null; | ||
37 | + } | ||
38 | + } | ||
39 | + } | ||
40 | + | ||
41 | + void OnApplicationQuit() | ||
42 | + { | ||
43 | + if (_Reader != null) | ||
44 | + { | ||
45 | + _Reader.Dispose(); | ||
46 | + _Reader = null; | ||
47 | + } | ||
48 | + | ||
49 | + if (_Sensor != null) | ||
50 | + { | ||
51 | + if (_Sensor.IsOpen) | ||
52 | + { | ||
53 | + _Sensor.Close(); | ||
54 | + } | ||
55 | + | ||
56 | + _Sensor = null; | ||
57 | + } | ||
58 | + } | ||
59 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public enum DepthViewMode | ||
6 | +{ | ||
7 | + SeparateSourceReaders, | ||
8 | + MultiSourceReader, | ||
9 | +} | ||
10 | + | ||
11 | +public class DepthSourceView : MonoBehaviour | ||
12 | +{ | ||
13 | + public DepthViewMode ViewMode = DepthViewMode.SeparateSourceReaders; | ||
14 | + | ||
15 | + public GameObject ColorSourceManager; | ||
16 | + public GameObject DepthSourceManager; | ||
17 | + public GameObject MultiSourceManager; | ||
18 | + | ||
19 | + private KinectSensor _Sensor; | ||
20 | + private CoordinateMapper _Mapper; | ||
21 | + private Mesh _Mesh; | ||
22 | + private Vector3[] _Vertices; | ||
23 | + private Vector2[] _UV; | ||
24 | + private int[] _Triangles; | ||
25 | + | ||
26 | + // Only works at 4 right now | ||
27 | + private const int _DownsampleSize = 4; | ||
28 | + private const double _DepthScale = 0.1f; | ||
29 | + private const int _Speed = 50; | ||
30 | + | ||
31 | + private MultiSourceManager _MultiManager; | ||
32 | + private ColorSourceManager _ColorManager; | ||
33 | + private DepthSourceManager _DepthManager; | ||
34 | + | ||
35 | + void Start() | ||
36 | + { | ||
37 | + _Sensor = KinectSensor.GetDefault(); | ||
38 | + if (_Sensor != null) | ||
39 | + { | ||
40 | + _Mapper = _Sensor.CoordinateMapper; | ||
41 | + var frameDesc = _Sensor.DepthFrameSource.FrameDescription; | ||
42 | + | ||
43 | + // Downsample to lower resolution | ||
44 | + CreateMesh(frameDesc.Width / _DownsampleSize, frameDesc.Height / _DownsampleSize); | ||
45 | + | ||
46 | + if (!_Sensor.IsOpen) | ||
47 | + { | ||
48 | + _Sensor.Open(); | ||
49 | + } | ||
50 | + } | ||
51 | + } | ||
52 | + | ||
53 | + void CreateMesh(int width, int height) | ||
54 | + { | ||
55 | + _Mesh = new Mesh(); | ||
56 | + GetComponent<MeshFilter>().mesh = _Mesh; | ||
57 | + | ||
58 | + _Vertices = new Vector3[width * height]; | ||
59 | + _UV = new Vector2[width * height]; | ||
60 | + _Triangles = new int[6 * ((width - 1) * (height - 1))]; | ||
61 | + | ||
62 | + int triangleIndex = 0; | ||
63 | + for (int y = 0; y < height; y++) | ||
64 | + { | ||
65 | + for (int x = 0; x < width; x++) | ||
66 | + { | ||
67 | + int index = (y * width) + x; | ||
68 | + | ||
69 | + _Vertices[index] = new Vector3(x, -y, 0); | ||
70 | + _UV[index] = new Vector2(((float)x / (float)width), ((float)y / (float)height)); | ||
71 | + | ||
72 | + // Skip the last row/col | ||
73 | + if (x != (width - 1) && y != (height - 1)) | ||
74 | + { | ||
75 | + int topLeft = index; | ||
76 | + int topRight = topLeft + 1; | ||
77 | + int bottomLeft = topLeft + width; | ||
78 | + int bottomRight = bottomLeft + 1; | ||
79 | + | ||
80 | + _Triangles[triangleIndex++] = topLeft; | ||
81 | + _Triangles[triangleIndex++] = topRight; | ||
82 | + _Triangles[triangleIndex++] = bottomLeft; | ||
83 | + _Triangles[triangleIndex++] = bottomLeft; | ||
84 | + _Triangles[triangleIndex++] = topRight; | ||
85 | + _Triangles[triangleIndex++] = bottomRight; | ||
86 | + } | ||
87 | + } | ||
88 | + } | ||
89 | + | ||
90 | + _Mesh.vertices = _Vertices; | ||
91 | + _Mesh.uv = _UV; | ||
92 | + _Mesh.triangles = _Triangles; | ||
93 | + _Mesh.RecalculateNormals(); | ||
94 | + } | ||
95 | + | ||
96 | + void OnGUI() | ||
97 | + { | ||
98 | + GUI.BeginGroup(new Rect(0, 0, Screen.width, Screen.height)); | ||
99 | + GUI.TextField(new Rect(Screen.width - 250 , 10, 250, 20), "DepthMode: " + ViewMode.ToString()); | ||
100 | + GUI.EndGroup(); | ||
101 | + } | ||
102 | + | ||
103 | + void Update() | ||
104 | + { | ||
105 | + if (_Sensor == null) | ||
106 | + { | ||
107 | + return; | ||
108 | + } | ||
109 | + | ||
110 | + if (Input.GetButtonDown("Fire1")) | ||
111 | + { | ||
112 | + if(ViewMode == DepthViewMode.MultiSourceReader) | ||
113 | + { | ||
114 | + ViewMode = DepthViewMode.SeparateSourceReaders; | ||
115 | + } | ||
116 | + else | ||
117 | + { | ||
118 | + ViewMode = DepthViewMode.MultiSourceReader; | ||
119 | + } | ||
120 | + } | ||
121 | + | ||
122 | + float yVal = Input.GetAxis("Horizontal"); | ||
123 | + float xVal = -Input.GetAxis("Vertical"); | ||
124 | + | ||
125 | + transform.Rotate( | ||
126 | + (xVal * Time.deltaTime * _Speed), | ||
127 | + (yVal * Time.deltaTime * _Speed), | ||
128 | + 0, | ||
129 | + Space.Self); | ||
130 | + | ||
131 | + if (ViewMode == DepthViewMode.SeparateSourceReaders) | ||
132 | + { | ||
133 | + if (ColorSourceManager == null) | ||
134 | + { | ||
135 | + return; | ||
136 | + } | ||
137 | + | ||
138 | + _ColorManager = ColorSourceManager.GetComponent<ColorSourceManager>(); | ||
139 | + if (_ColorManager == null) | ||
140 | + { | ||
141 | + return; | ||
142 | + } | ||
143 | + | ||
144 | + if (DepthSourceManager == null) | ||
145 | + { | ||
146 | + return; | ||
147 | + } | ||
148 | + | ||
149 | + _DepthManager = DepthSourceManager.GetComponent<DepthSourceManager>(); | ||
150 | + if (_DepthManager == null) | ||
151 | + { | ||
152 | + return; | ||
153 | + } | ||
154 | + | ||
155 | + gameObject.GetComponent<Renderer>().material.mainTexture = _ColorManager.GetColorTexture(); | ||
156 | + RefreshData(_DepthManager.GetData(), | ||
157 | + _ColorManager.ColorWidth, | ||
158 | + _ColorManager.ColorHeight); | ||
159 | + } | ||
160 | + else | ||
161 | + { | ||
162 | + if (MultiSourceManager == null) | ||
163 | + { | ||
164 | + return; | ||
165 | + } | ||
166 | + | ||
167 | + _MultiManager = MultiSourceManager.GetComponent<MultiSourceManager>(); | ||
168 | + if (_MultiManager == null) | ||
169 | + { | ||
170 | + return; | ||
171 | + } | ||
172 | + | ||
173 | + gameObject.GetComponent<Renderer>().material.mainTexture = _MultiManager.GetColorTexture(); | ||
174 | + | ||
175 | + RefreshData(_MultiManager.GetDepthData(), | ||
176 | + _MultiManager.ColorWidth, | ||
177 | + _MultiManager.ColorHeight); | ||
178 | + } | ||
179 | + } | ||
180 | + | ||
181 | + private void RefreshData(ushort[] depthData, int colorWidth, int colorHeight) | ||
182 | + { | ||
183 | + var frameDesc = _Sensor.DepthFrameSource.FrameDescription; | ||
184 | + | ||
185 | + ColorSpacePoint[] colorSpace = new ColorSpacePoint[depthData.Length]; | ||
186 | + _Mapper.MapDepthFrameToColorSpace(depthData, colorSpace); | ||
187 | + | ||
188 | + for (int y = 0; y < frameDesc.Height; y += _DownsampleSize) | ||
189 | + { | ||
190 | + for (int x = 0; x < frameDesc.Width; x += _DownsampleSize) | ||
191 | + { | ||
192 | + int indexX = x / _DownsampleSize; | ||
193 | + int indexY = y / _DownsampleSize; | ||
194 | + int smallIndex = (indexY * (frameDesc.Width / _DownsampleSize)) + indexX; | ||
195 | + | ||
196 | + double avg = GetAvg(depthData, x, y, frameDesc.Width, frameDesc.Height); | ||
197 | + | ||
198 | + avg = avg * _DepthScale; | ||
199 | + | ||
200 | + _Vertices[smallIndex].z = (float)avg; | ||
201 | + | ||
202 | + // Update UV mapping with CDRP | ||
203 | + var colorSpacePoint = colorSpace[(y * frameDesc.Width) + x]; | ||
204 | + _UV[smallIndex] = new Vector2(colorSpacePoint.X / colorWidth, colorSpacePoint.Y / colorHeight); | ||
205 | + } | ||
206 | + } | ||
207 | + | ||
208 | + _Mesh.vertices = _Vertices; | ||
209 | + _Mesh.uv = _UV; | ||
210 | + _Mesh.triangles = _Triangles; | ||
211 | + _Mesh.RecalculateNormals(); | ||
212 | + } | ||
213 | + | ||
214 | + private double GetAvg(ushort[] depthData, int x, int y, int width, int height) | ||
215 | + { | ||
216 | + double sum = 0.0; | ||
217 | + | ||
218 | + for (int y1 = y; y1 < y + 4; y1++) | ||
219 | + { | ||
220 | + for (int x1 = x; x1 < x + 4; x1++) | ||
221 | + { | ||
222 | + int fullIndex = (y1 * width) + x1; | ||
223 | + | ||
224 | + if (depthData[fullIndex] == 0) | ||
225 | + sum += 4500; | ||
226 | + else | ||
227 | + sum += depthData[fullIndex]; | ||
228 | + | ||
229 | + } | ||
230 | + } | ||
231 | + | ||
232 | + return sum / 16; | ||
233 | + } | ||
234 | + | ||
235 | + void OnApplicationQuit() | ||
236 | + { | ||
237 | + if (_Mapper != null) | ||
238 | + { | ||
239 | + _Mapper = null; | ||
240 | + } | ||
241 | + | ||
242 | + if (_Sensor != null) | ||
243 | + { | ||
244 | + if (_Sensor.IsOpen) | ||
245 | + { | ||
246 | + _Sensor.Close(); | ||
247 | + } | ||
248 | + | ||
249 | + _Sensor = null; | ||
250 | + } | ||
251 | + } | ||
252 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public class InfraredSourceManager : MonoBehaviour | ||
6 | +{ | ||
7 | + private KinectSensor _Sensor; | ||
8 | + private InfraredFrameReader _Reader; | ||
9 | + private ushort[] _Data; | ||
10 | + private byte[] _RawData; | ||
11 | + | ||
12 | + // I'm not sure this makes sense for the Kinect APIs | ||
13 | + // Instead, this logic should be in the VIEW | ||
14 | + private Texture2D _Texture; | ||
15 | + | ||
16 | + public Texture2D GetInfraredTexture() | ||
17 | + { | ||
18 | + return _Texture; | ||
19 | + } | ||
20 | + | ||
21 | + void Start() | ||
22 | + { | ||
23 | + _Sensor = KinectSensor.GetDefault(); | ||
24 | + if (_Sensor != null) | ||
25 | + { | ||
26 | + _Reader = _Sensor.InfraredFrameSource.OpenReader(); | ||
27 | + var frameDesc = _Sensor.InfraredFrameSource.FrameDescription; | ||
28 | + _Data = new ushort[frameDesc.LengthInPixels]; | ||
29 | + _RawData = new byte[frameDesc.LengthInPixels * 4]; | ||
30 | + _Texture = new Texture2D(frameDesc.Width, frameDesc.Height, TextureFormat.BGRA32, false); | ||
31 | + | ||
32 | + if (!_Sensor.IsOpen) | ||
33 | + { | ||
34 | + _Sensor.Open(); | ||
35 | + } | ||
36 | + } | ||
37 | + } | ||
38 | + | ||
39 | + void Update () | ||
40 | + { | ||
41 | + if (_Reader != null) | ||
42 | + { | ||
43 | + var frame = _Reader.AcquireLatestFrame(); | ||
44 | + if (frame != null) | ||
45 | + { | ||
46 | + frame.CopyFrameDataToArray(_Data); | ||
47 | + | ||
48 | + int index = 0; | ||
49 | + foreach(var ir in _Data) | ||
50 | + { | ||
51 | + byte intensity = (byte)(ir >> 8); | ||
52 | + _RawData[index++] = intensity; | ||
53 | + _RawData[index++] = intensity; | ||
54 | + _RawData[index++] = intensity; | ||
55 | + _RawData[index++] = 255; // Alpha | ||
56 | + } | ||
57 | + | ||
58 | + _Texture.LoadRawTextureData(_RawData); | ||
59 | + _Texture.Apply(); | ||
60 | + | ||
61 | + frame.Dispose(); | ||
62 | + frame = null; | ||
63 | + } | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + void OnApplicationQuit() | ||
68 | + { | ||
69 | + if (_Reader != null) | ||
70 | + { | ||
71 | + _Reader.Dispose(); | ||
72 | + _Reader = null; | ||
73 | + } | ||
74 | + | ||
75 | + if (_Sensor != null) | ||
76 | + { | ||
77 | + if (_Sensor.IsOpen) | ||
78 | + { | ||
79 | + _Sensor.Close(); | ||
80 | + } | ||
81 | + | ||
82 | + _Sensor = null; | ||
83 | + } | ||
84 | + } | ||
85 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | + | ||
4 | +public class InfraredSourceView : MonoBehaviour | ||
5 | +{ | ||
6 | + public GameObject InfraredSourceManager; | ||
7 | + private InfraredSourceManager _InfraredManager; | ||
8 | + | ||
9 | + void Start () | ||
10 | + { | ||
11 | + gameObject.GetComponent<Renderer>().material.SetTextureScale("_MainTex", new Vector2(-1, 1)); | ||
12 | + } | ||
13 | + | ||
14 | + void Update() | ||
15 | + { | ||
16 | + if (InfraredSourceManager == null) | ||
17 | + { | ||
18 | + return; | ||
19 | + } | ||
20 | + | ||
21 | + _InfraredManager = InfraredSourceManager.GetComponent<InfraredSourceManager>(); | ||
22 | + if (_InfraredManager == null) | ||
23 | + { | ||
24 | + return; | ||
25 | + } | ||
26 | + | ||
27 | + gameObject.GetComponent<Renderer>().material.mainTexture = _InfraredManager.GetInfraredTexture(); | ||
28 | + } | ||
29 | +} |
1 | +using UnityEngine; | ||
2 | +using System.Collections; | ||
3 | +using Windows.Kinect; | ||
4 | + | ||
5 | +public class MultiSourceManager : MonoBehaviour { | ||
6 | + public int ColorWidth { get; private set; } | ||
7 | + public int ColorHeight { get; private set; } | ||
8 | + | ||
9 | + private KinectSensor _Sensor; | ||
10 | + private MultiSourceFrameReader _Reader; | ||
11 | + private Texture2D _ColorTexture; | ||
12 | + private ushort[] _DepthData; | ||
13 | + private byte[] _ColorData; | ||
14 | + | ||
15 | + public Texture2D GetColorTexture() | ||
16 | + { | ||
17 | + return _ColorTexture; | ||
18 | + } | ||
19 | + | ||
20 | + public ushort[] GetDepthData() | ||
21 | + { | ||
22 | + return _DepthData; | ||
23 | + } | ||
24 | + | ||
25 | + void Start () | ||
26 | + { | ||
27 | + _Sensor = KinectSensor.GetDefault(); | ||
28 | + | ||
29 | + if (_Sensor != null) | ||
30 | + { | ||
31 | + _Reader = _Sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth); | ||
32 | + | ||
33 | + var colorFrameDesc = _Sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Rgba); | ||
34 | + ColorWidth = colorFrameDesc.Width; | ||
35 | + ColorHeight = colorFrameDesc.Height; | ||
36 | + | ||
37 | + _ColorTexture = new Texture2D(colorFrameDesc.Width, colorFrameDesc.Height, TextureFormat.RGBA32, false); | ||
38 | + _ColorData = new byte[colorFrameDesc.BytesPerPixel * colorFrameDesc.LengthInPixels]; | ||
39 | + | ||
40 | + var depthFrameDesc = _Sensor.DepthFrameSource.FrameDescription; | ||
41 | + _DepthData = new ushort[depthFrameDesc.LengthInPixels]; | ||
42 | + | ||
43 | + if (!_Sensor.IsOpen) | ||
44 | + { | ||
45 | + _Sensor.Open(); | ||
46 | + } | ||
47 | + } | ||
48 | + } | ||
49 | + | ||
50 | + void Update () | ||
51 | + { | ||
52 | + if (_Reader != null) | ||
53 | + { | ||
54 | + var frame = _Reader.AcquireLatestFrame(); | ||
55 | + if (frame != null) | ||
56 | + { | ||
57 | + var colorFrame = frame.ColorFrameReference.AcquireFrame(); | ||
58 | + if (colorFrame != null) | ||
59 | + { | ||
60 | + var depthFrame = frame.DepthFrameReference.AcquireFrame(); | ||
61 | + if (depthFrame != null) | ||
62 | + { | ||
63 | + colorFrame.CopyConvertedFrameDataToArray(_ColorData, ColorImageFormat.Rgba); | ||
64 | + _ColorTexture.LoadRawTextureData(_ColorData); | ||
65 | + _ColorTexture.Apply(); | ||
66 | + | ||
67 | + depthFrame.CopyFrameDataToArray(_DepthData); | ||
68 | + | ||
69 | + depthFrame.Dispose(); | ||
70 | + depthFrame = null; | ||
71 | + } | ||
72 | + | ||
73 | + colorFrame.Dispose(); | ||
74 | + colorFrame = null; | ||
75 | + } | ||
76 | + | ||
77 | + frame = null; | ||
78 | + } | ||
79 | + } | ||
80 | + } | ||
81 | + | ||
82 | + void OnApplicationQuit() | ||
83 | + { | ||
84 | + if (_Reader != null) | ||
85 | + { | ||
86 | + _Reader.Dispose(); | ||
87 | + _Reader = null; | ||
88 | + } | ||
89 | + | ||
90 | + if (_Sensor != null) | ||
91 | + { | ||
92 | + if (_Sensor.IsOpen) | ||
93 | + { | ||
94 | + _Sensor.Close(); | ||
95 | + } | ||
96 | + | ||
97 | + _Sensor = null; | ||
98 | + } | ||
99 | + } | ||
100 | +} |
No preview for this file type
597 KB
5.28 MB
1.66 MB
1.27 MB
855 KB
3.39 MB
No preview for this file type
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/Mountains_night/0.png
0 → 100644
7.44 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/Mountains_night/1.png
0 → 100644
4.95 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/Mountains_night/2.png
0 → 100644
6.11 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/Mountains_night/3.png
0 → 100644
4.57 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/Mountains_night/4.png
0 → 100644
4.15 KB
12.8 KB
5.61 KB
4.89 KB
4.72 KB
2.8 KB
7.95 KB
5.21 KB
4.68 KB
4.88 KB
3.09 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_2_day/desert_2_day.png
0 → 100644
8.29 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_2_night/0.png
0 → 100644
5.21 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_2_night/1.png
0 → 100644
4.68 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_2_night/2.png
0 → 100644
4.88 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_2_night/3.png
0 → 100644
3.1 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_2_night/poustii22.png
0 → 100644
8.26 KB
5.61 KB
4.89 KB
4.72 KB
2.84 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/desert_night/desert_night.png
0 → 100644
8.01 KB
8.2 KB
9.21 KB
2.79 KB
21.7 KB
8.47 KB
4.57 KB
3.97 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/grass_day/grass_day.png
0 → 100644
9.76 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/grass_evening/0.png
0 → 100644
8.48 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/grass_evening/1.png
0 → 100644
4.57 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/grass_evening/2.png
0 → 100644
3.94 KB
9.57 KB
8.49 KB
4.57 KB
3.93 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/grass_night/grass_night.png
0 → 100644
9.57 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_day/0.png
0 → 100644
7.45 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_day/1.png
0 → 100644
6.63 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_day/2.png
0 → 100644
6.89 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_day/3.png
0 → 100644
3.59 KB
14.5 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_morning/0.png
0 → 100644
7.45 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_morning/1.png
0 → 100644
6.6 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_morning/2.png
0 → 100644
6.88 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_morning/3.png
0 → 100644
4.57 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/mountains_morning/4.png
0 → 100644
3.6 KB
14.5 KB
5.82 KB
8.58 KB
5.87 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/sky_day/sky_day.png
0 → 100644
11.1 KB
5.81 KB
8.58 KB
5.87 KB
4.01 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/sky_evening/sky_evening.png
0 → 100644
11 KB
5.82 KB
8.57 KB
5.87 KB
4.01 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/sky_morning/sky_morning.png
0 → 100644
11 KB
5.3 KB
4.85 KB
7.45 KB
3.73 KB
2.89 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/volcano_day/volcano_day.png
0 → 100644
10.6 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/volcano_night/0.png
0 → 100644
5.3 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/volcano_night/1.png
0 → 100644
4.85 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/volcano_night/2.png
0 → 100644
7.45 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/volcano_night/3.png
0 → 100644
3.73 KB
sourcecode/capstone/Assets/Nature - pixel art backgrounds/Nature pack/volcano_night/4.png
0 → 100644
4.19 KB
11.2 KB
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
12 KB
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Script/Move.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Script/RigBone.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/AudioBeamFrameArrivedEventArgs.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/BodyIndexFrameArrivedEventArgs.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/CoordinateMappingChangedEventArgs.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/InfraredFrameArrivedEventArgs.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/LongExposureInfraredFrameReader.cs
0 → 100644
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/LongExposureInfraredFrameReference.cs
0 → 100644
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/LongExposureInfraredFrameSource.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/Standard Assets/Windows/Kinect/MultiSourceFrameArrivedEventArgs.cs
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
sourcecode/capstone/Assets/background2.png
0 → 100644
292 KB
sourcecode/capstone/NtKinectDll.dll
0 → 100644
No preview for this file type
sourcecode/capstone/Packages/manifest.json
0 → 100644
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment