void Start () {
        keystoningConfigurator = GetComponent<RUISKeystoningConfiguration>();
        if (!keystoningConfigurator)
        {
            keystoningConfigurator = transform.parent.GetComponent<RUISKeystoningConfiguration>();
        }
	}
예제 #2
0
 void Start()
 {
     keystoningConfigurator = GetComponent <RUISKeystoningConfiguration>();
     if (!keystoningConfigurator)
     {
         keystoningConfigurator = transform.parent.GetComponent <RUISKeystoningConfiguration>();
     }
 }
예제 #3
0
    public void Awake()
    {
        keystoningConfiguration = GetComponent <RUISKeystoningConfiguration>();

        centerCamera = camera;
        leftCamera   = transform.FindChild("CameraLeft").GetComponent <Camera>();
        rightCamera  = transform.FindChild("CameraRight").GetComponent <Camera>();

        centerCamera.cullingMask = cullingMask;
        leftCamera.cullingMask   = cullingMask;
        rightCamera.cullingMask  = cullingMask;
    }
예제 #4
0
    public static bool ImportKeystoningConfiguration(RUISKeystoningConfiguration keystoningConfiguration, XmlDocument xmlDoc)
    {
        XmlNode centerCornerElement = xmlDoc.GetElementsByTagName("centerKeystone").Item(0);

        keystoningConfiguration.centerCameraCorners = new RUISKeystoning.KeystoningCorners(centerCornerElement);

        XmlNode leftCornerElement = xmlDoc.GetElementsByTagName("leftKeystone").Item(0);

        keystoningConfiguration.leftCameraCorners = new RUISKeystoning.KeystoningCorners(leftCornerElement);

        XmlNode rightCornerElement = xmlDoc.GetElementsByTagName("rightKeystone").Item(0);

        keystoningConfiguration.rightCameraCorners = new RUISKeystoning.KeystoningCorners(rightCornerElement);

        return(true);
    }
 void Start()
 {
     keystoningConfigurator = GetComponent <RUISKeystoningConfiguration>();
     if (!keystoningConfigurator && transform.parent)
     {
         keystoningConfigurator = transform.parent.GetComponent <RUISKeystoningConfiguration>();
         if (!keystoningConfigurator && transform.parent.parent)
         {
             keystoningConfigurator = transform.parent.parent.GetComponent <RUISKeystoningConfiguration>();
         }
     }
     if (!keystoningConfigurator)
     {
         Debug.LogError("GameObject " + name + " has " + typeof(RUISKeystoningBorderDrawer) + " script, but a "
                        + typeof(RUISKeystoningConfiguration) + " can't be found when searching up to grandparent gameObject!");
     }
 }
예제 #6
0
    public static bool ExportKeystoningConfiguration(RUISKeystoningConfiguration keystoningConfiguration, XmlElement displayXmlElement)
    {
        XmlElement centerCornerElement = displayXmlElement.OwnerDocument.CreateElement("centerKeystone");

        keystoningConfiguration.centerCameraCorners.SaveToXML(centerCornerElement);
        displayXmlElement.AppendChild(centerCornerElement);

        XmlElement leftCornerElement = displayXmlElement.OwnerDocument.CreateElement("leftKeystone");

        keystoningConfiguration.leftCameraCorners.SaveToXML(leftCornerElement);
        displayXmlElement.AppendChild(leftCornerElement);

        XmlElement rightCornerElement = displayXmlElement.OwnerDocument.CreateElement("rightKeystone");

        keystoningConfiguration.rightCameraCorners.SaveToXML(rightCornerElement);
        displayXmlElement.AppendChild(rightCornerElement);

        return(true);
    }
예제 #7
0
    public void Awake()
    {
        keystoningConfiguration = GetComponent<RUISKeystoningConfiguration>();

        centerCamera = camera;
        leftCamera = transform.FindChild("CameraLeft").GetComponent<Camera>();
        rightCamera = transform.FindChild("CameraRight").GetComponent<Camera>();

        //centerCamera.cullingMask = cullingMask;
        cullingMask = centerCamera.cullingMask;

        try
        {
            leftCamera.cullingMask = cullingMask;
            rightCamera.cullingMask = cullingMask;
        }
        catch (System.NullReferenceException e)
        {
            Debug.LogError(e.ToString(), this);
            Debug.LogError("Missing either CameraLeft or CameraRight child object or their Camera components.");
        }
    }
