new protected HandModel CreateHand(HandModel model) { HandModel hand_model = Instantiate(model, transform.position, transform.rotation) as HandModel; hand_model.gameObject.SetActive(true); ParticleSystem[] particleSystems = hand_model.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem system in particleSystems) { system.Stop(); } Utils.IgnoreCollisions(hand_model.gameObject, gameObject); // add scripts... foreach (FingerModel finger in hand_model.fingers) { if (finger.GetType() == typeof(RigidFinger)) { RigidFinger rigidFinger = finger as RigidFinger; foreach (Transform bone in rigidFinger.bones) { if (bone == null) { continue; } GameObject bGameObject = bone.gameObject; Rigidbody bRigidBody = bGameObject.gameObject.GetComponent <Rigidbody>() as Rigidbody; bRigidBody.isKinematic = false; bRigidBody.useGravity = false; bRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; } rigidFinger.bones[rigidFinger.bones.Length - 1].gameObject.tag = "FingerTip"; } } Collider[] allCls = hand_model.GetComponentsInChildren <Collider>(); foreach (Collider lcl in allCls) { foreach (Collider refCl in allCls) { if (!lcl.Equals(refCl)) { //Physics.IgnoreCollision(lcl, refCl, true); } } } return(hand_model); }
private void IgnoreHandCollisions(HandModel hand) { // Ignores hand collisions with immovable objects. Collider[] colliders = gameObject.GetComponentsInChildren<Collider>(); Collider[] hand_colliders = hand.GetComponentsInChildren<Collider>(); for (int i = 0; i < colliders.Length; ++i) { for (int h = 0; h < hand_colliders.Length; ++h) { if (colliders[i].rigidbody == null) Physics.IgnoreCollision(colliders[i], hand_colliders[h]); } } }
private void IgnoreHandCollisions(HandModel hand) { // Ignores hand collisions with immovable objects. Collider[] colliders = gameObject.GetComponentsInChildren <Collider>(); Collider[] hand_colliders = hand.GetComponentsInChildren <Collider>(); for (int i = 0; i < colliders.Length; ++i) { for (int h = 0; h < hand_colliders.Length; ++h) { if (colliders[i].rigidbody == null) { Physics.IgnoreCollision(colliders[i], hand_colliders[h]); } } } }
new protected HandModel CreateHand(HandModel model) { HandModel hand_model = Instantiate(model, transform.position, transform.rotation) as HandModel; hand_model.gameObject.SetActive(true); ParticleSystem[] particleSystems = hand_model.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem system in particleSystems) { system.Stop(); } Utils.IgnoreCollisions(hand_model.gameObject, gameObject); // add scripts... foreach (FingerModel finger in hand_model.fingers) { if (finger.GetType() == typeof(RigidFinger)) { RigidFinger rigidFinger = finger as RigidFinger; foreach (Transform bone in rigidFinger.bones) { if (bone == null) { continue; } GameObject bGameObject = bone.gameObject; Rigidbody bRigidBody = bGameObject.gameObject.GetComponent <Rigidbody>() as Rigidbody; bRigidBody.isKinematic = false; bRigidBody.useGravity = false; bRigidBody.collisionDetectionMode = CollisionDetectionMode.ContinuousDynamic; } rigidFinger.bones[rigidFinger.bones.Length - 1].gameObject.tag = "FingerTip"; } } // add grasp script if (hand_model.GetType() == typeof(RigidHand)) { hand_model.gameObject.AddComponent <GraspController>(); GraspController graspController = hand_model.gameObject.GetComponent <GraspController>(); //graspController.GraspTriggerDistance = 1.0f * this.GraspDistanceScale; //graspController.ReleaseTriggerDistance = 2.5f * this.GraspDistanceScale; graspController.GraspObjectDistance = 3.5f * this.GraspDistanceScale * transform.localScale.x; } Collider[] allCls = hand_model.GetComponentsInChildren <Collider>(); foreach (Collider lcl in allCls) { foreach (Collider refCl in allCls) { if (!lcl.Equals(refCl)) { Physics.IgnoreCollision(lcl, refCl, true); } } } if (this.enableFingerParticleSystems && hand_model.GetType() == typeof(SkeletalHand)) { SkeletalHand skeletalHand = hand_model as SkeletalHand; foreach (FingerModel finger in skeletalHand.fingers) { if (finger.GetType() == typeof(SkeletalFinger)) { SkeletalFinger skeletalFinger = finger as SkeletalFinger; if (skeletalFinger.fingerType == Finger.FingerType.TYPE_INDEX) { Transform bone = skeletalFinger.bones[skeletalFinger.bones.Length - 1]; /*GameObject indexProxy = GameObject.Instantiate(this.IndexStimulationProxyPrefab, Vector3.zero, Quaternion.identity) as GameObject; * indexProxy.transform.parent = bone; * indexProxy.transform.localPosition = Vector3.zero;*/ } else if (skeletalFinger.fingerType == Finger.FingerType.TYPE_THUMB) { Transform bone = skeletalFinger.bones[skeletalFinger.bones.Length - 1]; /*GameObject thumbProxy = GameObject.Instantiate(this.ThumbStimulationProxyPrefab, Vector3.zero, Quaternion.identity) as GameObject; * thumbProxy.transform.parent = bone; * thumbProxy.transform.localPosition = Vector3.zero;*/ } } } //skeletalHand.gameObject.AddComponent<StimulationProxy>(); } return(hand_model); }