// Use this for initialization void Start() { create_CD = 1; handExists = false; hand = null; offset = new Vector3(0, -0.1f, 0); }
public void rightHandActions() { GameObject hand = GameObject.Find("CleanRobotRightHand(Clone)"); //hand is in the current frame if (hand != null) { SkeletalHand skeleton = hand.GetComponent <SkeletalHand>(); //look for the gestures that exist foreach (Gesture g in skeleton.GetLeapHand().Frame.Gestures()) { if (g.Type == Gesture.GestureType.TYPE_CIRCLE && g.Hands.Count == 1 && g.Hands.Frontmost.IsRight) { spawner_in_view_.freezeAllTraffic(); action_timer = action_time; } else if (g.Type == Gesture.GestureType.TYPESWIPE && g.Hands.Count == 1 && g.Hands.Frontmost.IsRight) { spawner_in_view_.resumeTraffic(); action_timer = action_time; } } } }
// Use this for initialization void Start() { SkeletalHand hand = this.gameObject.GetComponent <SkeletalHand>(); foreach (FingerModel finger in hand.fingers) { if (finger.GetType() == typeof(SkeletalFinger)) { SkeletalFinger skeletalFinger = finger as SkeletalFinger; if (skeletalFinger.fingerType == Finger.FingerType.TYPE_INDEX) { foreach (Transform bone in skeletalFinger.bones) { if (bone == null) { continue; } ParticleSystem ps = bone.gameObject.GetComponentInChildren <ParticleSystem>(); if (ps != null) { this.indexFingerProxy = ps; break; } } } else if (skeletalFinger.fingerType == Finger.FingerType.TYPE_THUMB) { foreach (Transform bone in skeletalFinger.bones) { if (bone == null) { continue; } ParticleSystem ps = bone.gameObject.GetComponentInChildren <ParticleSystem>(); if (ps != null) { this.thumbProxy = ps; break; } } } } } if (this.indexFingerProxy == null) { Debug.LogError("index finger stimulation proxy is missing..."); } if (this.thumbProxy == null) { Debug.LogError("thumb stimulation proxy is missing..."); } this.stopParticleSystems(); }
// Update is called once per frame void Update() { if (create_CD > 0.05f) { if (FindObjectOfType<SkeletalHand>()) { hand = FindObjectOfType<SkeletalHand>(); GameObject lightobj = Instantiate(l, hand.GetPalmCenter() + offset, transform.rotation) as GameObject; Destroy(lightobj, 0.7f); hand = null; } } create_CD += Time.deltaTime; }
private int UpdateHand(IDictionary <string, SkeletalHand> hands, string name, int id) { int newId = id; if (hands.ContainsKey(name)) { SkeletalHand handModel = hands[name]; newId = handModel.GetInstanceID(); if (id == -1 || id != newId) { SetHandMaterial(handModel, defaultMaterial); } } return(newId); }
// Use this for initialization void Start() { camera = GetComponent <Camera>(); camera.clearFlags = CameraClearFlags.SolidColor; // HandModel hand_model = GameObject.Find("HandModel").GetComponent<HandModel>(); noob = GameObject.Find("HandController").GetComponent <HandController>(); bob = GameObject.Find("KnobbyHand").GetComponent <SkeletalHand>(); //GameObject.Find("HandController").GetLeapController(); //GUI.backgroundColor = Color.blue; //a = GameObject.Find("KnobbyHand").GetComponent<Pointable>().TipPosition.z;//GetComponent<Transform>().position.z; //a = GameObject.Find("KnobbyFinger 1").GetComponent<Pointable>().TipPosition.z;//GetComponent<Transform>().position.z; text = GameObject.Find("Text").GetComponent <UnityEngine.UI.Text>(); }
private void SetPalmMaterial(SkeletalHand hand, Material material) { if (hand.palm != null) { Transform torus = hand.palm.Find("torus"); if (torus != null) { torus = torus.Find("torus"); if (torus != null) { Renderer r = torus.GetComponent <Renderer>(); r.material = material; } } } }
public void leftHandActions() { GameObject hand = GameObject.Find("CleanRobotLeftHand(Clone)"); if (hand != null) { Debug.Log("ing here"); SkeletalHand skeleton = hand.GetComponent <SkeletalHand>(); foreach (Gesture g in skeleton.GetLeapHand().Frame.Gestures()) { if (g.Type == Gesture.GestureType.TYPE_CIRCLE && g.Hands.Count == 1 && g.Hands.Frontmost.IsLeft) { if (rotate_timer_ < 0) { rotate90(1); } } } } }
void Update() { SkeletalHand skeletal_hand = GetComponent <SkeletalHand>(); Hand leap_hand = skeletal_hand.GetLeapHand(); if (leap_hand == null) { return; } if (leap_hand.GrabStrength < GRAB_TRIGGER && handSpawn != null && wait <= 0) { GameObject spawn = Instantiate(handSpawn, skeletal_hand.GetPalmCenter(), Quaternion.identity) as GameObject; spawn.rigidbody.velocity = VELOCITY_SPAWN * (skeletal_hand.GetPalmRotation() * Vector3.down); wait = SPAWN_WAIT_ITERATIONS; Physics.IgnoreCollision(skeletal_hand.palm.collider, spawn.collider); } wait--; }
private void SetFingerMaterial(SkeletalHand hand, Material material) { foreach (var finger in hand.fingers) { if (finger != null) { foreach (var bone in finger.bones) { if (bone != null) { foreach (Transform child in bone.transform) { if (child != null) { Renderer r = child.GetComponent <Renderer>(); r.material = material; } } } } } } }
private IDictionary <string, SkeletalHand> FindHands() { IDictionary <string, SkeletalHand> hands = new Dictionary <string, SkeletalHand>(); string name = "leftHand"; foreach (Transform gameObject in handsPrefab.transform) { if (gameObject.name == "MinimalHand(Clone)") { SkeletalHand sh = gameObject.GetComponent <SkeletalHand>(); Hand hand = sh.GetLeapHand(); if (hand.IsRight) { name = "rightHand"; } hands[name] = sh; } } return(hands); }
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); }
public void SetHandMaterial(SkeletalHand hand, Material material) { SetPalmMaterial(hand, material); SetFingerMaterial(hand, material); }