예제 #8
0
    public void Awake()
    {
        keystoningConfiguration = GetComponent <RUISKeystoningConfiguration>();
        if (!keystoningConfiguration)
        {
            Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, "
                           + "but is missing " + typeof(RUISKeystoningConfiguration) + " component!");
        }

        centerCamera = camera;
        try
        {
            leftCamera  = transform.FindChild("CameraLeft").GetComponent <Camera>();
            rightCamera = transform.FindChild("CameraRight").GetComponent <Camera>();
        }
        catch (System.Exception e)
        {
            Debug.LogError(e.TargetSite + ": GameObject " + name + " has " + typeof(RUISCamera) + " script, "
                           + "but it is missing either CameraLeft or CameraRight child object.");
            gameObject.SetActive(false);
        }

        if (centerCamera == null)
        {
            Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, "
                           + "but is missing camera component!");

            gameObject.SetActive(false);
            return;
        }

        bool isDifferentCenterMask = false;
        bool isDifferentLeftMask   = false;
        bool isDifferentRightMask  = false;

        if (associatedDisplay != null && !associatedDisplay.enableOculusRift)
        {
            // TODO: Recreate RUISCamera for SDK 0.4.4
            try
            {
                GetComponent <OVRCameraRig>().enabled = false;
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.TargetSite + ": GameObject '" + name + "': " + typeof(OVRCameraRig) + " was not found.", this);
            }
        }
        else
        {
            //				Debug.LogWarning(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, but no " + typeof(RUISDisplay)
            //				                 + " was associated with it upon Awake(). Leaving OVR scripts on.");
            foreach (RUISKeystoningBorderDrawer drawer in GetComponentsInChildren <RUISKeystoningBorderDrawer>())
            {
                drawer.enabled = false;
            }
        }



        if (cullingMask != centerCamera.cullingMask)
        {
            isDifferentCenterMask = true;
        }

        try
        {
            if (cullingMask != leftCamera.cullingMask)
            {
                isDifferentLeftMask = true;
            }
            if (cullingMask != rightCamera.cullingMask)
            {
                isDifferentRightMask = true;
            }
        }
        catch (System.NullReferenceException e)
        {
            Debug.LogError(e.ToString(), this);
            Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, "
                           + "but it is missing either CameraLeft or CameraRight child object or their Camera components.");
            gameObject.SetActive(false);
            return;
        }

        if (isDifferentCenterMask || isDifferentLeftMask || isDifferentRightMask)
        {
            string differingMasksList = isDifferentCenterMask?"Camera":"";
            if (differingMasksList.Length == 0)
            {
                differingMasksList += isDifferentLeftMask?"CameraLeft":"";
            }
            else
            {
                differingMasksList += isDifferentLeftMask?", CameraLeft":"";
            }
            if (differingMasksList.Length == 0)
            {
                differingMasksList += isDifferentRightMask?"CameraRight":"";
            }
            else
            {
                differingMasksList += isDifferentRightMask?", CameraRight":"";
            }

            Debug.LogWarning("GameObject " + name + " has " + typeof(RUISCamera) + " script, whose "
                             + "Culling Mask property has overwritten Culling Masks of its [" + differingMasksList + "].");
        }

        centerCamera.cullingMask = cullingMask;
        leftCamera.cullingMask   = cullingMask;
        rightCamera.cullingMask  = cullingMask;
    }
예제 #9
0
    public static bool ImportKeystoningConfiguration(RUISKeystoningConfiguration keystoningConfiguration, XmlDocument xmlDoc)
    {
        XmlNode centerCornerElement = xmlDoc.GetElementsByTagName("centerKeystone").Item(0);
        keystoningConfiguration.centerCameraCorners = new RUISKeystoning.KeystoningCorners(centerCornerElement);

        XmlNode leftCornerElement = xmlDoc.GetElementsByTagName("leftKeystone").Item(0);
        keystoningConfiguration.leftCameraCorners = new RUISKeystoning.KeystoningCorners(leftCornerElement);

        XmlNode rightCornerElement = xmlDoc.GetElementsByTagName("rightKeystone").Item(0);
        keystoningConfiguration.rightCameraCorners = new RUISKeystoning.KeystoningCorners(rightCornerElement);

        return true;
    }
예제 #10
0
    public static bool ExportKeystoningConfiguration(RUISKeystoningConfiguration keystoningConfiguration, XmlElement displayXmlElement)
    {
        XmlElement centerCornerElement = displayXmlElement.OwnerDocument.CreateElement("centerKeystone");
        keystoningConfiguration.centerCameraCorners.SaveToXML(centerCornerElement);
        displayXmlElement.AppendChild(centerCornerElement);

        XmlElement leftCornerElement = displayXmlElement.OwnerDocument.CreateElement("leftKeystone");
        keystoningConfiguration.leftCameraCorners.SaveToXML(leftCornerElement);
        displayXmlElement.AppendChild(leftCornerElement);

        XmlElement rightCornerElement = displayXmlElement.OwnerDocument.CreateElement("rightKeystone");
        keystoningConfiguration.rightCameraCorners.SaveToXML(rightCornerElement);
        displayXmlElement.AppendChild(rightCornerElement);

        return true;
    }
