Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        public HVRHandPoseData DeepCopy()
        {
            var copy = new HVRHandPoseData();

            copy.Position = Position;
            copy.Rotation = Rotation;
            copy.Thumb    = Thumb?.DeepCopy();
            copy.Index    = Index?.DeepCopy();
            copy.Middle   = Middle?.DeepCopy();
            copy.Ring     = Ring?.DeepCopy();
            copy.Pinky    = Pinky?.DeepCopy();

            return(copy);
        }