t1 / TFDContents / Assets / Standard Assets / Windows / Kinect / BodyFrame.cs @ 9
이력 | 보기 | 이력해설 | 다운로드 (5.73 KB)
1 |
#if !(UNITY_WSA_10_0 && NETFX_CORE) |
---|---|
2 |
using RootSystem = System; |
3 |
using System.Linq; |
4 |
using System.Collections.Generic; |
5 |
namespace Windows.Kinect |
6 |
{ |
7 |
// |
8 |
// Windows.Kinect.BodyFrame |
9 |
// |
10 |
public sealed partial class BodyFrame : RootSystem.IDisposable, Helper.INativeWrapper |
11 |
|
12 |
{ |
13 |
internal RootSystem.IntPtr _pNative; |
14 |
RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } } |
15 |
|
16 |
// Constructors and Finalizers |
17 |
internal BodyFrame(RootSystem.IntPtr pNative) |
18 |
{ |
19 |
_pNative = pNative; |
20 |
Windows_Kinect_BodyFrame_AddRefObject(ref _pNative); |
21 |
} |
22 |
|
23 |
~BodyFrame() |
24 |
{ |
25 |
Dispose(false); |
26 |
} |
27 |
|
28 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
29 |
private static extern void Windows_Kinect_BodyFrame_ReleaseObject(ref RootSystem.IntPtr pNative); |
30 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
31 |
private static extern void Windows_Kinect_BodyFrame_AddRefObject(ref RootSystem.IntPtr pNative); |
32 |
private void Dispose(bool disposing) |
33 |
{ |
34 |
if (_pNative == RootSystem.IntPtr.Zero) |
35 |
{ |
36 |
return; |
37 |
} |
38 |
|
39 |
__EventCleanup(); |
40 |
|
41 |
Helper.NativeObjectCache.RemoveObject<BodyFrame>(_pNative); |
42 |
|
43 |
if (disposing) |
44 |
{ |
45 |
Windows_Kinect_BodyFrame_Dispose(_pNative); |
46 |
} |
47 |
Windows_Kinect_BodyFrame_ReleaseObject(ref _pNative); |
48 |
|
49 |
_pNative = RootSystem.IntPtr.Zero; |
50 |
} |
51 |
|
52 |
|
53 |
// Public Properties |
54 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
55 |
private static extern int Windows_Kinect_BodyFrame_get_BodyCount(RootSystem.IntPtr pNative); |
56 |
public int BodyCount |
57 |
{ |
58 |
get |
59 |
{ |
60 |
if (_pNative == RootSystem.IntPtr.Zero) |
61 |
{ |
62 |
throw new RootSystem.ObjectDisposedException("BodyFrame"); |
63 |
} |
64 |
|
65 |
return Windows_Kinect_BodyFrame_get_BodyCount(_pNative); |
66 |
} |
67 |
} |
68 |
|
69 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
70 |
private static extern RootSystem.IntPtr Windows_Kinect_BodyFrame_get_BodyFrameSource(RootSystem.IntPtr pNative); |
71 |
public Windows.Kinect.BodyFrameSource BodyFrameSource |
72 |
{ |
73 |
get |
74 |
{ |
75 |
if (_pNative == RootSystem.IntPtr.Zero) |
76 |
{ |
77 |
throw new RootSystem.ObjectDisposedException("BodyFrame"); |
78 |
} |
79 |
|
80 |
RootSystem.IntPtr objectPointer = Windows_Kinect_BodyFrame_get_BodyFrameSource(_pNative); |
81 |
Helper.ExceptionHelper.CheckLastError(); |
82 |
if (objectPointer == RootSystem.IntPtr.Zero) |
83 |
{ |
84 |
return null; |
85 |
} |
86 |
|
87 |
return Helper.NativeObjectCache.CreateOrGetObject<Windows.Kinect.BodyFrameSource>(objectPointer, n => new Windows.Kinect.BodyFrameSource(n)); |
88 |
} |
89 |
} |
90 |
|
91 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
92 |
private static extern RootSystem.IntPtr Windows_Kinect_BodyFrame_get_FloorClipPlane(RootSystem.IntPtr pNative); |
93 |
public Windows.Kinect.Vector4 FloorClipPlane |
94 |
{ |
95 |
get |
96 |
{ |
97 |
if (_pNative == RootSystem.IntPtr.Zero) |
98 |
{ |
99 |
throw new RootSystem.ObjectDisposedException("BodyFrame"); |
100 |
} |
101 |
|
102 |
var objectPointer = Windows_Kinect_BodyFrame_get_FloorClipPlane(_pNative); |
103 |
Helper.ExceptionHelper.CheckLastError(); |
104 |
var obj = (Windows.Kinect.Vector4)RootSystem.Runtime.InteropServices.Marshal.PtrToStructure(objectPointer, typeof(Windows.Kinect.Vector4)); |
105 |
Windows.Kinect.KinectUnityAddinUtils.FreeMemory(objectPointer); |
106 |
return obj; |
107 |
} |
108 |
} |
109 |
|
110 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
111 |
private static extern long Windows_Kinect_BodyFrame_get_RelativeTime(RootSystem.IntPtr pNative); |
112 |
public RootSystem.TimeSpan RelativeTime |
113 |
{ |
114 |
get |
115 |
{ |
116 |
if (_pNative == RootSystem.IntPtr.Zero) |
117 |
{ |
118 |
throw new RootSystem.ObjectDisposedException("BodyFrame"); |
119 |
} |
120 |
|
121 |
return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_BodyFrame_get_RelativeTime(_pNative)); |
122 |
} |
123 |
} |
124 |
|
125 |
|
126 |
// Public Methods |
127 |
[RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)] |
128 |
private static extern void Windows_Kinect_BodyFrame_Dispose(RootSystem.IntPtr pNative); |
129 |
public void Dispose() |
130 |
{ |
131 |
if (_pNative == RootSystem.IntPtr.Zero) |
132 |
{ |
133 |
return; |
134 |
} |
135 |
|
136 |
Dispose(true); |
137 |
RootSystem.GC.SuppressFinalize(this); |
138 |
} |
139 |
|
140 |
private void __EventCleanup() |
141 |
{ |
142 |
} |
143 |
} |
144 |
|
145 |
} |
146 |
#endif |