예제 #11
0
    public void Awake()
    {
        keystoningConfiguration = GetComponent <RUISKeystoningConfiguration>();
        if (!keystoningConfiguration)
        {
            Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, "
                           + "but is missing " + typeof(RUISKeystoningConfiguration) + " component!");
        }

        camerasInChildren = GetComponentsInChildren <Camera>();

        if (camerasInChildren != null)
        {
            foreach (Camera cam in camerasInChildren)
            {
                if (cam.gameObject.name == centerCameraName)                // TODO: Cameras are searched by gameobject name, this is not good
                {
                    centerCamera = cam;
                }
                if (cam.gameObject.name == leftCameraName)
                {
                    leftCamera = cam;
                }
                if (cam.gameObject.name == rightCameraName)
                {
                    rightCamera = cam;
                }
            }

            if (leftCamera == null)
            {
                Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, it did "
                               + "not contain a camera Component in a child with the name " + leftCameraName + ". Disabling "
                               + name + ". See the original RUISCamera prefab for a correct RUISCamera setup.");
                gameObject.SetActive(false);
                return;
            }
            if (rightCamera == null)
            {
                Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, it did "
                               + "not contain a camera Component in a child with the name " + rightCameraName + ". Disabling "
                               + name + ". See the original RUISCamera prefab for a correct RUISCamera setup.");
                gameObject.SetActive(false);
                return;
            }
            if (centerCamera == null)
            {
                Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, it did "
                               + "not contain a camera Component in a child with the name " + centerCameraName + ". Disabling "
                               + name + ". See the original RUISCamera prefab for a correct RUISCamera setup.");
                gameObject.SetActive(false);
                return;
            }
        }
        else
        {
            Debug.LogError("GameObject " + name + " has " + typeof(RUISCamera) + " script, "
                           + "but no Camera components were found in its children!");
        }

        /*
         * centerCamera = GetComponent<Camera>();
         * try
         * {
         *
         *      leftCamera = transform.FindChild("CameraLeft").GetComponent<Camera>();
         *      rightCamera = transform.FindChild("CameraRight").GetComponent<Camera>();
         * }
         * catch (System.Exception e)
         * {
         *      Debug.LogError(  e.TargetSite + ": GameObject " + name + " has " + typeof(RUISCamera) + " script, "
         + "but it is missing either CameraLeft or CameraRight child object.");
         +      gameObject.SetActive(false);
         + }
         +
         + if(centerCamera == null)
         + {
         +      Debug.LogError(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, "
         + "but is missing camera component!");
         +
         +      gameObject.SetActive(false);
         +      return;
         + }
         */

        bool isDifferentCenterMask = false;
        bool isDifferentLeftMask   = false;
        bool isDifferentRightMask  = false;

        isHmdCamera = UnityEngine.VR.VRSettings.enabled && !this.isStereo && this.centerCamera &&
                      this.centerCamera.stereoTargetEye != StereoTargetEyeMask.None;

        // Is this a VR RUISCamera?
        if (isHmdCamera)
        {
            //				Debug.LogWarning(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, but no " + typeof(RUISDisplay)
            //				                 + " was associated with it upon Awake(). Leaving OVR scripts on.");
            foreach (RUISKeystoningBorderDrawer drawer in GetComponentsInChildren <RUISKeystoningBorderDrawer>())
            {
                drawer.enabled = false;
            }

//			if(Valve.VR.OpenVR.IsHmdPresent() && SteamVR.instance != null)
//				print (SteamVR.instance.hmd_ModelNumber);
//
//			if(UnityEngine.VR.VRDevice.isPresent)
//				print (UnityEngine.VR.VRDevice.model);

            // *** TODO HACK Create an abstract HMD class and implementations for each HMD model
//			if(    Valve.VR.OpenVR.IsHmdPresent()
//				&& centerCamera.GetComponentInChildren<SteamVR_Camera>() )
//			{
//				SteamVR_Camera steamCamera = centerCamera.GetComponentInChildren<SteamVR_Camera>();
//				return;
//			}
        }


        cullingMask = centerCamera.cullingMask;
