Beispiel #1
0
        // Update is called once per frame
        void Update()
        {
            if (!CVInterface.AreDatasAvailable())
            {
                return;
            }

            foreach (KeyValuePair <IRISJoints.Joints, Transform> couples in JointsToTransforms)
            {
                if (CVInterface.IsJointTracked(couples.Key))
                {
                    Vector3 p = CVInterface.GetJointPos3D(couples.Key);

                    couples.Value.position = Vector3.Lerp(couples.Value.position, p, .5f);
                }
            }

            Vector3 ol = LeftShoulderT.position;
            Vector3 or = RightShoulderT.position;

            // shoulders positions hack to straighten the middle mesh x-->  <--x
            LeftShoulderT.position  = Vector3.Lerp(ol, or, .15f);
            RightShoulderT.position = Vector3.Lerp(ol, or, .85f);

            foreach (Link l in links)
            {
                Vector3 delta = l.j2.position - l.j1.position;
                if (delta == Vector3.zero)
                {
                    continue;
                }

                if (l.tr == null)
                {
                    continue;
                }

                l.tr.position = l.j1.position + (delta) / 2f;
                l.tr.rotation = Quaternion.LookRotation(delta) * Quaternion.LookRotation(Vector3.up);
                Vector3 s = l.tr.localScale;
                l.tr.localScale = new Vector3(s.x, (l.j2.position - l.j1.position).magnitude / 2f, s.z);
            }

            DrawMiddle();
        }