コード例 #1
0
    /*
     * Gets a secific proximity collider list
     */
    public List <GameObject> GetCollisionList(ProximityType proximityType, SixenseHands hand)
    {
        List <GameObject> targetList = null;

        switch (proximityType)
        {
        case ProximityType.INSTRUMENT_INTERIOR:
            if (hand == SixenseHands.LEFT)
            {
                targetList = m_leftInstrumentInterior;
            }
            else if (hand == SixenseHands.RIGHT)
            {
                targetList = m_rightInstrumentInterior;
            }
            break;

        case ProximityType.INSTRUMENT_PROXIMITY:
            if (hand == SixenseHands.LEFT)
            {
                targetList = m_leftInstrumentProximity;
            }
            else if (hand == SixenseHands.RIGHT)
            {
                targetList = m_rightInstrumentProximity;
            }
            break;

        case ProximityType.GENERATOR:
            break;
        }

        return(targetList);
    }
コード例 #2
0
    /*
     * Adds a proximity target to a list of active colliders with a hand
     */
    public void AddCollision(GameObject proximityTarget, SixenseHands hand, ProximityType proximityType)
    {
        List <GameObject> targetList = GetCollisionList(proximityType, hand);

        if (!targetList.Contains(proximityTarget))
        {
            targetList.Add(proximityTarget);
        }
    }
コード例 #3
0
 void OnTriggerExit(Collider collider)
 {
     if (isActive)
     {
         if (collider.gameObject.layer == LayerMask.NameToLayer("SoundCollideable"))
         {
             SixenseHands hand = collider.gameObject.GetComponent <HydraHand>().Hand;
             HydraController.Instance.RemoveCollision(proximityRoot, hand, proximityTarget);
         }
     }
 }
コード例 #4
0
ファイル: SixenseInput.cs プロジェクト: Sebkasanzew/VR-Sports
    /// <summary>
    /// Gets the Controller object bound to the specified hand.
    /// </summary>
    public static Controller GetController(SixenseHands hand)
    {
        for (int i = 0; i < MAX_CONTROLLERS; i++)
        {
            if ((m_Controllers[i] != null) && (m_Controllers[i].Hand == hand))
            {
                return(m_Controllers[i]);
            }
        }

        return(null);
    }
コード例 #5
0
ファイル: SixenseInput.cs プロジェクト: DillonWhatley/Elegame
 /// <summary>
 /// Gets the Controller object bound to the specified hand.
 /// </summary>
 public static Controller GetController(SixenseHands hand)
 {
     for (int i = 0; i < MAX_CONTROLLERS; i++)
     {
         if ((m_Controllers[i] != null) && (m_Controllers[i].Hand == hand))
         {
             return(m_Controllers[i]);
         }
     }
     Debug.Log(m_Controllers[2]);
     return(m_Controllers[3]);
     //return null;
 }
コード例 #6
0
    public Vector3 GetRotation(SixenseHands Hand)
    {
        if (Hand == SixenseHands.LEFT || (Hand == SixenseHands.RIGHT && !invertRightHand))
        {
            return(rotationModifier);
        }

        if (Hand == SixenseHands.RIGHT)
        {
            return(rotationModifier + invertRotationModifier);
        }

        return(defaultRotationModifier);
    }
コード例 #7
0
	/// <summary>
	/// Gets the Controller object bound to the specified hand.
	/// </summary>
	public static Controller GetController( SixenseHands hand )
	{
		for ( int i = 0; i < MAX_CONTROLLERS; i++ )
		{
			if ( ( m_Controllers[i] != null ) && ( m_Controllers[i].Hand == hand ) )
			{
				return m_Controllers[i];
			}
		}
		
		return null;
	}
