SetYRotation() public method

public SetYRotation ( float yRotation ) : void
yRotation float
return void
コード例 #1
0
 /// <summary>
 /// Sets the cameras.
 /// </summary>
 public void SetCameras()
 {
     if (CameraController != null)
     {
         // Make sure to set the initial direction of the camera
         // to match the game player direction
         CameraController.SetOrientationOffset(OrientationOffset);
         CameraController.SetYRotation(YRotation);
     }
 }
コード例 #2
0
    private void doYawFiltering(float deltaT)
    {
        switch (driftingSensor)
        {
        case DriftingRotation.OculusRift:
            if (OVRDevice.IsSensorPresent(oculusID))
            {
                OVRDevice.GetOrientation(oculusID, ref driftingRot);
                if (oculusCamController)
                {
                    // In the future OVR SDK oculusCamController will have oculusID?
                    oculusCamController.SetYRotation(-finalYawDifference.eulerAngles.y);
                }
            }
            break;

        case DriftingRotation.RazerHydra:
            // TODO
            //driftingRot = hydraRotation;
            break;

        case DriftingRotation.InputTransform:
            if (driftingTransform)
            {
                driftingRot = driftingTransform.rotation;
            }
            break;
        }

        if (driftingDirectionVisualizer != null)
        {
            driftingDirectionVisualizer.transform.rotation = driftingRot;
        }

        driftingEuler = driftingRot.eulerAngles;

        switch (compass)
        {
        case CompassSource.Kinect:
            if (!skeletonManager || !skeletonManager.skeletons[kinectPlayerID].isTracking)
            {
                break;
            }
            else
            {
                compassData = skeletonManager.GetJointData(compassJoint, kinectPlayerID);

                // First check for high confidence value
                if (compassData != null && compassData.rotationConfidence >= 1.0f)
                {
                    updateDifferenceKalman(compassData.rotation.eulerAngles,
                                           driftingEuler, deltaT);
                }
            }
            break;

        case CompassSource.PSMove:

            if (inputManager)
            {
                compassMove = inputManager.GetMoveWand(PSMoveID);
                if (compassMove)
                {
                    updateDifferenceKalman(compassMove.localRotation.eulerAngles,
                                           driftingEuler, deltaT);
                }
            }
            break;

        case CompassSource.InputTransform:
            if (compassTransform != null)
            {
                updateDifferenceKalman(compassTransform.rotation.eulerAngles,
                                       driftingEuler, deltaT);
            }
            break;
        }

        float normalizedT = Mathf.Clamp01(deltaT * driftCorrectionRate);

        if (normalizedT != 0)
        {
            finalYawDifference = Quaternion.Lerp(finalYawDifference, filteredYawDifference,
                                                 normalizedT);
        }

        if (correctedDirectionVisualizer != null)
        {
            correctedDirectionVisualizer.transform.rotation = Quaternion.Euler(
                new Vector3(driftingEuler.x,
                            (360 + driftingEuler.y
                             - finalYawDifference.eulerAngles.y) % 360,
                            driftingEuler.z));
        }
        //driftingRotation*Quaternion.Inverse(finalDifference);
        if (correctedDirectionVisualizer != null && driftVisualizerPosition != null)
        {
            correctedDirectionVisualizer.transform.position = driftVisualizerPosition.position;
        }
    }