public static HVRHandPoseData FromByteArray(byte[] bytes, HVRHandSide side) { var pose = new HVRHandPoseData(); using (var ms = new MemoryStream(bytes)) { using (var reader = new BinaryReader(ms)) { pose.Position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); pose.Rotation = new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); var fingers = reader.ReadInt32(); for (var i = 0; i < fingers; i++) { var finger = new HVRPosableFingerData(); finger.Bones = new List <HVRPosableBoneData>(); switch (i) { case 0: pose.Thumb = finger; break; case 1: pose.Index = finger; break; case 2: pose.Middle = finger; break; case 3: pose.Ring = finger; break; case 4: pose.Pinky = finger; break; } var bones = reader.ReadInt32(); for (var j = 0; j < bones; j++) { var bone = new HVRPosableBoneData(); finger.Bones.Add(bone); bone.Position = new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); bone.Rotation = new Quaternion(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle()); } } } } return(pose); }
public HVRPosableFingerData DeepCopy() { var finger = new HVRPosableFingerData(); foreach (var bone in Bones) { finger.Bones.Add(bone.DeepCopy()); } return(finger); }