コード例 #1
0
        private Vector3 GetBoneCoordinate(FinchBone bone)
        {
            switch (bone)
            {
            case FinchBone.LeftUpperArm:
                return(FinchCore.GetBoneCoordinate(FinchBone.LeftUpperArm));

            case FinchBone.LeftLowerArm:
                return(elbowPositions[0]);

            case FinchBone.LeftHandCenter:
                return(wristPositions[0]);

            case FinchBone.LeftHand:
                return(GetHandPositionByControllerPosition(wristPositions[0], wristOrientations[0], Vector3.left, FinchCore.GetBoneLength(FinchBone.LeftHand)));

            case FinchBone.RightUpperArm:
                return(FinchCore.GetBoneCoordinate(FinchBone.RightUpperArm));

            case FinchBone.RightLowerArm:
                return(elbowPositions[1]);

            case FinchBone.RightHand:
                return(GetHandPositionByControllerPosition(wristPositions[1], wristOrientations[1], Vector3.right, FinchCore.GetBoneLength(FinchBone.RightHand)));

            case FinchBone.RightHandCenter:
                return(wristPositions[1]);

            default:
                return(Vector3.zero);
            }
        }
コード例 #2
0
ファイル: FinchAvatar.cs プロジェクト: zyouc518/hackx-holokit
        private void HandleBone(FinchBone bone, bool isChestLike, bool onlyRotation)
        {
            HumanBodyBones avatarBone = (HumanBodyBones)bone;

            if (avatarBone >= HumanBodyBones.LastBone)
            {
                return;
            }

            if (!isChestLike && PlayerState.Bones[bone] == -1)
            {
                return;
            }

            Transform boneTransform = ModelAnimator.GetBoneTransform(avatarBone);

            if (boneTransform == null)
            {
                return;
            }

            Quaternion boneRotation = (isChestLike) ? state.GetRotation(FinchBone.Chest) : state.GetRotation(bone);

            boneTransform.rotation = GetRotationFromInnerCS(boneRotation);
            if (!onlyRotation && !isChestLike)
            {
                boneTransform.position = GetPositionFromInnerCS(state.GetPosition(bone));
            }
        }
コード例 #3
0
        private void FillControllerState(PlayerState outState)
        {
            for (int index = 0; index < PlayerState.Bones.BoneCount; ++index)
            {
                FinchBone bone = PlayerState.Bones[index];
                switch (bone)
                {
                case FinchBone.LeftUpperArm:
                case FinchBone.LeftLowerArm:
                case FinchBone.LeftHand:
                case FinchBone.LeftHandCenter:
                case FinchBone.RightUpperArm:
                case FinchBone.RightLowerArm:
                case FinchBone.RightHand:
                case FinchBone.RightHandCenter:
                {
                    outState.Rotations[index]    = GetBoneRotation(bone);
                    outState.Positions[index]    = GetBoneCoordinate(bone);
                    outState.Available[index]    = true;
                    outState.BonesLengths[index] = FinchCore.GetBoneLength(bone);
                    break;
                }

                default:
                {
                    outState.Rotations[index]    = FinchCore.GetBoneRotation(bone);
                    outState.Positions[index]    = FinchCore.GetBoneCoordinate(bone);
                    outState.Available[index]    = FinchCore.IsBoneAvailable(bone);
                    outState.BonesLengths[index] = FinchCore.GetBoneLength(bone);
                    break;
                }
                }
            }
        }
コード例 #4
0
ファイル: FinchAvatar.cs プロジェクト: zyouc518/hackx-holokit
        private float GetBoneAngleAboveHorizontInDegrees(FinchBone bone, FinchChirality chirality)
        {
            Quaternion rotation = state.GetRotation(bone);
            Vector3    localForward;

            switch (chirality)
            {
            case FinchChirality.Left:
            {
                localForward = Vector3.left;
                break;
            }

            case FinchChirality.Right:
            {
                localForward = Vector3.right;
                break;
            }

            default:
            {
                localForward = Vector3.forward;
                break;
            }
            }
            Vector3 forward  = rotation * localForward;
            float   cosAngle = Vector3.Dot(forward, Vector3.up);

            return(Mathf.Asin(cosAngle) * Mathf.Rad2Deg); //cos alpha = sin 90 - alpha
        }
