예제 #1
0
    /// <summary>
    /// Process all the raw data on the Playstation Move controller
    /// </summary>
    private void ProcessData()
    {
        trigger = ((int)psmove_get_trigger(handle)) / 255f;

        int x = 0, y = 0, z = 0;

        psmove_get_accelerometer(handle, ref x, ref y, ref z);

        rawAccel.x = x;
        rawAccel.y = y;
        rawAccel.z = z;


        float ax = 0, ay = 0, az = 0;

        psmove_get_accelerometer_frame(handle, PSMove_Frame.Frame_SecondHalf, ref ax, ref ay, ref az);

        accel.x = ax;
        accel.y = ay;
        accel.z = az;

        psmove_get_gyroscope(handle, ref x, ref y, ref z);

        rawGyro.x = x;
        rawGyro.y = y;
        rawGyro.z = z;


        float gx = 0, gy = 0, gz = 0;

        psmove_get_gyroscope_frame(handle, PSMove_Frame.Frame_SecondHalf, ref gx, ref gy, ref gz);

        gyro.x = gx;
        gyro.y = gy;
        gyro.z = gz;



        psmove_get_magnetometer(handle, ref x, ref y, ref z);

        // TODO: Should these values be converted into a more human-understandable range?
        magnet.x = x;
        magnet.y = y;
        magnet.z = z;

        //Orientation
        float q0 = 0.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f;

        psmove_get_orientation(handle, ref q0, ref q1, ref q2, ref q3);
        //Quaternion w has to be moved to front (swapped) for Unity
        orientation.w = q0;
        orientation.x = -q1;
        orientation.y = q3;
        orientation.z = q2;

        battery = psmove_get_battery(handle);

        temperature = psmove_get_temperature(handle);
    }
예제 #2
0
    /// <summary>
    /// Process all the raw data on the Playstation Move controller
    /// </summary>
    private void ProcessData()
    {
        trigger = ((int)psmove_get_trigger(handle)) / 255f;

        int x = 0, y = 0, z = 0;

        psmove_get_accelerometer(handle, ref x, ref y, ref z);

        rawAccel.x = x;
        rawAccel.y = y;
        rawAccel.z = z;


        float ax = 0, ay = 0, az = 0;

        psmove_get_accelerometer_frame(handle, PSMove_Frame.Frame_SecondHalf, ref ax, ref ay, ref az);

        accel.x = ax;
        accel.y = ay;
        accel.z = az;

        psmove_get_gyroscope(handle, ref x, ref y, ref z);

        rawGyro.x = x;
        rawGyro.y = y;
        rawGyro.z = z;


        float gx = 0, gy = 0, gz = 0;

        psmove_get_gyroscope_frame(handle, PSMove_Frame.Frame_SecondHalf, ref gx, ref gy, ref gz);

        gyro.x = gx;
        gyro.y = gy;
        gyro.z = gz;



        psmove_get_magnetometer(handle, ref x, ref y, ref z);

        // TODO: Should these values be converted into a more human-understandable range?
        magnet.x = x;
        magnet.y = y;
        magnet.z = z;

        battery = psmove_get_battery(handle);

        temperature = psmove_get_temperature(handle);
    }
    /// <summary>
    /// Process all the raw data on the Playstation Move controller
    /// </summary>
    private void ProcessData()
    {
        trigger = ((int)psmove_get_trigger(handle)) / 255f;

        int x = 0, y = 0, z = 0;

        psmove_get_accelerometer(handle, ref x, ref y, ref z);

        rawAccel.x = x;
        rawAccel.y = y;
        rawAccel.z = z;

        float ax = 0, ay = 0, az = 0;
        psmove_get_accelerometer_frame(handle, PSMove_Frame.Frame_SecondHalf, ref ax, ref ay, ref az);

        accel.x = ax;
        accel.y = ay;
        accel.z = az;

        psmove_get_gyroscope(handle, ref x, ref y, ref z );

        rawGyro.x = x;
        rawGyro.y = y;
        rawGyro.z = z;

        float gx = 0, gy = 0, gz = 0;
        psmove_get_gyroscope_frame(handle, PSMove_Frame.Frame_SecondHalf, ref gx, ref gy, ref gz);

        gyro.x = gx;
        gyro.y = gy;
        gyro.z = gz;

        psmove_get_magnetometer(handle, ref x, ref y, ref z );

        // TODO: Should these values be converted into a more human-understandable range?
        magnet.x = x;
        magnet.y = y;
        magnet.z = z;

        //Orientation
        float q0 = 0.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f;
        psmove_get_orientation(handle, ref q0, ref q1, ref q2, ref q3);
        //Quaternion w has to be moved to front (swapped) for Unity
        orientation.w=q0;
        orientation.x=-q1;
        orientation.y=q3;
        orientation.z=q2;

        battery = psmove_get_battery(handle);

        temperature = psmove_get_temperature(handle);
    }
    /// <summary>
    /// Process all the raw data on the Playstation Move controller
    /// </summary>
    private void ProcessData()
    {
        trigger = ((int)psmove_get_trigger(handle)) / 255f;

        int x = 0, y = 0, z = 0;

        psmove_get_accelerometer(handle, ref x, ref y, ref z);

        rawAccel.x = x;
        rawAccel.y = y;
        rawAccel.z = z;

        float ax = 0, ay = 0, az = 0;
        psmove_get_accelerometer_frame(handle, PSMove_Frame.Frame_SecondHalf, ref ax, ref ay, ref az);

        accel.x = ax;
        accel.y = ay;
        accel.z = az;

        psmove_get_gyroscope(handle, ref x, ref y, ref z );

        rawGyro.x = x;
        rawGyro.y = y;
        rawGyro.z = z;

        float gx = 0, gy = 0, gz = 0;
        psmove_get_gyroscope_frame(handle, PSMove_Frame.Frame_SecondHalf, ref gx, ref gy, ref gz);

        gyro.x = gx;
        gyro.y = gy;
        gyro.z = gz;

        psmove_get_magnetometer(handle, ref x, ref y, ref z );

        // TODO: Should these values be converted into a more human-understandable range?
        magnet.x = x;
        magnet.y = y;
        magnet.z = z;

        battery = psmove_get_battery(handle);

        temperature = psmove_get_temperature(handle);
    }
