// Update is called once per frame void FixedUpdate() { if (gestureManager.noSpellActive()) { UpdatePinch(); if (pinching && grabbedObject != null) { //Get relative movement based on palm position Vector3 palmPosition = leapManager.GetPalmWorldPosition(); Vector3 palmMovement = palmPosition - prevPalmPosition; prevPalmPosition = palmPosition; //Find the vector towards the thumb Vector3 directionToThumb = grabPosition - grabbedObject.transform.position; releaseVectors.Add(palmMovement); if (releaseVectors.Count >= 6) { releaseVectors.RemoveAt(0); } grabbedObject.attachedRigidbody.useGravity = false; grabbedObject.attachedRigidbody.MovePosition(grabPosition); //DEBUGGING: //grabbedObject.gameObject.GetComponent<Renderer> ().material.color = Color.magenta; } } }
private void UpdateBonePositions() { //For core corePosition = leapManager.GetPalmWorldPosition(); core.GetComponent <CoreManager>().targetPosition = corePosition; //For palm for (int i = 0; i < palmBoneCount; i++) { //Scale all offsets, based on grib strength //--- //Update stored positions/rotations palmBoneRotations [i] = leapManager.GetPalmRotation() /** Quaternion.Euler(Vector3.up * 180) * Quaternion.Euler(Vector3.forward * 180)*/; //EXTEND HERE, TO ACCOMODATE MORE PALMBONES! //palmBonePositions [i] = manager.GetPalmWorldPosition () +palmBoneOffsets [i]; Vector3 newOffset = -palmBoneOffsets [i]; newOffset = Quaternion.Euler(leapManager.GetPalmRotation().eulerAngles) * newOffset; palmBonePositions [i] = leapManager.GetPalmWorldPosition() + newOffset * fingerBoneScale * 0.75f; //Update bones palm_bones [i].GetComponent <BoneManager>().targetPosition = palmBonePositions[i]; palm_bones [i].GetComponent <BoneManager>().targetRotation = palmBoneRotations[i]; } //For fingers for (int i = 0; i < fingerCount; i++) { for (int j = 0; j < fingerBoneCount; j++) { //Treat positions differently, depending on if it's thumb or some other finger switch (i) { case 0: //Thumb switch (j) { case 0: fingerBonePositions [i, j] = leapManager.GetBoneCenterWorldPosition(i, 1); break; case 1: fingerBonePositions [i, j] = leapManager.GetBoneBaseWorldPosition(i, 2); break; case 2: fingerBonePositions [i, j] = leapManager.GetBoneCenterWorldPosition(i, 2); break; case 3: fingerBonePositions [i, j] = leapManager.GetBoneBaseWorldPosition(i, 3); break; } break; default: //Other fingers //Update stored positions/rotations fingerBonePositions [i, j] = leapManager.GetBoneCenterWorldPosition(i, j); break; } fingerBoneRotations [i, j] = leapManager.GetBoneRotation(i, j); //Update bones finger_bones [i, j].GetComponent <BoneManager>().targetPosition = fingerBonePositions[i, j]; finger_bones [i, j].GetComponent <BoneManager>().targetRotation = fingerBoneRotations[i, j]; } } }
/** * Sets the desiredPositions of the palm, incl. the offset from parent object */ private void UpdateBonePositions() { palm_bone_position = manager.GetPalmWorldPosition(); palm_bone.GetComponent <BoneManager> ().targetPosition = palm_bone_position; }