コード例 #5
0
        private Quaternion GetBoneRotation(FinchBone bone)
        {
            switch (bone)
            {
            case FinchBone.LeftUpperArm:
                return(shoulderOrientations[0]);

            case FinchBone.LeftLowerArm:
                return(elbowOrientations[0]);

            case FinchBone.LeftHand:
                return(wristOrientations[0]);

            case FinchBone.LeftHandCenter:
                return(wristOrientations[0]);

            case FinchBone.RightUpperArm:
                return(shoulderOrientations[1]);

            case FinchBone.RightLowerArm:
                return(elbowOrientations[1]);

            case FinchBone.RightHand:
                return(wristOrientations[1]);

            case FinchBone.RightHandCenter:
                return(wristOrientations[1]);

            default:
                return(Quaternion.identity);
            }
        }
コード例 #6
0
            public static bool IsFingerBone(FinchBone bone)
            {
                foreach (FinchBone nonFingerBone in nonFingersBoneArray)
                {
                    if (bone == nonFingerBone)
                    {
                        return(false);
                    }
                }

                return(true);
            }
コード例 #7
0
        private static void UpdateCoordinates(PlayerState state, FinchBone[] boneChain, FinchVector3[] boneLocalPositions)
        {
            Vector3 position = Vector3.zero;

            for (int i = 1; i < boneChain.Length; ++i)
            {
                FinchBone  parent    = boneChain[i - 1];
                FinchBone  child     = boneChain[i];
                float      length    = state.BonesLengths[PlayerState.Bones[parent]];
                Quaternion parentRot = state.Rotations[PlayerState.Bones[parent]];
                position += length * (parentRot * boneLocalPositions[PlayerState.Bones[child]].ToUnity());
                state.Positions[PlayerState.Bones[child]] = position;
            }
        }
コード例 #8
0
        public override void ReadState(PlayerState outState)
        {
            base.ReadState(outState);

            for (int i = 0; i < PlayerState.Bones.BoneCount; ++i)
            {
                FinchBone bone = PlayerState.Bones[i];
                outState.Rotations[i]    = FinchCore.GetBoneRotation(bone);
                outState.Positions[i]    = FinchCore.GetBoneCoordinate(bone);
                outState.Available[i]    = FinchCore.IsBoneAvailable(bone);
                outState.BonesLengths[i] = FinchCore.GetBoneLength(bone);
            }

            outState.Positions[PlayerState.Bones[FinchBone.Head]] = outState.Positions[PlayerState.Bones[FinchBone.Neck]]
                                                                    + outState.Rotations[PlayerState.Bones[FinchBone.Hips]] * Vector3.up * outState.BonesLengths[PlayerState.Bones[FinchBone.Neck]];

            outState.Positions[PlayerState.Bones[FinchBone.RightEye]] = outState.Positions[PlayerState.Bones[FinchBone.Head]]
                                                                        + outState.Rotations[PlayerState.Bones[FinchBone.Head]] * Vector3.up * outState.BonesLengths[PlayerState.Bones[FinchBone.Head]]
                                                                        + outState.Rotations[PlayerState.Bones[FinchBone.Head]] * Vector3.forward * eyeForwardShift;
        }
コード例 #9
0
        /// <summary>
        /// Creates new instance of the FinchController with specified chirality.
        /// </summary>
        /// <param name="chirality">Right or left</param>
        public FinchController(FinchChirality chirality)
        {
            Chirality = chirality;
            switch (chirality)
            {
            case FinchChirality.Left:
                Bone     = FinchBone.LeftHandCenter;
                NodeType = FinchNodeType.LeftHand;
                break;

            case FinchChirality.Right:
                Bone     = FinchBone.RightHandCenter;
                NodeType = FinchNodeType.RightHand;
                break;

            default:
                Bone     = FinchBone.Unknown;
                NodeType = FinchNodeType.Unknown;
                break;
            }
        }
コード例 #10
0
 public static extern FinchQuaternion FinchGetBoneFPoseRotation(FinchBone bone);