예제 #5
0
	/// <summary>
	/// Process all the raw data on the Playstation Move controller
	/// </summary>
	private void ProcessData()
	{

		trigger = ((int)psmove_get_trigger(handle)) / 255f;
		
		int x = 0, y = 0, z = 0;
		
		psmove_get_accelerometer(handle, ref x, ref y, ref z);
		
		rawAccel.x = x;
		rawAccel.y = y;
		rawAccel.z = z;
		
		
		float ax = 0, ay = 0, az = 0;
		psmove_get_accelerometer_frame(handle, PSMove_Frame.Frame_SecondHalf, ref ax, ref ay, ref az);
		
		accel.x = ax;
		accel.y = ay;
		accel.z = az;

		//accel.x = ax < 1 ? 0 : ax;
		//accel.y = ay < 1 ? 0 : ay;
		//accel.z = az < 1 ? 0 : az;

		
		psmove_get_gyroscope(handle, ref x, ref y, ref z );
		
		rawGyro.x = x;
		rawGyro.y = y;
		rawGyro.z = z;
		
		
		float gx = 0, gy = 0, gz = 0;
		psmove_get_gyroscope_frame(handle, PSMove_Frame.Frame_SecondHalf, ref gx, ref gy, ref gz);
		
		gyro.x = gx;
		gyro.y = gy;
		gyro.z = gz;

		//gyro.x = gx < 1 ? 0 : gx;
		//gyro.y = gy < 1 ? 0 : gy;
		//gyro.z = gz < 1 ? 0 : gz;


		
		
		
		psmove_get_magnetometer(handle, ref x, ref y, ref z );
		
		// TODO: Should these values be converted into a more human-understandable range?
		magnet.x = x;
		magnet.y = y;
		magnet.z = z;
		
		//Orientation
		float q0 = 0.0f, q1 = 0.0f, q2 = 0.0f, q3 = 0.0f;
		psmove_get_orientation(handle, ref q0, ref q1, ref q2, ref q3);
		//Quaternion w has to be moved to front (swapped) for Unity
		orientation.w=q0;
		orientation.x=q1;
		orientation.y=q2;
		orientation.z=q3;

		//orientation = orientation * Quaternion.AngleAxis(90, Vector3.right);
		

		//Debug.Log (orientation.eulerAngles);


		var euler = orientation.eulerAngles;

		//euler.x = -euler.x;
		euler.y = -euler.y;
		//euler.z += 90;

		//orientation = orientation + new Vector3(0, 1, -1);//revert 

		orientation = Quaternion.Euler (euler);


		//euler.y = euler.y %360;


		if(GetButton(PSMoveButton.Trigger))
		{
			// wait for user to let go of trigger before starting again..
			if(waitingToLetGoAfterMakingGesture){
				makingGesture = false;
				//ResetHistory();
			} else{
				makingGesture = true;
			}
		} else
		{
			waitingToLetGoAfterMakingGesture = false;
			// not really needed but doing foshu?
			makingGesture = false;
			//ResetHistory();
		}


		if(makingGesture){
			DoGestureStuff();
		}

		//Debug.Log (euler);
		battery = psmove_get_battery(handle);
		
		temperature = psmove_get_temperature(handle);
		
	}