コード例 #8
0
 internal void Update( ref SixensePlugin.sixenseControllerData cd )
 {
     m_Docked = ( cd.is_docked != 0 );
     m_Hand = ( SixenseHands )cd.which_hand;
     m_ButtonsPrevious = m_Buttons;
     m_Buttons = ( SixenseButtons )cd.buttons;
     m_Trigger = cd.trigger;
     m_JoystickX = cd.joystick_x;
     m_JoystickY = cd.joystick_y;
     m_Position.Set( cd.pos[0], cd.pos[1], cd.pos[2] );
     m_Rotation.Set( cd.rot_quat[0], cd.rot_quat[1], cd.rot_quat[2], cd.rot_quat[3] );
     if ( m_Trigger > TriggerButtonThreshold )
     {
         m_Buttons |= SixenseButtons.TRIGGER;
     }
 }
コード例 #9
0
 internal Controller()
 {
     m_Enabled = false;
     m_Docked = false;
     m_Hand = SixenseHands.UNKNOWN;
     m_HandBind = SixenseHands.UNKNOWN;
     m_Buttons = 0;
     m_ButtonsPrevious = 0;
     m_Trigger = 0.0f;
     m_JoystickX = 0.0f;
     m_JoystickY = 0.0f;
     m_Position.Set( 0.0f, 0.0f, 0.0f );
     m_Rotation.Set( 0.0f, 0.0f, 0.0f, 1.0f );
 }
コード例 #10
0
    /*
     * Removes a proximity target from a list of active colliders with a hand
     */
    public void RemoveCollision(GameObject proximityTarget, SixenseHands hand, ProximityType proximityType)
    {
        List <GameObject> targetList = GetCollisionList(proximityType, hand);

        targetList.Remove(proximityTarget);
    }
コード例 #11
0
	void Awake()
	{
		coordinateSystem = MonoBehaviour.FindObjectOfType(typeof(RUISCoordinateSystem)) as RUISCoordinateSystem;
		localPosition = Vector3.zero;
		localRotation = Quaternion.identity;
		rawRotation = Quaternion.identity;
		
		filterPos = new KalmanFilter();
		filterPos.initialize(3,3);
		filterPos.skipIdenticalMeasurements = true;
		//		filterRot = new KalmanFilter();
		//		filterRot.initialize(4,4);
		
		// Mobile Razer Hydra base filtering
		hydraBaseFilterPos = new KalmanFilter();
		hydraBaseFilterPos.initialize(3,3);
		hydraBaseFilterPos.skipIdenticalMeasurements = true;
		//		hydraBaseFilterRot = new KalmanFilter();
		//		hydraBaseFilterRot.initialize(4,4);
		
		filterRot.skipIdenticalMeasurements = true;
		
		// Yaw Drift Corrector invocations in Awake()
		filterDrift = new KalmanFilter();
		filterDrift.initialize(2,2);
		
		transform.localPosition = defaultPosition;
		eyeCenterPosition = defaultPosition;
		measuredHeadPosition = defaultPosition;
		
		hydraBasePosition = new Vector3(0, 0, 0);
		hydraBaseRotation = Quaternion.identity;
		
		ovrCameraRig = GetComponentInChildren<OVRCameraRig>();
		if(ovrCameraRig != null && OVRManager.display != null && OVRManager.display.isPresent)
		{
			useOculusRiftRotation = true;
		}
		else
		{
			useOculusRiftRotation = false;
		}
		
		// Enforce rotation settings if rotation source is set to be same as position source
		if (!pickRotationSource) 
		{
			switch (headPositionInput)
			{	
			case HeadPositionSource.Kinect1:
			{
				headRotationInput = HeadRotationSource.Kinect1;
				rotationPlayerID = positionPlayerID;
				rotationJoint = positionJoint;
				break;
			}
			case HeadPositionSource.Kinect2:
			{
				headRotationInput = HeadRotationSource.Kinect2;
				rotationPlayerID = positionPlayerID;
				rotationJoint = positionJoint;
				break;
			}
			case HeadPositionSource.PSMove:
			{
				headRotationInput = HeadRotationSource.PSMove;
				rotationPSMoveID = positionPSMoveID;
				break;
			}
			case HeadPositionSource.RazerHydra:
			{
				headRotationInput = HeadRotationSource.RazerHydra;
				rotationRazerID = positionRazerID;
				break;
			}
			case HeadPositionSource.InputTransform:
			{
				headRotationInput = HeadRotationSource.InputTransform;
				rotationInput = positionInput;
				break;
			}
			case HeadPositionSource.None:
			{
				headRotationInput = HeadRotationSource.None;
				break;
			}
			}
		}
		
		filterPosition = false;
	}
