// Use this for initialization void Start () { this.leftTrigger = false; this.rightTrigger = false; leftHand = leftHandObject.GetComponent<SixenseHand>(); rightHand = rightHandObject.GetComponent<SixenseHand>(); leftHand.handPosition = Hand.LEFT; rightHand.handPosition = Hand.RIGHT; }
/** Updates hand position and rotation */ void UpdateHand( SixenseHand hand ) { bool bControllerActive = IsControllerActive( hand.m_controller ); if ( bControllerActive ) { hand.transform.localPosition = ( hand.m_controller.Position - m_baseOffset ) * m_sensitivity; hand.transform.localRotation = hand.m_controller.Rotation * hand.InitialRotation; } else { // use the inital position and orientation because the controller is not active hand.transform.localPosition = hand.InitialPosition; hand.transform.localRotation = hand.InitialRotation; } }
/** Updates hand position and rotation */ void UpdateHand(SixenseHand hand) { bool bControllerActive = IsControllerActive(hand.m_controller); if (bControllerActive) { hand.transform.localPosition = (hand.m_controller.Position - m_baseOffset) * m_sensitivity; hand.transform.localRotation = hand.m_controller.Rotation * hand.InitialRotation; } else { // use the inital position and orientation because the controller is not active hand.transform.localPosition = hand.InitialPosition; hand.transform.localRotation = hand.InitialRotation; } }
private void Awake() { hand = GetComponent <SixenseHand>(); }
protected void Start() { hand = GetComponent<SixenseHand> (); }
// Use this for initialization void Start() { get_change = false; m_hand = GetComponent<SixenseHand>(); }
// Use this for initialization void Start() { get_change = false; m_hand = GetComponent <SixenseHand>(); }
/** Updates hand position and rotation */ void UpdateHand( SixenseHand hand ) { bool bControllerActive = IsControllerActive( hand.m_controller ); if (wheelController.leftTrigger && wheelController.rightTrigger) { Vector3 leftPosition = (wheelController.leftHand.m_controller.Position - m_baseOffset); Vector3 rightPosition = (wheelController.rightHand.m_controller.Position - m_baseOffset); float currentAngle = wheelController.wheelObject.transform.rotation.eulerAngles.z; float leftDegree = 0.0f; float rightDegree = 0.0f; float degree = 0.0f; if (leftLastPosition.x != 0.0f && rightLastPosition.x != 0.0f) { leftDegree = Mathf.Atan2(leftPosition.y, leftPosition.x) - Mathf.Atan2(leftLastPosition.y, leftLastPosition.x); rightDegree = Mathf.Atan2(rightPosition.y, rightPosition.x) - Mathf.Atan2(rightLastPosition.y, rightLastPosition.x); } degree = Mathf.Abs(leftDegree) > Mathf.Abs(rightDegree) ? leftDegree : rightDegree; degree = degree * Mathf.Rad2Deg; leftLastPosition = leftPosition; rightLastPosition = rightPosition; if (degree+currentAngle < 75 || degree+currentAngle > 285) { wheelController.wheelObject.transform.Rotate(new Vector3(0f, 0f, degree)); } } else if(wheelController.leftHand.isTrigger) { float currentAngle = wheelController.wheelObject.transform.rotation.eulerAngles.z; Vector3 leftPosition = (wheelController.leftHand.m_controller.Position - m_baseOffset); float degree = 0.0f; if (leftLastPosition.x != 0.0f) { degree = Mathf.Atan2(leftPosition.y, leftPosition.x) - Mathf.Atan2(leftLastPosition.y, leftLastPosition.x); } degree = degree * Mathf.Rad2Deg; leftLastPosition = leftPosition; if (degree+currentAngle < 75 || degree+currentAngle > 285) { wheelController.wheelObject.transform.Rotate(new Vector3(0f, 0f, degree)); } } else if(wheelController.rightHand.isTrigger) { float currentAngle = wheelController.wheelObject.transform.rotation.eulerAngles.z; Vector3 rightPosition = (wheelController.rightHand.m_controller.Position - m_baseOffset); float degree = 0.0f; if (rightLastPosition.x != 0.0f) { degree = Mathf.Atan2(rightPosition.y, rightPosition.x) - Mathf.Atan2(rightLastPosition.y, rightLastPosition.x); } degree = degree * Mathf.Rad2Deg; rightLastPosition = rightPosition; if (degree+currentAngle < 75 || degree+currentAngle > 285) { wheelController.wheelObject.transform.Rotate(new Vector3(0f, 0f, degree)); } } else if(transmissionController.hand.isTransmission) { Vector3 handPosition = (transmissionController.hand.m_controller.Position - m_baseOffset) * (m_sensitivity/2); Vector3 delta = new Vector3(0f, 0f, 0f); if(transmissionLastPosition.x != 0.0f || transmissionLastPosition.y != 0.0f || transmissionLastPosition.z != 0.0f) { delta = handPosition - transmissionLastPosition; delta.x = 0; delta.z = 0; } transmissionLastPosition = handPosition; transmissionController.TObject.transform.Translate(-delta); } if ((hand.handPosition == Hand.LEFT && wheelController.leftTrigger) || (hand.handPosition == Hand.RIGHT && wheelController.rightTrigger) || (hand.handPosition == Hand.RIGHT && transmissionController.hand.isTransmission)) { } else if ( bControllerActive) { hand.transform.localPosition = ( hand.m_controller.Position - m_baseOffset ) * m_sensitivity; hand.transform.localRotation = hand.m_controller.Rotation * hand.InitialRotation; } else { // use the inital position and orientation because the controller is not active hand.transform.localPosition = hand.InitialPosition; hand.transform.localRotation = hand.InitialRotation; } }