Esempio n. 1
0
 public override void tick(float dt)
 {
     if (SimpleIK.intersection(0, 0, this.radius1, (this.targetAbs.v - this.basisAbs.v).length(), 0, this.radius2))
     {
         if ((SimpleIK.yi > 0))
         {
             this.resultAbs.v = this.calc(new Vector2(SimpleIK.xi, SimpleIK.yi));
         }
         else
         {
             this.resultAbs.v = this.calc(new Vector2(SimpleIK.xi_prime, SimpleIK.yi_prime));
         }
     }
 }
Esempio n. 2
0
        public override void tick(float dt)
        {
            isInError = false;
            float len = (targetAbs.v - basisAbs.v).length();

//            len = Math.Max(len, Math.Abs(radius1 - radius2)*1.01f);
//            len = Math.Min(len, Math.Abs(radius1 + radius2)*0.99f); - must not happen
            if (SimpleIK.intersection(radius1, len, radius2))
            {
//            if (SimpleIK.intersection(0, 0, radius1, len, 0, radius2)) {
                if (SimpleIK.yi > 0)
                {
                    resultAbs.v = calc(new Vector2(SimpleIK.xi, SimpleIK.yi));
                }
                else
                {
                    resultAbs.v = calc(new Vector2(SimpleIK.xi_prime, SimpleIK.yi_prime));
                }
            }
            else
            {
                isInError = true;
                float ratio = radius1 / (radius1 + radius2);
                if (!float.IsInfinity(ratio))
                {
                    resultAbs.v = basisAbs.v.mix(targetAbs.v, ratio);
                }
            }

            if (float.IsNaN(resultAbs.v.x) || float.IsNaN(resultAbs.v.y) || float.IsNaN(resultAbs.v.z))
            {
                isInError = true;
                Debug.Log("!" + resultAbs.v + " " + radius1 + " " + radius2);
                Debug.Log("!!" + targetAbs.v);
            }
        }
        void Awake()
        {
            this.rootCapsuleCollider = this.GetComponent <CapsuleCollider>();
            this.capsuleColliders    = this.GetComponentsInChildren <CapsuleCollider>().ToList();
            this.capsuleColliders.Remove(this.rootCapsuleCollider);

            this.simpleHumanVRController = this.GetComponentInChildren <SimpleHumanVRController>();
            this.simpleIK = this.GetComponentInChildren <SimpleIK>();
            this.cleanupAvatarVRHandControllers = this.GetComponentsInChildren <CleanupAvatarVRHandController>().ToList();

            ExecutionMode executionMode = (ExecutionMode)Enum.ToObject(typeof(ExecutionMode), CleanupConfig.Instance.configFileInfo.executionMode);

            switch (executionMode)
            {
            // For the competition. Read generated data.
            case ExecutionMode.Competition:
            {
                this.ovrCameraRig.SetActive(false);
                this.avatarAnimator.enabled = false;

                CleanupAvatarVRHandController[] cleanupAvatarVRHandControllers = this.GetComponentsInChildren <CleanupAvatarVRHandController>();

                foreach (CleanupAvatarVRHandController cleanupAvatarVRHandController in cleanupAvatarVRHandControllers)
                {
                    cleanupAvatarVRHandController.enabled = false;
                }

                this.rootCapsuleCollider.enabled = false;
                foreach (CapsuleCollider capsuleCollider in this.capsuleColliders)
                {
                    capsuleCollider.enabled = true;
                }

                this.simpleHumanVRController.enabled = false;
                this.simpleIK.enabled = false;
                foreach (CleanupAvatarVRHandController cleanupAvatarVRHandController in this.cleanupAvatarVRHandControllers)
                {
                    cleanupAvatarVRHandController.enabled = false;
                }

                this.initialPositionMarker.SetActive(false);

                this.enabled = false;

                break;
            }

            // For data generation.
            case ExecutionMode.DataGeneration:
            {
                this.ovrCameraRig.SetActive(true);
                this.avatarAnimator.enabled = true;

                this.rootCapsuleCollider.enabled = true;
                foreach (CapsuleCollider capsuleCollider in this.capsuleColliders)
                {
                    capsuleCollider.enabled = false;
                }

                this.simpleHumanVRController.enabled = true;
                this.simpleIK.enabled = true;
                foreach (CleanupAvatarVRHandController cleanupAvatarVRHandController in this.cleanupAvatarVRHandControllers)
                {
                    cleanupAvatarVRHandController.enabled = true;
                }

                this.initialPositionMarker.SetActive(true);

                break;
            }

            default:
            {
                throw new Exception("Illegal Execution mode. mode=" + CleanupConfig.Instance.configFileInfo.executionMode);
            }
            }
        }
        void Awake()
        {
            this.capsuleColliders = this.GetComponentsInChildren <CapsuleCollider>().ToList();
            this.capsuleColliders.Remove(this.rootCapsuleCollider);

            this.simpleHumanVRController = this.GetComponentInChildren <SimpleHumanVRController>();
            this.simpleIK = this.GetComponentInChildren <SimpleIK>();
            this.cleanupAvatarVRHandControllers = this.GetComponentsInChildren <CleanupAvatarVRHandController>().ToList();

            ExecutionMode executionMode = (ExecutionMode)Enum.ToObject(typeof(ExecutionMode), CleanupConfig.Instance.configFileInfo.executionMode);

            switch (executionMode)
            {
            // For the competition. Read generated data.
            case ExecutionMode.Competition:
            {
                this.cameraRig.SetActive(false);
                this.avatarAnimator.enabled = false;

                this.rootCapsuleCollider.enabled = false;
                foreach (CapsuleCollider capsuleCollider in this.capsuleColliders)
                {
                    capsuleCollider.enabled = true;
                }

                this.simpleHumanVRController.enabled = false;
                this.simpleIK.enabled = false;
                foreach (CleanupAvatarVRHandController cleanupAvatarVRHandController in this.cleanupAvatarVRHandControllers)
                {
                    cleanupAvatarVRHandController.enabled = false;
                }

                this.initialPositionMarker.SetActive(false);

                // Add for SteamVR START
                Rigidbody[] rigidbodies = this.GetComponentsInChildren <Rigidbody>(true);
                foreach (Rigidbody rigidbody in rigidbodies)
                {
                    rigidbody.useGravity = false;
                }
                // Add for SteamVR END

                this.enabled = false;

                break;
            }

            // For data generation.
            case ExecutionMode.DataGeneration:
            {
                StartCoroutine(this.InitializeHumanForDataGeneration());

                break;
            }

            default:
            {
                throw new Exception("Illegal Execution mode. mode=" + CleanupConfig.Instance.configFileInfo.executionMode);
            }
            }
        }