Exemple #1
0
        protected override HandAttachments BuildAttachmentHand(Chirality handedness)
        {
            var hand = base.BuildAttachmentHand(handedness);

            foreach (var sphere in new Transform[] { hand.Thumb, hand.Index, hand.Middle, hand.Ring, hand.Pinky, hand.Palm })
            {
                var boneCollider = CreateCollider(sphere, -0.05f);
                boneCollider.enabled = false;
                DynamicColliderRegistry.RegisterCollider(boneCollider, (b) => !IsNotBust(b));

                boneCollider         = CreateCollider(sphere, 0.01f);
                boneCollider.enabled = false;
                DynamicColliderRegistry.RegisterCollider(boneCollider, IsNotBust);
            }
            hand.OnBegin += delegate
            {
                foreach (var collider in hand.GetComponentsInChildren <DynamicBoneCollider>())
                {
                    collider.enabled = true;
                }
            };

            hand.OnFinish += delegate
            {
                foreach (var collider in hand.GetComponentsInChildren <DynamicBoneCollider>())
                {
                    collider.enabled = false;
                }
            };

            return(hand);
        }
Exemple #2
0
        private void AssociateBoneColliders(IEnumerable <IDynamicBoneWrapper> bones)
        {
            IDictionary <DynamicBoneCollider, List <IDynamicBoneWrapper> > colliderBoneMap = new Dictionary <DynamicBoneCollider, List <IDynamicBoneWrapper> >();

            // Find colliders that are responsible for these bones
            var colliders = GetComponentsInChildren <DynamicBoneCollider>();

            foreach (var bone in bones)
            {
                var atari = colliders.FirstOrDefault(collider => bone.Colliders.Contains(collider));
                if (atari)
                {
                    if (!colliderBoneMap.ContainsKey(atari))
                    {
                        colliderBoneMap.Add(atari, new List <IDynamicBoneWrapper>());
                    }

                    colliderBoneMap[atari].Add(bone);
                    atari.m_Bound = DynamicBoneCollider.Bound.Inside;
                }
            }

            // Override the match condition for the responsible colliders to *only* cover these bones and ignore all other (because we changed the m_Bound to INside)
            foreach (var colliderBonePair in colliderBoneMap)
            {
                _ColliderOldSelectorMap[colliderBonePair.Key] = DynamicColliderRegistry.GetCondition(colliderBonePair.Key);
                DynamicColliderRegistry.RegisterCollider(colliderBonePair.Key, (collider) => colliderBonePair.Value.Contains(collider));
            }
        }
Exemple #3
0
        private void DeassociateBoneColliders()
        {
            // Revert the changes made in AssociateBoneColliders() by setting the m_Bound to Outside and restoring the old conditions
            foreach (var colliderConditionPair in _ColliderOldSelectorMap)
            {
                colliderConditionPair.Key.m_Bound = DynamicBoneCollider.Bound.Outside;
                DynamicColliderRegistry.RegisterCollider(colliderConditionPair.Key, colliderConditionPair.Value);
            }

            _ColliderOldSelectorMap.Clear();
        }
Exemple #4
0
        protected override void CreateControllers()
        {
            base.CreateControllers();

            foreach (var controller in new Controller[] { Left, Right })
            {
                var boneCollider = CreateCollider(controller.transform, -0.05f);
                boneCollider.m_Center.y = -0.03f;
                boneCollider.m_Center.z = 0.01f;
                DynamicColliderRegistry.RegisterCollider(boneCollider, (b) => !IsNotBust(b));

                boneCollider            = CreateCollider(controller.transform, 0.01f);
                boneCollider.m_Center.y = -0.03f;
                boneCollider.m_Center.z = 0.01f;
                DynamicColliderRegistry.RegisterCollider(boneCollider, IsNotBust);
            }
        }
Exemple #5
0
        protected override void CreateControllers()
        {
            base.CreateControllers();

            foreach (var controller in new Controller[] { Left, Right })
            {
                var boneCollider = new GameObject("Dynamic Collider").AddComponent <DynamicBoneCollider>();
                boneCollider.transform.SetParent(controller.transform, false);
                boneCollider.m_Radius   = 0.01f; // Does not seem to have an effect
                boneCollider.m_Height   = 0f;
                boneCollider.m_Center.y = 0;
                boneCollider.m_Center.z = 0;
                boneCollider.m_Center.x = 0;

                boneCollider.m_Bound = DynamicBoneCollider.Bound.Outside;
                DynamicColliderRegistry.RegisterCollider(boneCollider);
            }
        }