void GetData() { try { if (this.client.IsAvailable > 3) { this.client.Update(ref this.data); UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); dec.Source = this.data; this.robotPos.x = dec.get_float(); this.robotPos.y = dec.get_float(); this.robotPos.z = dec.get_float(); this.robotLightPos.x = dec.get_float(); this.robotLightPos.y = dec.get_float(); this.robotLightPos.z = dec.get_float(); } } catch { Debug.Log("Error:ReceiveData"); } }
// Update is called once per frame void Update () { if (this.cipc == null) return; UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); dec.Source = this.cipc.Data; if (this.cipc.Data.Length > 1900) { dec.Source = this.cipc.Data; dec.get_int();//2 dec.get_int();//6 for (int j = 0; j < 6; j++) { dec.get_int();//0 for (int i = 0; i < 20; i++) { float x = dec.get_float();//x float y = dec.get_float();//y float z = dec.get_float();//z int state = dec.get_int();//trackingstate skst => 2 this.skeletons[j].bone[i].GlobalVec = new Vector3f(x, y, z); this.skeletons[j].bone[i].trackingstate = Bone.TrackingState.Tracked; } } this.HaveData = true; } }
List<Vector3> GetData() { List<Vector3> list_position = new List<Vector3>(); try { this.client.Update(ref this.data); UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); dec.Source = this.data; //データ格納 int humanNum = dec.get_int(); for (int i = 0; i < humanNum; i++) { float x = - (float)dec.get_double(); float z = (float)dec.get_double(); list_position.Add(new Vector3(x, 0, z)); } //Debug.Log(list_position[0].ToString()); } catch { } return list_position; }
void GetData() { try { this.client.Update(ref this.data); UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); dec.Source = this.data; //データ格納 this.List_Humans.Clear(); int MaxofHuman = (int)dec.get_byte(); int NumofHuman = (int)dec.get_byte(); this.List_Humans = new List<Human>(); for (int i = 0; i < NumofHuman; i++) { Human human = new Human(); human.id = i; human.numofBone = (int)dec.get_byte(); human.bones = new Bone[human.numofBone]; for (int j = 0; j < human.numofBone; j++) { Bone bone = new Bone(); bone.dimensiton = (int)dec.get_byte(); bone.position.x = dec.get_float(); bone.position.y = dec.get_float(); bone.position.z = dec.get_float(); bone.quaternion.x = dec.get_float(); bone.quaternion.y = dec.get_float(); bone.quaternion.z = dec.get_float(); bone.quaternion.w = dec.get_float(); bone.IsTracking = dec.get_byte(); human.bones[j] = bone; //if(j == 0) Debug.Log(bone.position.ToString()) ; } this.List_Humans.Add(human); } } catch { Debug.Log("Error:ReceiveData"); } }
void GetData() { try { this.client.Update(ref this.data); UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); dec.Source = this.data; //データ格納 this.List_Humans.Clear(); int MaxofHuman = (int)dec.get_byte(); int NumofHuman = (int)dec.get_byte(); this.List_Humans = new List <Human>(); for (int i = 0; i < NumofHuman; i++) { Human human = new Human(); human.id = i; human.numofBone = (int)dec.get_byte(); human.bones = new Bone[human.numofBone]; for (int j = 0; j < human.numofBone; j++) { Bone bone = new Bone(); bone.dimensiton = (int)dec.get_byte(); bone.position.x = dec.get_float(); bone.position.y = dec.get_float(); bone.position.z = dec.get_float(); bone.quaternion.x = dec.get_float(); bone.quaternion.y = dec.get_float(); bone.quaternion.z = dec.get_float(); bone.quaternion.w = dec.get_float(); bone.IsTracking = dec.get_byte(); human.bones[j] = bone; //if(j == 0) Debug.Log(bone.position.ToString()) ; } this.List_Humans.Add(human); } } catch { Debug.Log("Error:ReceiveData"); } }
public void Connect() { byte[] data = CLIENT.Recieve(); UPD = new UDP_PACKETS_DECODER(data); nPackets = UPD.get_int(); recieveSize = UPD.get_int(); data_length = UPD.get_int(); width = UPD.get_int(); height = UPD.get_int(); stride = UPD.get_int(); UPE=new UDP_PACKETS_ENCODER(); UPE+=(int)0; CLIENT.Send(UPE.data); isconnected = true; }
private void ReceiveSkeletonFromCIPCClient() { this.CIPCClient.Update(ref receiveddata); UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); if (this.receiveddata.Length > 1900) { dec.Source = this.receiveddata; dec.get_int();//2 dec.get_int();//6 dec.get_int();//0 for (int i = 0; i < 20; i++) { float x = dec.get_float();//x float y = dec.get_float();//y float z = dec.get_float();//z int state = dec.get_int();//trackingstate skst => 2 this.CurrentSkeleton.bone[i].GlobalVec = new Vector3f(x, y, z); this.CurrentSkeleton.bone[i].trackingstate = Bone.TrackingState.Tracked; } Debug.Log("dec.length" + dec.Length.ToString()); } }
public byte[] Recieve(int id) { if (isconnected == true) { int counter; byte[] data= new byte[data_length]; for (int i = 0; i < nPackets; i++) { byte[] _data = CLIENT.Recieve(); UPD = null; UPD = new UDP_PACKETS_DECODER(_data); if(UPD.get_int() == id) { counter = UPD.get_int(); Array.Copy(UPD.get_bytes(_data.Length - 2 * sizeof(int)), 0, data, counter * recieveSize, _data.Length - 2 * sizeof(int)); } _data = null; } return data; } else { throw new Exception("error from UDP_STREAMING, connect before to recieve."); } }
public bool[] Recieve_bool(int id) { if (isconnected == true) { int counter; bool[] data = new bool[data_length]; for (int i = 0; i < nPackets; i++) { byte[] _data = CLIENT.Recieve(); UPD = null; UPD = new UDP_PACKETS_DECODER(_data); if (UPD.get_int() == id) { counter = UPD.get_int(); for (int t = 0; t < _data.Length-2*sizeof(int); t++ ) { data[t+recieveSize*counter] = UPD.get_bool(); } } _data = null; } return data; } else { throw new Exception("error from UDP_STREAMING, connect before to recieve."); } }
void GetData() { try { while (true) { if (IsCIPC && this.client.IsAvailable > 0) { this.client.Update(ref this.data); UDP_PACKETS_CODER.UDP_PACKETS_DECODER dec = new UDP_PACKETS_CODER.UDP_PACKETS_DECODER(); dec.Source = this.data; //データ取得 CIPCKey = dec.get_string(); } } } catch { } }