//		if(cullingMask != centerCamera.cullingMask)
//			isDifferentCenterMask = true;

        if (leftCamera && cullingMask != leftCamera.cullingMask)
        {
            isDifferentLeftMask = true;
        }
        if (rightCamera && cullingMask != rightCamera.cullingMask)
        {
            isDifferentRightMask = true;
        }

        if (isDifferentCenterMask || isDifferentLeftMask || isDifferentRightMask)
        {
            string differingMasksList = isDifferentCenterMask ? centerCameraName : "";
            if (differingMasksList.Length == 0)
            {
                differingMasksList += isDifferentLeftMask ? leftCameraName : "";
            }
            else
            {
                differingMasksList += isDifferentLeftMask ? (", " + leftCameraName) : "";
            }
            if (differingMasksList.Length == 0)
            {
                differingMasksList += isDifferentRightMask ? rightCameraName : "";
            }
            else
            {
                differingMasksList += isDifferentRightMask ? ", " + rightCameraName : "";
            }

            Debug.LogWarning("GameObject " + name + " has " + typeof(RUISCamera) + " script, whose child " + centerCameraName
                             + "'s Camera Culling Mask has been used to overwrite Culling Masks in [" + differingMasksList + "].");
        }

        centerCamera.cullingMask = cullingMask;
        leftCamera.cullingMask   = cullingMask;
        rightCamera.cullingMask  = cullingMask;
    }
예제 #12
0
 public static bool ExportKeystoningConfiguration(RUISKeystoningConfiguration keystoningConfiguration, XmlElement displayXmlElement)
 {
     return(true);
 }
예제 #13
0
 public static bool ImportKeystoningConfiguration(RUISKeystoningConfiguration keystoningConfiguration, XmlDocument xmlDoc)
 {
     return(true);
 }
예제 #14
0
	public void Awake()
	{
        keystoningConfiguration = GetComponent<RUISKeystoningConfiguration>();
		if(!keystoningConfiguration)
			Debug.LogError( "GameObject " + name + " has " + typeof(RUISCamera) + " script, "
			               + "but is missing " + typeof(RUISKeystoningConfiguration) + " component!");
		
        centerCamera = GetComponent<Camera>();
		try
		{
			
			leftCamera = transform.FindChild("CameraLeft").GetComponent<Camera>();
			rightCamera = transform.FindChild("CameraRight").GetComponent<Camera>();
		}
		catch (System.Exception e)
		{
			Debug.LogError(  e.TargetSite + ": GameObject " + name + " has " + typeof(RUISCamera) + " script, "
			               + "but it is missing either CameraLeft or CameraRight child object.");
			gameObject.SetActive(false);
		}

		if(centerCamera == null)
		{
			Debug.LogError(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, "
			               + "but is missing camera component!");
			
			gameObject.SetActive(false);
			return;
		}

		bool isDifferentCenterMask = false;
		bool isDifferentLeftMask = false;
		bool isDifferentRightMask = false;
		
		if (associatedDisplay != null && !associatedDisplay.enableOculusRift)
		{
			// TODO: Recreate RUISCamera for SDK 0.4.4
			try 
			{
				GetComponent<OVRCameraRig>().enabled = false;
			}
			catch (System.Exception e)
			{
				Debug.LogError(e.TargetSite + ": GameObject '" + name + "': " + typeof(OVRCameraRig) + " was not found.", this);
			}
		}
		else
		{
			//				Debug.LogWarning(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, but no " + typeof(RUISDisplay) 
			//				                 + " was associated with it upon Awake(). Leaving OVR scripts on.");
			foreach (RUISKeystoningBorderDrawer drawer in GetComponentsInChildren<RUISKeystoningBorderDrawer>())
			{
				drawer.enabled = false;
			}
		}
		


		if(cullingMask != centerCamera.cullingMask)
			isDifferentCenterMask = true;

		try
		{
			
			if(cullingMask != leftCamera.cullingMask)
				isDifferentLeftMask = true;
			if(cullingMask != rightCamera.cullingMask)
				isDifferentRightMask = true;
		}
		catch (System.NullReferenceException e)
		{
			Debug.LogError(e.ToString(), this);
			Debug.LogError(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, "
			               + "but it is missing either CameraLeft or CameraRight child object or their Camera components.");
			gameObject.SetActive(false);
			return;
		}

		if(isDifferentCenterMask || isDifferentLeftMask || isDifferentRightMask)
		{
			string differingMasksList = isDifferentCenterMask?"Camera":"";
			if(differingMasksList.Length == 0)
				differingMasksList += isDifferentLeftMask?"CameraLeft":"";
			else
				differingMasksList += isDifferentLeftMask?", CameraLeft":"";
			if(differingMasksList.Length == 0)
				differingMasksList += isDifferentRightMask?"CameraRight":"";
			else
				differingMasksList += isDifferentRightMask?", CameraRight":"";

			Debug.LogWarning(  "GameObject " + name + " has " + typeof(RUISCamera) + " script, whose "
			                 + "Culling Mask property has overwritten Culling Masks of its [" + differingMasksList + "]." );

		}
		
		centerCamera.cullingMask = cullingMask;
		leftCamera.cullingMask = cullingMask;
		rightCamera.cullingMask = cullingMask;
	}