Beispiel #1
0
	public PoseDiff CompareWithController(ControllerInput controller, float progress)
	{
		int firstPhase = (int)Mathf.Floor(progress/phaseLength);
		int secondPhase = firstPhase + 1;

		if (data.count == 1)
		{
			secondPhase = 0;
		}

		PoseData firstPose = data.poses [firstPhase];
		PoseData secondPose = data.poses [secondPhase];

		PoseData desiredPose = new PoseData();

		float subProgress = progress % phaseLength;
		subProgress /= phaseLength;	//normalize it;

		desiredPose.leftWing = firstPose.leftWing + (secondPose.leftWing - firstPose.leftWing) * subProgress;
		desiredPose.rightWing = firstPose.rightWing + (secondPose.rightWing - firstPose.rightWing) * subProgress;

		desiredPose.head.x = firstPose.head.x + (secondPose.head.x - firstPose.head.x) * subProgress;
		desiredPose.head.y = firstPose.head.y + (secondPose.head.y - firstPose.head.y) * subProgress;

		desiredPose.tail.x = firstPose.tail.x + (secondPose.tail.x - firstPose.tail.x) * subProgress;
		desiredPose.tail.y = firstPose.tail.y + (secondPose.tail.y - firstPose.tail.y) * subProgress;

		PoseData controllerPose = CalculateFromController(controller);

		return CalculatePoseDiffs (desiredPose, controllerPose);
	}
Beispiel #2
0
	public static PoseDiff CalculatePoseDiffs(PoseData a, PoseData b)
	{
		PoseDiff result = new PoseDiff ();

		result = CalculateDiffs (a.leftWing, b.leftWing, result);
		result = CalculateDiffs (a.rightWing, b.rightWing, result);
		//result = CalculateDiffs (a.head.x, b.head.x, result);
		//result = CalculateDiffs (a.head.y, b.head.y, result);
		//result = CalculateDiffs (a.tail.x, b.tail.x, result);
		//result = CalculateDiffs (a.tail.y, b.tail.y, result);

		return result;
	}
    private void PositionTrackable(TrackableBehaviour trackableBehaviour,
        PoseData camToTargetPose)
    {
        trackableBehaviour.transform.position =
                    camera.transform.TransformPoint(camToTargetPose.position);

            trackableBehaviour.transform.rotation =
                    camera.transform.rotation *
                    camToTargetPose.orientation *
                    Quaternion.AngleAxis(270, Vector3.left);
    }
Beispiel #4
0
	public static PoseData CalculateFromController(ControllerInput controller)
	{
		PoseData result = new PoseData ();

		result.leftWing = controller.GetAxis (ControllerAction.L2);
		result.rightWing = controller.GetAxis (ControllerAction.R2);
		result.head.x = controller.GetAxis (ControllerAction.LEFT_STICK_X);
		result.head.y = controller.GetAxis (ControllerAction.LEFT_STICK_Y);
		result.tail.x = controller.GetAxis (ControllerAction.RIGHT_STICK_X);
		result.tail.y = controller.GetAxis (ControllerAction.RIGHT_STICK_Y);

		return result;
	}
    private void PositionCamera(TrackableBehaviour trackableBehaviour,
        PoseData camToTargetPose)
    {
        camera.transform.localPosition =
                    trackableBehaviour.transform.rotation *
                    Quaternion.AngleAxis(90, Vector3.left) *
                    Quaternion.Inverse(camToTargetPose.orientation) *
                    (-camToTargetPose.position) +
                    trackableBehaviour.transform.position;

            camera.transform.rotation =
                    trackableBehaviour.transform.rotation *
                    Quaternion.AngleAxis(90, Vector3.left) *
                    Quaternion.Inverse(camToTargetPose.orientation);
    }