Exemple #1
0
        public static Curve MakeThirdDotLine(FingerDot[] fingerDots, float smoothes)
        {
            List <Vector3> totalPoints = new List <Vector3>();

            for (int i = 0; i < fingerDots.Length - 1; i++)
            {
                var       dotsToSmooth = new List <Vector3>();
                FingerDot left         = fingerDots[i];
                FingerDot right        = fingerDots[i + 1];

                dotsToSmooth.Add(left.transform.position - left.transform.parent.position);
                if (left.RightDot != null)
                {
                    dotsToSmooth.Add(left.RightDot.position - left.transform.parent.position);
                }

                if (right.LeftDot != null)
                {
                    dotsToSmooth.Add(right.LeftDot.position - right.transform.parent.position);
                }

                dotsToSmooth.Add(right.transform.position - right.transform.parent.position);
                List <Vector3> smoothDots = SmoothDots(dotsToSmooth.ToArray(), smoothes).ToList();
                smoothDots.RemoveAt(smoothDots.Count - 1);
                totalPoints.AddRange(smoothDots);
            }
            totalPoints.Add(fingerDots[fingerDots.Length - 1].transform.position - fingerDots[fingerDots.Length - 1].transform.parent.position);
            return(new Curve(totalPoints.ToArray()));
        }
Exemple #2
0
        public void AutoGetDots()
        {
            if (_fingerDots == null)
            {
                _childCount = -1;
            }
            if (_previousCurveType != TypeOfCurve)
            {
                WorkWithExtraDots();
                _previousCurveType = TypeOfCurve;
            }

            if (_childCount != _transform.childCount)
            {
                _childCount = _transform.childCount;
                List <FingerDot> childDots = new List <FingerDot>();
                for (int i = 0; i < _transform.childCount; i++)
                {
                    Transform child     = _transform.GetChild(i);
                    FingerDot fingerDot = child.GetComponent <FingerDot>();
                    if (fingerDot != null)
                    {
                        childDots.Add(fingerDot);
                    }
                }
                _fingerDots = childDots.ToArray();
                WorkWithExtraDots();
            }
        }
Exemple #3
0
    private void Initialize()
    {
        _boneDots    = new List <BoneDot>();
        _fingerDots  = new List <FingerDot>();
        _ovrSkeleton = GetComponent <OVRSkeleton>();

        for (int i = 0; i < BoneDirectionIndex.Length / 3; i++)
        {
            var boneVis = new BoneDot(
                _ovrSkeleton.Bones[BoneDirectionIndex[i, 0]].Transform,
                _ovrSkeleton.Bones[BoneDirectionIndex[i, 1]].Transform,
                _ovrSkeleton.Bones[BoneDirectionIndex[i, 2]].Transform);

            _boneDots.Add(boneVis);
        }

        for (int i = 0; i < Enum.GetNames(typeof(FingerIndex)).Length; i++)
        {
            FingerDot Fing;
            if (i == 0)
            {
                Fing = new FingerDot(_boneDots[0], _boneDots[1]);
            }
            else
            {
                Fing = new FingerDot(_boneDots[2 + 3 * (i - 1)], _boneDots[3 + 3 * (i - 1)], _boneDots[4 + 3 * (i - 1)]);
            }
            _fingerDots.Add(Fing);
        }

        _isInitialized = true;
    }