public List <PoseDescription> CopyFromSingle(PoseDescription poseDescriptionToCopy) { var output = new List <PoseDescription>(40); for (int i = 0; i < 40; i++) { output.Add(new PoseDescription(poseDescriptionToCopy.data)); } return(output); }
public void ReadStream(NetworkStream networkStream, MessageHeader incomingHeader) { header = incomingHeader; poseDescriptions = new List <PoseDescription>(header.dataByte); for (int readIdx = 0; readIdx < header.dataByte; readIdx++) { PoseDescription newPoseDescription = new PoseDescription().FakeConstructor(); _ = networkStream.Read(ByteTypeConverter.SbytesTobytes(newPoseDescription.data), 0, PoseDescription.DATA_SIZE); poseDescriptions.Add(newPoseDescription); } }
public PoseDescription PackPose() { var nd = new PoseDescription().FakeConstructor(); //todo: establish how this will work, this is position in playerSpace... undecided at the moment nd.globalPosition_x = 0; nd.globalPosition_y = 0; Vector3 headPosition = Head.transform.position; Vector3 leftHandPosition = LeftHand.transform.position - headPosition; Vector3 rightHandPosition = RightHand.transform.position - headPosition; //-//Positions //head nd.head_Position_x = QuantizePosition(headPosition.x); nd.head_Position_y = QuantizePosition(headPosition.y); nd.head_Position_z = QuantizePosition(headPosition.z); //left hand nd.hand_Position_Left_x = QuantizePosition(leftHandPosition.x); nd.hand_Position_Left_y = QuantizePosition(leftHandPosition.y); nd.hand_Position_Left_z = QuantizePosition(leftHandPosition.z); //right hand nd.hand_Position_Right_x = QuantizePosition(rightHandPosition.x); nd.hand_Position_Right_y = QuantizePosition(rightHandPosition.y); nd.hand_Position_Right_z = QuantizePosition(rightHandPosition.z); //-//Rotations //head nd.head_Rotation_x = QuantizeQuaternionElement_FloatToByte(Head.transform.rotation.x); nd.head_Rotation_y = QuantizeQuaternionElement_FloatToByte(Head.transform.rotation.y); nd.head_Rotation_z = QuantizeQuaternionElement_FloatToByte(Head.transform.rotation.z); nd.head_Rotation_w = QuantizeQuaternionElement_FloatToByte(Head.transform.rotation.w); //left hand nd.hand_Rotation_Left_x = QuantizeQuaternionElement_FloatToByte(LeftHand.transform.rotation.x); nd.hand_Rotation_Left_y = QuantizeQuaternionElement_FloatToByte(LeftHand.transform.rotation.y); nd.hand_Rotation_Left_z = QuantizeQuaternionElement_FloatToByte(LeftHand.transform.rotation.z); nd.hand_Rotation_Left_w = QuantizeQuaternionElement_FloatToByte(LeftHand.transform.rotation.w); //right hand nd.hand_Rotation_Right_x = QuantizeQuaternionElement_FloatToByte(RightHand.transform.rotation.x); nd.hand_Rotation_Right_y = QuantizeQuaternionElement_FloatToByte(RightHand.transform.rotation.y); nd.hand_Rotation_Right_z = QuantizeQuaternionElement_FloatToByte(RightHand.transform.rotation.z); nd.hand_Rotation_Right_w = QuantizeQuaternionElement_FloatToByte(RightHand.transform.rotation.w); // Debug.Log($"packing current pose as {nd}"); return(nd); }
public void SetNeighbourAppearanceFromDescription(int poolsIdx, PoseDescription pd) { float positionDequantizationFactor = 0.01f; float rotationDequantizationFactor = 1f / 127f; //todo: remove this! float tempX = (2.5f - (poolsIdx % 6)) / 6f; float tempY = (2.5f - (poolsIdx / 6)) / 6f; //-//Positions //StudentSpace position Vector3 StudentGlobalPosition = SimpleMockStudentPlacer.instance.GetPositionInStudentSpace(new Vector3((pd.globalPosition_x * positionDequantizationFactor) + tempX, (pd.globalPosition_y * positionDequantizationFactor) + tempY, 0)); //head Vector3 headPosition = (new Vector3(pd.head_Position_x, pd.head_Position_y, pd.head_Position_z) * positionDequantizationFactor) + StudentGlobalPosition; Heads_Pool[poolsIdx].localPosition = headPosition; //left hand LeftHands_Pool[poolsIdx].localPosition = (new Vector3(pd.hand_Position_Left_x, pd.hand_Position_Left_y, pd.hand_Position_Left_z) * positionDequantizationFactor) + headPosition; //right hand RightHands_Pool[poolsIdx].localPosition = (new Vector3(pd.hand_Position_Right_x, pd.hand_Position_Right_y, pd.hand_Position_Right_z) * positionDequantizationFactor) + headPosition; //-//Rotations //left LeftHands_Pool[poolsIdx].localRotation = new Quaternion( pd.hand_Rotation_Left_x * rotationDequantizationFactor, pd.hand_Rotation_Left_y * rotationDequantizationFactor, pd.hand_Rotation_Left_z * rotationDequantizationFactor, pd.hand_Rotation_Left_w * rotationDequantizationFactor); //right RightHands_Pool[poolsIdx].localRotation = new Quaternion( pd.hand_Rotation_Right_x * rotationDequantizationFactor, pd.hand_Rotation_Right_y * rotationDequantizationFactor, pd.hand_Rotation_Right_z * rotationDequantizationFactor, pd.hand_Rotation_Right_w * rotationDequantizationFactor); //head Heads_Pool[poolsIdx].localRotation = new Quaternion( pd.head_Rotation_x * rotationDequantizationFactor, pd.head_Rotation_y * rotationDequantizationFactor, pd.head_Rotation_z * rotationDequantizationFactor, pd.head_Rotation_w * rotationDequantizationFactor); }
//Ctor stuff public Client(NetworkStream _networkStream) { audioData_Float = new float[SampleRate]; //one second of float audio to kick this bad boy off! MostRecentMessageTime = Environment.TickCount + 10000; if (!AssignID(out ClientID)) { throw new Exception("Server Full"); } Console.WriteLine($"client_{ClientID} connected"); networkStream = _networkStream; //member audio data should be a full second of data I think memberAudioData = new byte[SampleRate]; MostRecentPoseDescription = new PoseDescription(); }
public PoseMessage_Client() { header = new MessageHeader(MessageHeader.MessageType.poseMessage, 255); poseDescription = new PoseDescription(); }