public static void Initialize(out AvatarState s, int clientId, Pose p, GameObject leftHandHeldObj, GameObject rightHandHeldObj) { s.clientId = clientId; s.headPosition = p.headPosition; s.headRotation = p.headRotation; s.leftHandPosition = p.handLeftPosition; s.leftHandRotation = p.handLeftRotation; s.leftHandGripTrigger = p.handLeftPose.gripFlex; s.leftHandIdTrigger = p.handLeftPose.indexFlex; s.isLeftHandPointing = p.handLeftPose.isPointing; s.areLeftHandThumbsUp = p.handLeftPose.isThumbUp; if (leftHandHeldObj) { s.isLeftHandHoldingCube = true; var cube = leftHandHeldObj.GetComponent <NetworkCube>(); s.leftHandCubeId = cube.cubeId; s.leftHandAuthorityId = cube.authorityPacketId; s.leftHandOwnershipId = cube.ownershipId; s.leftHandCubeLocalPosition = leftHandHeldObj.transform.localPosition; s.leftHandCubeLocalRotation = leftHandHeldObj.transform.localRotation; } else { s.isLeftHandHoldingCube = false; s.leftHandCubeId = -1; s.leftHandAuthorityId = 0; s.leftHandOwnershipId = 0; s.leftHandCubeLocalPosition = zero; s.leftHandCubeLocalRotation = identity; } s.rightHandPosition = p.handRightPosition; s.rightHandRotation = p.handRightRotation; s.rightHandGripTrigger = p.handRightPose.gripFlex; s.rightHandIdTrigger = p.handRightPose.indexFlex; s.isRightHandPointing = p.handRightPose.isPointing; s.areRightHandThumbsUp = p.handRightPose.isThumbUp; if (rightHandHeldObj) { s.isRightHandHoldingCube = true; var network = rightHandHeldObj.GetComponent <NetworkCube>(); s.rightHandCubeId = network.cubeId; s.rightHandAuthorityId = network.authorityPacketId; s.rightHandOwnershipId = network.ownershipId; s.rightHandCubeLocalPosition = rightHandHeldObj.transform.localPosition; s.rightHandCubeLocalRotation = rightHandHeldObj.transform.localRotation; } else { s.isRightHandHoldingCube = false; s.rightHandCubeId = -1; s.rightHandAuthorityId = 0; s.rightHandOwnershipId = 0; s.rightHandCubeLocalPosition = zero; s.rightHandCubeLocalRotation = identity; } s.voiceAmplitude = p.voiceAmplitude; }
void RecordPose(float delta, Pose p) { if (packet == null) //If this is our first packet, store the pose as the initial frame { packet = new OvrAvatarPacket(p); delta = 0; } var recorded = 0f; while (recorded < delta) { var left = delta - recorded; var inPacket = PacketDurationSec - packet.LastTime; //what if it's negative? if (left < inPacket) //If we're not going to fill the packet, just add the frame { packet.AddFrame(p, left); recorded += left; } else { // If we're going to fill the packet, interpolate the pose, send the packet, // and open a new one // Interpolate between the packet's last frame and our target pose // to compute a pose at the end of the packet time. var pose = Pose.Interpolate(packet.LastFrame, p, inPacket / left); packet.AddFrame(pose, inPacket); recorded += inPacket; PacketRecorded?.Invoke(this, new PacketEventArgs(packet)); //Broadcast the recorded packet packet = new OvrAvatarPacket(pose); //Open a new packet } } }
public static void Write(this BinaryWriter w, Frame f) { w.Write(f.headPosition); w.Write(f.headRotation); w.Write(f.handLeftPosition); w.Write(f.handLeftRotation); w.Write(f.handRightPosition); w.Write(f.handRightRotation); w.Write(f.voiceAmplitude); w.Write(f.controllerLeftPose); w.Write(f.controllerRightPose); w.Write(f.handLeftPose); w.Write(f.handRightPose); }
public static void UpdatePose(ref AvatarState s, int clientId, Pose p, Context context) { p.headPosition = s.headPosition; p.headRotation = s.headRotation; p.handLeftPosition = s.leftHandPosition; p.handLeftRotation = s.leftHandRotation; p.handLeftPose.gripFlex = s.leftHandGripTrigger; p.handLeftPose.indexFlex = s.leftHandIdTrigger; p.handLeftPose.isPointing = s.isLeftHandPointing; p.handLeftPose.isThumbUp = s.areLeftHandThumbsUp; p.handRightPosition = s.rightHandPosition; p.handRightRotation = s.rightHandRotation; p.handRightPose.gripFlex = s.rightHandGripTrigger; p.handRightPose.indexFlex = s.rightHandIdTrigger; p.handRightPose.isPointing = s.isRightHandPointing; p.handRightPose.isThumbUp = s.areRightHandThumbsUp; p.voiceAmplitude = s.voiceAmplitude; }
public Frame GetPoseFrame(float seconds) { if (frames.Count == 1) { return(frames[0]); } int id = 1; //This can be replaced with a more efficient binary search while (id < times.Count && times[id] < seconds) { ++id; } var from = times[id - 1]; var to = times[id]; var time = (seconds - from) / (to - from); return(Frame.Interpolate(frames[id - 1], frames[id], time)); }
public void AddFrame(Frame frame, float delta) { times.Add(LastTime + delta); frames.Add(frame); }
List <byte[]> audios = new List <byte[]>(); //encodedAudioPackets public OvrAvatarPacket(Frame initialPose) { times.Add(0.0f); frames.Add(initialPose); }