00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00036 #include "KinectUser.h"
00037
00038 #include "../core/Exception.h"
00039 #include "../core/DataSkeleton.h"
00040 #include "../DeviceManager.h"
00041 #include "../generator/User.h"
00042 #include "KinectDevice.h"
00043
00044 #include "../ScolPlugin.h"
00045
00046 namespace NIDevice
00047 {
00048 namespace Objects
00049 {
00050
00051 KinectUser::KinectUser()
00052 {
00053 }
00054
00055 KinectUser::KinectUser(NIDevice::Objects::KinectDevice* pDevice)
00056 {
00057 p_KinectDevice = pDevice;
00058 m_DataSkeleton = new NIDevice::Core::DataSkeleton(this);
00059 uId = -1;
00060
00061 GenerateColor();
00062 }
00063
00064
00065 KinectUser::~KinectUser()
00066 {
00067 if (uId > 0)
00068 p_KinectDevice->AddExistingId(uId);
00069
00070 if (p_KinectDevice->GetUserGenerator())
00071 p_KinectDevice->GetUserGenerator()->stopTracking(this);
00072
00073 SAFE_DELETE(m_DataSkeleton);
00074
00075 p_KinectDevice = 0;
00076 }
00077
00078 void KinectUser::GenerateColor()
00079 {
00080 unsigned int r = rand() %255;
00081 unsigned int g = rand() %255;
00082 unsigned int b = rand() %255;
00083 color = r + (g << 8) + (b << 16);
00084 }
00085
00086 NIDevice::Objects::KinectDevice* KinectUser::GetParentDevice()
00087 {
00088 return p_KinectDevice;
00089 }
00090
00091 NIDevice::Core::DataSkeleton* KinectUser::GetSkeletonData()
00092 {
00093 return m_DataSkeleton;
00094 }
00095
00096 void KinectUser::SetId(int id)
00097 {
00098 uId = id;
00099 GenerateColor();
00100 }
00101
00102 int KinectUser::GetId()
00103 {
00104 return uId;
00105 }
00106
00107 }
00108 }
00109