コード例 #11
0
 public static extern byte FinchIsBoneAvailable(FinchBone bone);
コード例 #12
0
 /// <summary>
 ///     Returns the bone length skeletal model.
 /// </summary>
 /// <param name="bone"></param>
 /// <returns></returns>
 public static float GetBoneLength(FinchBone bone)
 {
     return(Interop.FinchGetBoneLength(bone));
 }
コード例 #13
0
 /// <summary>
 ///     Sets the value of the selected bone length.
 /// </summary>
 /// <param name="bone"></param>
 /// <param name="length"></param>
 public static void SetBoneLength(FinchBone bone, float length)
 {
     Interop.FinchSetBoneLength(bone, length);
 }
コード例 #14
0
 public static extern float FinchGetBoneLength(FinchBone bone);
コード例 #15
0
 public static extern FinchVector3 FinchGetBoneGlobalAngularVelocity(FinchBone bone);
コード例 #16
0
 private FinchController(FinchChirality chirality, FinchBone bone, FinchNodeType node)
 {
     Chirality = chirality;
     Node      = node;
     Bone      = bone;
 }
コード例 #17
0
 /// <summary>
 ///     Returns true, if bone data is available.
 /// </summary>
 /// <param name="bone"></param>
 /// <returns></returns>
 public static bool IsBoneAvailable(FinchBone bone)
 {
     return(Interop.FinchIsBoneAvailable(bone) != 0);
 }
コード例 #18
0
 public void SetBoneLength(FinchBone bone, float length)
 {
     FinchCore.SetBoneLength(bone, length);
 }
コード例 #19
0
ファイル: FinchInput.cs プロジェクト: conglifu/FinchUnitySDK
 /// <summary>
 /// Returns bone rotation.
 /// </summary>
 /// <param name="bone">Certain bone</param>
 /// <param name="fPose">Use fPose rotation</param>
 /// <returns>Bone rotation quaternion</returns>
 public static Quaternion GetBoneRotation(FinchBone bone, bool fPose = true)
 {
     return(FinchCore.GetBoneRotation(bone, fPose));
 }
コード例 #20
0
ファイル: FinchInput.cs プロジェクト: conglifu/FinchUnitySDK
 /// <summary>
 /// Returns bone position.
 /// </summary>
 /// <param name="bone">Certain bone</param>
 /// <returns>Position coordinates</returns>
 public static Vector3 GetBonePosition(FinchBone bone)
 {
     return(FinchCore.GetBonePosition(bone));
 }
コード例 #21
0
 public void SetBoneLength(FinchBone bone, float lenhth)
 {
     WarningDummy("SetBoneLength");
 }
コード例 #22
0
 public static extern FinchVector3 FinchGetBoneCoordinate(FinchBone bone);
コード例 #23
0
 public static extern FinchVector3 FinchGetBoneGlobalAcceleration(FinchBone bone);
コード例 #24
0
 /// <summary>
 ///     Returns bone acceleration in local coordinate system.
 /// </summary>
 /// <param name="bone"></param>
 /// <returns></returns>
 public static Vector3 GetBoneGlobalAcceleration(FinchBone bone)
 {
     return(Interop.FinchGetBoneGlobalAcceleration(bone).ToUnity());
 }
コード例 #25
0
 public static extern void FinchSetBoneLength(FinchBone bone, float length);
コード例 #26
0
 /// <summary>
 ///     Returns bone angular velocity vector in local coordinate system.
 /// </summary>
 /// <param name="bone"></param>
 /// <returns></returns>
 public static Vector3 GetBoneGlobalAngularVelocity(FinchBone bone)
 {
     return(Interop.FinchGetBoneGlobalAngularVelocity(bone).ToUnity());
 }
コード例 #27
0
 /// <summary>
 ///     Returns bone current orientation in space, as a quaternion.
 /// </summary>
 /// <param name="bone"></param>
 /// <param name="fPose"></param>
 /// <returns></returns>
 public static Quaternion GetBoneRotation(FinchBone bone, bool fPose = false)
 {
     return(fPose ? Interop.FinchGetBoneFPoseRotation(bone).ToUnity() : Interop.FinchGetBoneTPoseRotation(bone).ToUnity());
 }
