Log in or register to post comments

How do I Mono to Stereo?

January 7, 2016 - 3:51am #1

I want to implement Mono to Stereo(cardboard) into my application.

I tried following this tutorial https://developer.vuforia.com/library/articles/Solution/Implementing-a-Mono-to-Stereo-Transition-for-Cardboard-Apps but I'm getting stuck right at the beginning where it says that i have to "Create a new MonoAnchorPoint GameObject".

I've looked all over and couldn't find any such thing. Is the tutorial outdated and that gameovject renamed or something?

How do I implement Mono to Stereo (and stereo to mono) in unity?

How do I Mono to Stereo?

July 6, 2016 - 8:56am #3

In my heiarchy the cardboard game object does not exist.  

Then when I create the script where do I attach it to?

Then How do i create the button to toggle between Mono and stereo?

How do I Mono to Stereo?

January 9, 2016 - 8:13am #2

You must follow this steps:

In the menu bar:

Game Object->Create Empty and after rename the created object (this for MonoAnchorPoint) 

Game Object->Camera and after rename the created camera (this for MonoCamera)

It is important in the MonoCamera that you change the Near and Far parameters according with the Camera paramenters in ARCamera.

 

For the switching the script that I have created and function well is:

 

using UnityEngine;
using System.Collections;
using Vuforia;

public class StereoToMono : MonoBehaviour {

	public bool mono = false;
	public GameObject cardboardMain = null;
	public GameObject cardboardHead = null;
	public GameObject monoAnchorPoint = null;
	public Camera monoCamera = null;

	public Camera cardboardCameraLeft = null;
	public Camera cardboardCameraRight = null;

	public bool switching = false; 

	// Use this for initialization
	void Start () {
		if (mono)
			monoMode ();
		else
			stereoMode ();
	}

	// Update is called once per frame
	void Update () {

		if (switching) {

			switching = false; 

			if (mono){
				stereoMode ();
				ui.showMessage(ui.SWITCHMONO);
				Handheld.Vibrate();
			}
				
			else if (!mono){
				monoMode ();
				ui.showMessage(ui.SWITCHSTEREO);
				Handheld.Vibrate();
			}
				
		}

	
	}

	public void monoMode(){
		// Stop and Deinit the camera:
		CameraDevice.Instance.Stop ();
		CameraDevice.Instance.Deinit ();

		cardboardMain.SetActive (false);
		// enable the mono anchor point:
		monoAnchorPoint.SetActive (true);

		// set the new tracking reference
		VuforiaBehaviour.Instance.SetCentralAnchorPoint (monoAnchorPoint.GetComponent<Transform> ());
		VuforiaBehaviour.Instance.PrimaryCamera = monoCamera;
		VuforiaBehaviour.Instance.SecondaryCamera = null;
		
		// disable explicit updating
		VuforiaBehaviour.Instance.SynchronizePoseUpdates = false;
		
		// turn off the cardboard UI:
		Cardboard.SDK.EnableAlignmentMarker = false;
		Cardboard.SDK.EnableSettingsButton = false;
	

		
		// now tell Vuforia that it's being removed from the Cardboard headset:
		VuforiaBehaviour.Instance.SetHeadsetNotPresent ();

		// initialize the camera again:
		CameraDevice.Instance.Init (CameraDevice.CameraDirection.CAMERA_BACK);
		CameraDevice.Instance.SelectVideoMode (CameraDevice.CameraDeviceMode.MODE_OPTIMIZE_SPEED);
		CameraDevice.Instance.Start ();

		mono = true;
	}

	public void stereoMode(){

		CameraDevice.Instance.Stop();
		CameraDevice.Instance.Deinit();

		// enable the mono anchor point:
		monoAnchorPoint.SetActive (false);
		cardboardMain.SetActive (true);
		VuforiaBehaviour.Instance.SetCentralAnchorPoint( cardboardHead.GetComponent<Transform>());
		VuforiaBehaviour.Instance.PrimaryCamera = cardboardCameraLeft;
		VuforiaBehaviour.Instance.SecondaryCamera = cardboardCameraRight;
		VuforiaBehaviour.Instance.SynchronizePoseUpdates = true;
		VuforiaBehaviour.Instance.SetHeadsetPresent("Cardboard");
		monoAnchorPoint.SetActive( false );
		CameraDevice.Instance.Init(CameraDevice.CameraDirection.CAMERA_BACK);
		CameraDevice.Instance.SelectVideoMode(CameraDevice.CameraDeviceMode.MODE_OPTIMIZE_SPEED);
		CameraDevice.Instance.Start();

		mono = false;
	}

}

 The variable switching is for switching to mono and stereo and viceversa in play mode. 

Remember that the script must be attached to a GameObject in the scene and the variable:

public bool mono = false;
	public GameObject cardboardMain = null;
	public GameObject cardboardHead = null;
	public GameObject monoAnchorPoint = null;
	public Camera monoCamera = null;

	public Camera cardboardCameraLeft = null;
	public Camera cardboardCameraRight = null;

	public bool switching = false; 

 

must be set in the inspector menu.

Hi, sorry for my english,

Gino.

 

 

 

Log in or register to post comments