예제 #6
0
    /// <summary>
    /// Process all the raw data on the Playstation Move controller
    /// </summary>
    private void ProcessData()
    {
        trigger = ((int)psmove_get_trigger(handle)) / 255f;

        int x = 0, y = 0, z = 0;

        psmove_get_accelerometer(handle, ref x, ref y, ref z);
        rawAccel.x = x; rawAccel.y = y; rawAccel.z = z;

        float ax = 0, ay = 0, az = 0;

        psmove_get_accelerometer_frame(handle, PSMove_Frame.Frame_SecondHalf, ref ax, ref ay, ref az);
        accel.x = ax; accel.y = ay; accel.z = az;

        psmove_get_gyroscope(handle, ref x, ref y, ref z);
        rawGyro.x = x; rawGyro.y = y; rawGyro.z = z;

        float gx = 0, gy = 0, gz = 0;

        psmove_get_gyroscope_frame(handle, PSMove_Frame.Frame_SecondHalf, ref gx, ref gy, ref gz);
        gyro.x = gx; gyro.y = gy; gyro.z = gz;

        psmove_get_magnetometer(handle, ref x, ref y, ref z);
        magnet.x = x; magnet.y = y; magnet.z = z;

        battery = psmove_get_battery(handle);

        temperature = psmove_get_temperature(handle);

        if (useTracking)
        {
            if (tracker != IntPtr.Zero)
            {
                float px = 0.0f, py = 0.0f, pz = 0.0f;

#if PSMOVE_TRACKING_THP
                psmove_fusion_get_position(fusion, handle, ref px, ref py, ref pz);
                position.x = -px * 0.05f; position.y = py * 0.05f; position.z = pz * 0.05f;
#elif PSMOVE_TRACKING_CBB
                psmove_tracker_get_location(tracker, handle, ref px, ref py, ref pz);
                position.x = -px / 100.0f; position.y = py / 100.0f; position.z = -pz / 100.0f;
#endif
            }
        }

        if (psmove_has_orientation(handle) == 1)
        {
            float rw = 0.0f, rx = 0.0f, ry = 0.0f, rz = 0.0f;
            psmove_get_orientation(handle, ref rw, ref rx, ref ry, ref rz);

            //orientation = new Quaternion(rx, ry, rz, rw);
            //Vector3 euler = orientation.eulerAngles;
            //orientation = Quaternion.Euler(euler.z, -euler.y, euler.x);

            //orientation = new Quaternion(-rw, -rx, -ry, -rz);
            //orientation = Quaternion.identity;
            //orientation = Quaternion.Inverse(new Quaternion(rw, rx, ry, rz));

            //orientation = new Quaternion(rx, ry, rz, rw);
            //orientation = orientation.SetFromToRotation(new Quaternion(rx, ry, rz, rw), Quaternion.identity);

            /*float rotationX = 0F;
             * Vector3 originalUp = new Vector3(1.0f, 0.0f, -1.0f);
             *          Quaternion quat = Quaternion.AngleAxis(rotationX, originalUp);
             *          orientation = new Quaternion(rx, ry, rz, rw) * quat;*/

            //Quaternion quat = new Quaternion(rx, ry, rz, rw);
            //orientation = quat * Quaternion.Dot(quat, Quaternion.identity);

            /*float angle = 0.0F;
             * Vector3 axis = Vector3.zero;
             * orientation = new Quaternion(rx, ry, rz, rw);
             * orientation.ToAngleAxis(out angle, out axis);
             * orientation = Quaternion.AngleAxis(angle, axis);*/

            //orientation = new Quaternion(rx, ry, rz, rw) * initialOrientation;
            //orientation = new Quaternion(rx, ry, rz, rw);
            //orientation.Set(rx, ry, rz, rw);

            //orientation.Set(rz, -ry, rx, rw);
            //orientation.Set(-ry, -rz, -rx, rw);

            orientation.Set(rx, ry, rz, rw);

//FQuat myQuat = FQuat(0, 0, 0, 1) * FQuat(RawDataPtr->OriX, RawDataPtr->OriY, RawDataPtr->OriZ, RawDataPtr->OriW);
//FQuat myQuat = FQuat(0, 0, sqrt(2.0) / 2, sqrt(2.0) / 2) * FQuat(RawDataPtr->OriX, RawDataPtr->OriY, RawDataPtr->OriZ, RawDataPtr->OriW);
//FQuat myQuat = FQuat(0, 0, sqrt(2.0) / 2, sqrt(2.0) / 2) * FQuat(RawDataPtr->OriX, RawDataPtr->OriY, RawDataPtr->OriZ, RawDataPtr->OriW);
//return myQuat.Rotator();
//+return FQuat(-RawDataPtr->OriX, RawDataPtr->OriY, -RawDataPtr->OriZ, RawDataPtr->OriW).Rotator();
//return FQuat(RawDataPtr->OriX, RawDataPtr->OriY, RawDataPtr->OriZ, RawDataPtr->OriW).Rotator();
//return FQuat(-RawDataPtr->OriX, RawDataPtr->OriY, RawDataPtr->OriZ, -RawDataPtr->OriW).Rotator();


            //orientation *= new Quaternion(0.5f, -0.5f, -0.5f, 0.5f);
            //orientation = Quaternion.Inverse(orientation);
//			orientation = initialOrientation * orientation;
//			Debug.Log(orientation);
            //Debug.Log(new Quaternion(rx, ry, rz, rw) + " - " + initialOrientation + " - " + orientation);
            //orientation = Quaternion.identity;
        }
    }