コード例 #28
0
 public TrembleOptions(FinchBone finchBone)
 {
     bone = finchBone;
 }
コード例 #29
0
ファイル: FinchAvatar.cs プロジェクト: zyouc518/hackx-holokit
        protected void UpdateTransforms()
        {
            if (Model == ModelType.Default)
            {
                for (int i = 0; i < PlayerState.Bones.BoneCount; ++i)
                {
                    HandleBone(PlayerState.Bones[i], false, OnlyRotations);
                }
            }
            else if (Model == ModelType.Babe)
            {
                for (int i = 0; i < PlayerState.Bones.BoneCount; ++i)
                {
                    FinchBone currentBone = PlayerState.Bones[i];
                    switch (currentBone)
                    {
                    case FinchBone.LeftShoulder:
                    case FinchBone.RightShoulder:
                    {
                        HandleBone(currentBone, false, OnlyRotations);
                        break;
                    }

                    case FinchBone.LeftThumbProximal:
                    case FinchBone.LeftThumbIntermediate:
                    case FinchBone.LeftThumbDistal:
                    case FinchBone.RightThumbProximal:
                    case FinchBone.RightThumbIntermediate:
                    case FinchBone.RightThumbDistal:
                    {
                        switch (Fingers)
                        {
                        case FingerMovement.Full:
                        {
                            HandleBone(currentBone, false, OnlyRotations);
                            break;
                        }

                        case FingerMovement.OnlyRotations:
                        {
                            HumanBodyBones avatarBone = (HumanBodyBones)currentBone;

                            Transform boneTransform = ModelAnimator.GetBoneTransform(avatarBone);
                            if (boneTransform == null)
                            {
                                return;
                            }

                            Quaternion boneRotation = state.GetRotation(currentBone);

                            Quaternion babeCrutchThumbDelta = new Quaternion(-0.707107f, 0.0f, 0.0f, 0.707107f);
                            boneTransform.rotation = GetRotationFromInnerCS(boneRotation) * babeCrutchThumbDelta;
                            break;
                        }

                        default:
                            break;
                        }
                        break;
                    }

                    default:
                    {
                        if (PlayerState.BoneDictionary.IsFingerBone(currentBone))
                        {
                            switch (Fingers)
                            {
                            case FingerMovement.Full:
                                HandleBone(currentBone, false, OnlyRotations);
                                break;

                            case FingerMovement.OnlyRotations:
                                HandleBone(currentBone, false, true);
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            HandleBone(currentBone, false, OnlyRotations);
                        }
                        break;
                    }
                    }
                }
            }

            foreach (FinchBone b in ChestLikeBones)
            {
                HandleBone(b, true, OnlyRotations);
            }

            Vector3 headLocalPosition;

            if (FinchSettings.DeviceType == FinchControllerType.Dash)
            {
                headLocalPosition = state.GetPosition(FinchBone.Head);
            }
            else
            {
                headLocalPosition = state.GetPosition(FinchBone.RightEye); //Center position of both eyes
            }
            Quaternion headLocalRotation = state.GetRotation(FinchBone.Head);

            if (FinchSettings.HeadUpdateType != FinchHeadUpdateType.RotationAndPositionUpdate)
            {
                if (Camera != null && !OnlyRotations)
                {
                    Camera.transform.position = GetPositionFromInnerCS(headLocalPosition);
                }
                if (HeadVisualTransform != null)
                {
                    HeadVisualTransform.rotation = GetRotationFromInnerCS(headLocalRotation);
                }
            }
            else
            {
                if (HeadVisualTransform != null)
                {
                    HeadVisualTransform.rotation = GetRotationFromInnerCS(headLocalRotation);
                }
            }
        }
コード例 #30
0
 /// <summary>
 ///     Returns bone position relatively midpoint of left and right shoulders.
 /// </summary>
 /// <param name="bone"></param>
 /// <returns></returns>
 public static Vector3 GetBoneCoordinate(FinchBone bone)
 {
     return(Interop.FinchGetBoneCoordinate(bone).ToUnity());
 }