私はバイトを受け取り、おそらくfloatへの変換を実行し、変換された値を表す必要があるコードを持っています:
public float DecodeFloat(byte[] data)
{
float x = data[3]|data[2]<<8|data[1]<<16|data[0]<<24;
return x;
}
// receive thread
private void ReceiveData()
{
int count=0;
IPEndPoint remoteIP = new IPEndPoint(IPAddress.Parse("10.0.2.213"), port);
client = new UdpClient(remoteIP);
while (true)
{
try
{
IPEndPoint anyIP = new IPEndPoint(IPAddress.Any, 0);
byte[] data = client.Receive(ref anyIP);
Vector3 vec,rot;
float x= DecodeFloat (data);
float y= DecodeFloat (data + 4);
float z= DecodeFloat (data + 8);
float alpha= DecodeFloat (data + 12);
float theta= DecodeFloat (data +16);
float phi= DecodeFloat (data+20);
vec.Set(x,y,z);
rot.Set (alpha,theta,phi);
print(">> " + x.ToString() + ", "+ y.ToString() + ", "+ z.ToString() + ", "
+ alpha.ToString() + ", "+ theta.ToString() + ", "+ phi.ToString());
// latest UDPpacket
lastReceivedUDPPacket=x.ToString()+" Packet#: "+count.ToString();
count = count+1;
}
私を正しい方法で配置してくれる人はいますか?