コード例 #12
0
 public HydraHand(SixenseHands hand )
 {
     this.hand = hand;
     isLeftHand = (hand == SixenseHands.LEFT);
     goal = isLeftHand ? AvatarIKGoal.LeftHand : AvatarIKGoal.RightHand;
 }
コード例 #13
0
        //ENDOF LUKA CODE
        internal void Update( ref SixensePlugin.sixenseControllerData cd )
        {
            m_Docked = ( cd.is_docked != 0 );
            m_Hand = ( SixenseHands )cd.which_hand;
            m_ButtonsPrevious = m_Buttons;
            m_Buttons = ( SixenseButtons )cd.buttons;
            m_Trigger = cd.trigger;
            m_JoystickX = cd.joystick_x;
            m_JoystickY = cd.joystick_y;

            //LUKA CODE
            if (recording && !startedRec) {
                StartRecording ();
            } else if (recording && startedRec && Time.time>=finishRecTime) {
                StopRecording ();
            }
            Vector3 rawPos = new Vector3(cd.pos[0], cd.pos[1], cd.pos[2] );
            for(int i =0; i<kStates.Length; i++){
                kStates[i].kalman_update(rawPos[i]);
            }

            Vector3 filteredPos = new Vector3 (kStates [0].x, kStates [1].x, kStates [2].x);
            if (recording && startedRec) {
                tw.WriteLine(rawPos.x+" "+rawPos.y+" "+rawPos.z);
                twFiltered.WriteLine(filteredPos.x+" "+filteredPos.y+" "+filteredPos.z);
            }
            if (useKalman) {
                m_Position.Set (filteredPos.x, filteredPos.y, filteredPos.z);
            } else {
                m_Position.Set (rawPos.x, rawPos.y, rawPos.z);
            }

            Quaternion rot = new Quaternion (cd.rot_quat [0], cd.rot_quat [1], cd.rot_quat [2], cd.rot_quat [3]);
            rot = rot * Quaternion.Euler (new Vector3 (225, 0, 0));

            //m_Rotation.Set( rot[0], rot[1], rot[2], rot[3] );
            //ENDOF LUKA CODE

            //m_Position.Set (cd.pos [0], cd.pos [1], cd.pos [2]);
            m_Rotation.Set( cd.rot_quat[0], cd.rot_quat[1], cd.rot_quat[2], cd.rot_quat[3] );
            if ( m_Trigger > TriggerButtonThreshold )
            {
                m_Buttons |= SixenseButtons.TRIGGER;
            }
        }
コード例 #14
0
        internal Controller()
        {
            //LUKA CODE
            processNoise = 0.1f;
            sensorNoise = 1.0f;
            estimatedError = 0.25f;
            kStates = new KalmanState[3];
            for(int i=0; i<kStates.Length; i++){
                kStates[i] = new KalmanState(processNoise,sensorNoise,0.0f,estimatedError,0);
            }
            //ENDOF LUKA CODE

            m_Enabled = false;
            m_Docked = false;
            m_Hand = SixenseHands.UNKNOWN;
            m_HandBind = SixenseHands.UNKNOWN;
            m_Buttons = 0;
            m_ButtonsPrevious = 0;
            m_Trigger = 0.0f;
            m_JoystickX = 0.0f;
            m_JoystickY = 0.0f;
            m_Position.Set( 0.0f, 0.0f, 0.0f );
            m_Rotation.Set( 0.0f, 0.0f, 0.0f, 1.0f );
        }