void Start() {
        //Set the scale of Destiny's screens to account or not account for bezel.
        if (CC_CONFIG.IsDestiny()) {
            foreach (Transform child in CC_DESTINY_SCREENS.transform) {
                child.localScale = new Vector3(0.6797f, 1.208f, 1.0f);
            }
        } else {
            foreach (Transform child in CC_DESTINY_SCREENS.transform) {
                child.localScale = new Vector3(0.701675f, 1.2255f, 1.0f);
            }
        }

        //Set the visibility of the wand models and screens
        CC_WAND[0].transform.Find("CC_AXIS_MODEL").gameObject.SetActive(false);
        CC_WAND[1].transform.Find("CC_AXIS_MODEL").gameObject.SetActive(false);

        CC_INNOVATOR_SCREENS.SetActive(false);
        CC_DESTINY_SCREENS.SetActive(false);

        //GUI Setup
        style = new GUIStyle();
        if (CC_CONFIG.IsDestiny() || CC_CONFIG.IsInnovator()) {
            style.fontSize = 100;
        } else {
            style.fontSize = 25;
        }
        style.normal.textColor = Color.white;
    }
    /// <summary>
    /// Displays the information to the screen.
    /// </summary>
    void OnGUI() {

        if ((Time.time - startTime) < popupDuration) {
            Rect textRect = new Rect();
            string canoePrefix = "CC_CANOE - ";
            string orientation = "";

            if (CC_CONFIG.IsInnovator() || CC_CONFIG.IsDestiny()) {
                textRect = new Rect(10f, Screen.height - 115, 200, 100);
            } else {
                textRect = new Rect(10f, Screen.height - 30, 200, 100);
            }

            if (simulatorActiveWand == Wand.Left) {
                orientation = "Left";
            } else if (simulatorActiveWand == Wand.Right) {
                orientation = "Right";
            }

            if (CC_CONFIG.IsInnovator() || CC_CONFIG.IsDestiny()) {
                if (guiDisplay.Contains("wandModel")) {
                    GUI.Label(textRect, canoePrefix + "Wand Model: " + guiDisplay.Substring(9), style);
                }
            } else {
                if (guiDisplay.Contains("wandModel")) {
                    GUI.Label(textRect, canoePrefix + orientation + " Simulator Wand, Model: " + guiDisplay.Substring(9), style);
                } else if (guiDisplay.Contains("showScreen")) {
                    GUI.Label(textRect, canoePrefix + "CANOE Model: " + guiDisplay.Substring(10), style);
                }
            }
        }
    }
    void Awake() {
        //Load Settings from the XML File
        if (!Application.isEditor) {
            CC_CONFIG.LoadXMLConfig();
        }

        CC_CONFIG.LoadXMLConfig();

        //Get the GameObjects attached to the canoe.
        CC_WAND = new GameObject[2];
        CC_WAND[0] = transform.Find("CC_WAND_LEFT").gameObject;
        CC_WAND[1] = transform.Find("CC_WAND_RIGHT").gameObject;
        CC_HEAD = transform.Find("CC_HEAD").gameObject;
        charController = GetComponent<CharacterController>();
        CC_CANOEOBJ = gameObject;
        CC_INNOVATOR_SCREENS = transform.Find("CC_INNOVATOR_SCREENS").gameObject;
        CC_DESTINY_SCREENS = transform.Find("CC_DESTINY_SCREENS").gameObject;
        if (isVive()) {
            CC_GUI = transform.Find("CC_GUI_VIVE").gameObject;
            systemType = "vive";
        } else if (isOptiTrack()) {
            CC_GUI = transform.Find("CC_GUI_OPTITRACK").gameObject;
            systemType = "optitrack";
        }
        keyboardControls = kbcont;
        navigator = gameObject.GetComponent<CCaux_OmniNavigator>();

        // Only checks and sets vrpn
        if (ClusterNetwork.isMasterOfCluster) {
            StartCoroutine(oneTimeServerVrpnSet());
        }
        return;
    }
 public void OnPreprocessBuild(BuildTarget target, string path)
 {
     PlayerSettings.defaultIsFullScreen = false;
     if (CC_CONFIG.IsDestiny())
     {
         PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Disabled;
     }
     else if (CC_CONFIG.IsInnovator())
     {
         PlayerSettings.displayResolutionDialog = ResolutionDialogSetting.Enabled;
     }
     PlayerSettings.resizableWindow = true;
 }
    /// <summary>
    /// Set the perspective of the Destiny camera rig.
    /// </summary>
    private void setDestinyPerspective()
    {
        if (!CC_CONFIG.IsDestiny())
        {
            m_DestinyCameraRig.UpdateCameraPerspective(destinyCameras, destinyCameraIndex, panOptic);
        }
        else
        {
            int cameraIndex = GetCameraIndex();

            if (cameraIndex == -1)
            {
                return;
            }

            m_DestinyCameraRig.UpdateCameraPerspective(destinyCameras, cameraIndex, panOptic);
        }
    }
    /// <summary>
    /// Displays the information to the screen.
    /// </summary>
    void OnGUI()
    {
        string value = (interaxial).ToString();

        string camPrefix = "CC_CAMERA - ";

        if (Time.time - guiTimeChange < 3)
        {
            Rect textRect = new Rect();
            if (CC_CONFIG.IsInnovator() || CC_CONFIG.IsDestiny())
            {
                textRect = new Rect(15, 10 /*Screen.height - 115*/, 200, 100);
            }
            else
            {
                textRect = new Rect(5, 10 /*Screen.height - 30*/, 200, 100);
            }

            if (guiDisplay.Equals("interaxialGUI"))
            {
                GUI.Label(textRect, camPrefix + "Interaxial: " + value + "mm", style);
            }
            else if (guiDisplay.Equals("stereoGUI"))
            {
                GUI.Label(textRect, camPrefix + "Stereo: " + savedStereo, style);
            }
            else if (guiDisplay.Equals("panopticGUI"))
            {
                GUI.Label(textRect, camPrefix + "Panoptic: " + panOptic, style);
            }
            else if (guiDisplay.Equals("cameraGUI"))
            {
                GUI.Label(textRect, camPrefix + "Camera Type: " + selectCamera.ToString(), style);
            }
            else if (guiDisplay.Equals("cameraIndex"))
            {
                GUI.Label(textRect, camPrefix + "Camera Index: MAUI " + (destinyCameraIndex + 1), style);
            }
        }
    }
 void Start()
 {
     wandPosition = new Vector3[2];
     wandRotation = new Quaternion[2];
     setDefaultPositions();
     canoe = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();
     if (canoe.isVive())
     {
         yaw_pitchKey          = KeyCode.T;
         rollKey               = KeyCode.O;
         left_right_up_downKey = KeyCode.V;
         left_right_in_outKey  = KeyCode.Comma;
         if (CC_CONFIG.IsDestiny())
         {
             addViveClusterInputs();
         }
     }
     else if (canoe.isOptiTrack() && CC_CONFIG.IsDestiny())
     {
         addOptiTrackClusterInputs();
     }
 }
    /// <summary>
    /// Obtain tracker information.
    /// </summary>
    private void getTrackerInformation()
    {
        if (CC_CONFIG.IsDestiny())
        {
            Vector3    position = new Vector3(0, 0, 0);
            Quaternion rotation = Quaternion.identity;

            if (canoe.isVive())
            {
                //Update head ClusterInput entry
                position = ClusterInput.GetTrackerPosition("head");
                rotation = ClusterInput.GetTrackerRotation("head");
                //Angle puck so flat section is bottom
                //Change "Camera Forward Tilt" in editor to change tilt if hat/helmet is angled
                rotation *= Quaternion.AngleAxis(90 - canoe.cameraForwardTilt, Vector3.left);
                rotation *= Quaternion.AngleAxis(180, Vector3.up);
                convertHeadTracking(position, rotation);

                //Update left controller ClusterInput entries
                position = ClusterInput.GetTrackerPosition("leftWand");
                rotation = ClusterInput.GetTrackerRotation("leftWand");
                convertWandTracking(Wand.Left, position, rotation);

                //Update right controller ClusterInput entries
                position = ClusterInput.GetTrackerPosition("rightWand");
                rotation = ClusterInput.GetTrackerRotation("rightWand");
                convertWandTracking(Wand.Right, position, rotation);

                //Moving the Character Controller with the head movement
                float same = CC_CANOE.CanoeCharacterController().center.y;
                CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);
            }
            else if (canoe.isOptiTrack())
            {
                //Head position and rotation
                position = ClusterInput.GetTrackerPosition("head");
                //position = new Vector3(position.x, position.y, -position.z);
                rotation = ClusterInput.GetTrackerRotation("head");
                convertHeadTracking(position, rotation);

                //Left wand position and rotation
                position = ClusterInput.GetTrackerPosition("leftWand");
                rotation = ClusterInput.GetTrackerRotation("leftWand");
                convertWandTracking(Wand.Left, position, rotation);

                //Right wand position and rotation
                position = ClusterInput.GetTrackerPosition("rightWand");
                rotation = ClusterInput.GetTrackerRotation("rightWand");
                convertWandTracking(Wand.Right, position, rotation);

                //Moving the Character Controller with the head movement
                float same = CC_CANOE.CanoeCharacterController().center.y;

                CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);
            }
        }
        else
        {
            if (CC_CONFIG.IsInnovator())
            {
                //if (checkInnovatorTracking()) {
                headPosition = convertToLeftHandPosition(VRPN.vrpnTrackerPos("CC_FLAT_HEAD@" + CC_CONFIG.innovatorIP, 0));
                headRotation = convertToLeftHandRotation(VRPN.vrpnTrackerQuat("CC_FLAT_HEAD@" + CC_CONFIG.innovatorIP, 0) * Quaternion.AngleAxis(90 - canoe.cameraForwardTilt, Vector3.left) * Quaternion.AngleAxis(180, Vector3.up));

                //Moving the Character Controller with the head movement
                float same = CC_CANOE.CanoeCharacterController().center.y;
                CC_CANOE.CanoeCharacterController().center = new Vector3(headPosition.x, same, headPosition.z);

                //Wands rotation and position.
                wandPosition[0] = convertToLeftHandPosition(VRPN.vrpnTrackerPos("CC_FLAT_WAND0@" + CC_CONFIG.innovatorIP, 0));
                wandPosition[1] = convertToLeftHandPosition(VRPN.vrpnTrackerPos("CC_FLAT_WAND1@" + CC_CONFIG.innovatorIP, 0));
                wandRotation[0] = convertToLeftHandRotation(VRPN.vrpnTrackerQuat("CC_FLAT_WAND0@" + CC_CONFIG.innovatorIP, 0));
                wandRotation[1] = convertToLeftHandRotation(VRPN.vrpnTrackerQuat("CC_FLAT_WAND1@" + CC_CONFIG.innovatorIP, 0));
            }
            else
            {
                setDefaultPositions();
            }
        }
    }
    void Start()
    {
        if (CC_CONFIG.IsInnovator())
        {
            Screen.fullScreen = false;
        }

        //Load Settings
        if (CC_CONFIG.ConfigLoaded())
        {
            interaxial   = (int)CC_CONFIG.interaxial;
            panOptic     = CC_CONFIG.panOptic;
            enableStereo = CC_CONFIG.stereo;
        }

        //Get camera groups
        innovatorCameraGroup = transform.Find("CC_INNOVATOR_CAMERAS").gameObject;
        destinyCameraGroup   = transform.Find("CC_DESTINY_CAMERAS").gameObject;
        simulatorCameraGroup = transform.Find("CC_SIM_CAMERA").gameObject;

        //Simulator Camera Setup
        simCam                 = simulatorCameraGroup.GetComponent <Camera>();
        simCam.rect            = GetComponent <Camera>().rect;
        simCam.nearClipPlane   = GetComponent <Camera>().nearClipPlane;
        simCam.farClipPlane    = GetComponent <Camera>().farClipPlane;
        simCam.clearFlags      = GetComponent <Camera>().clearFlags;
        simCam.backgroundColor = GetComponent <Camera>().backgroundColor;
        simCam.cullingMask     = GetComponent <Camera>().cullingMask;

        //Innovator Camera Setup
        innovatorCamera = innovatorCameraGroup.transform.GetChild(0).gameObject.GetComponent <Camera>();
        innovatorCamera.GetComponent <CC_CAMERASTEREO>().CreateStereoCameras(false);

        //Destiny Camera Setup
        destinyCameras    = new Camera[4];
        destinyCameras[0] = destinyCameraGroup.transform.GetChild(0).GetComponent <Camera>();
        destinyCameras[1] = destinyCameraGroup.transform.GetChild(1).GetComponent <Camera>();
        destinyCameras[2] = destinyCameraGroup.transform.GetChild(2).GetComponent <Camera>();
        destinyCameras[3] = destinyCameraGroup.transform.GetChild(3).GetComponent <Camera>();
        for (int i = 0; i < 4; i++)
        {
            destinyCameras[i].GetComponent <CC_CAMERASTEREO>().CreateStereoCameras(true);
        }

        //Initial Update Cameras
        updateCamerasInteraxials();
        updateCamerasStereo();
        updateCamerasAspectRatio();

        //Save current settings
        savedAspectRatio = GetComponent <Camera>().aspect;
        savedStereo      = enableStereo;
        savedInteraxial  = interaxial;

        //GUI Setup
        style = new GUIStyle();
        if (CC_CONFIG.IsDestiny() || CC_CONFIG.IsInnovator())
        {
            style.fontSize = 100;
        }
        else
        {
            style.fontSize = 25;
        }
        style.normal.textColor = Color.white;

        //Set startup camera according to platform
        if (!Application.isEditor)
        {
            if (CC_CONFIG.IsInnovator())
            {
                selectCamera = SelectedCamera.Innovator;
            }
            else if (CC_CONFIG.IsDestiny())
            {
                selectCamera = SelectedCamera.Destiny;
            }
            else
            {
                selectCamera = SelectedCamera.Simulator;
            }
        }
        changeCameras();
    }