Ejemplo n.º 1
0
 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();
     }
 }
Ejemplo n.º 2
0
    public override void OnInspectorGUI()
    {
        //Disconnect the prefab instance from the original prefab
        bool isPrefabOriginal = (PrefabUtility.GetPrefabParent(target) == null) && (PrefabUtility.GetPrefabObject(target) != null);

        if (!isPrefabOriginal)
        {
            PrefabUtility.DisconnectPrefabInstance(target);
        }

        EditorGUI.BeginChangeCheck();

        GUILayout.Space(10);
        EditorGUILayout.LabelField("Grabber Settings", EditorStyles.boldLabel);

        bool enableGrabbing = EditorGUILayout.Toggle(new GUIContent("Enable Grabbing", "Toggles grabbing using the specified wand."), grabTarget.enableGrabbing);

        //Disable grabbing if enable grabbin is false
        EditorGUI.BeginDisabledGroup(!enableGrabbing);

        bool grabWithTrigger = EditorGUILayout.Toggle(new GUIContent("Grab With Trigger", "Toggles navigation with trigger. Overrides Grab Button."), grabTarget.grabWithTrigger);

        //Disable grab button if grab with trigger is true
        EditorGUI.BeginDisabledGroup(grabWithTrigger);

        WandButton validGrabButton = grabTarget.grabButton;
        WandButton grabButton      = (WandButton)EditorGUILayout.EnumPopup(new GUIContent("Grab Button", "Select button to be used to grab."), grabTarget.grabButton);

        //End grab button disabled group
        EditorGUI.EndDisabledGroup();

        //End grabber disabled group
        EditorGUI.EndDisabledGroup();

        GUILayout.Space(20);

        EditorGUI.EndChangeCheck();

        Undo.RecordObject(grabTarget, "Updated Grabber Settings");
        canoe = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();

        //GRABBER STARTS
        grabTarget.enableGrabbing  = enableGrabbing;
        grabTarget.grabWithTrigger = grabWithTrigger;

        string location = "CCaux_Grabber on " + grabTarget.gameObject.name + "/\"Grabber Settings\"/\"Grab Button\"";

        //Button logic to keep user from selecting incorrect input for grab button
        if (canoe.isVive() && !CC_INPUT.IsViveInput(grabButton))
        {
            if (!CC_INPUT.IsEnumSeparator(grabButton))
            {
                if (!CC_INPUT.IsViveInput(validGrabButton))
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not Vive input. Defaulting to \"Menu\" button.");
                    grabButton = grabTarget.grabButton = WandButton.Menu;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not Vive input.");
                    grabButton = grabTarget.grabButton = validGrabButton;
                }
            }
            throw new ExitGUIException();
        }
        else if (canoe.isOptiTrack() && !CC_INPUT.IsOptiTrackInput(grabButton))
        {
            if (!CC_INPUT.IsEnumSeparator(grabButton))
            {
                if (!CC_INPUT.IsOptiTrackInput(validGrabButton))
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not OptiTrack input. Defaulting to \"X\" button.");
                    grabButton = grabTarget.grabButton = WandButton.X;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + grabButton + "\" is not OptiTrack input.");
                    grabButton = grabTarget.grabButton = validGrabButton;
                }
            }
            throw new ExitGUIException();
        }
        else
        {
            grabTarget.grabButton = grabButton;
        }
        //Button logic end

        //GRABBER ENDS
    }
    public override void OnInspectorGUI()
    {
        //Get This Target
        navTarget = (CCaux_OmniNavigator)target;
        canoe     = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();
        //Disconnect the prefab instance from the original prefab
        bool isPrefabOriginal = (PrefabUtility.GetPrefabParent(target) == null) && (PrefabUtility.GetPrefabObject(target) != null);

        if (!isPrefabOriginal)
        {
            PrefabUtility.DisconnectPrefabInstance(target);
        }

        EditorGUI.BeginChangeCheck();

        //NAVIGATION STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Navigation Settings", EditorStyles.boldLabel);
        bool enableNavigation = EditorGUILayout.Toggle(new GUIContent("Enable Navigation", "Toggle navigation using navigation input (default is trigger)."), navTarget.enableNavigation);

        //Disable navigation if enable navigation is false
        EditorGUI.BeginDisabledGroup(!enableNavigation);

        bool disableNavigationX = EditorGUILayout.Toggle(new GUIContent("Disable X-Axis Movement", "Toggle movement in the X-axis while navigating."), navTarget.disableNavigationX);
        bool disableNavigationY = EditorGUILayout.Toggle(new GUIContent("Disable Y-Axis Movement", "Toggle movement in the Y-axis while navigating."), navTarget.disableNavigationY);
        bool disableNavigationZ = EditorGUILayout.Toggle(new GUIContent("Disable Z-Axis Movement", "Toggle movement in the Z-axis while navigating."), navTarget.disableNavigationZ);

        CCaux_OmniNavigator.rotationLock lockRotation = (CCaux_OmniNavigator.rotationLock)EditorGUILayout.EnumPopup(new GUIContent("Lock Rotation Around Axis", "Select an axis to lock rotation around."), navTarget.lockRotation);
        Wand wandToUse      = (Wand)EditorGUILayout.EnumPopup(new GUIContent("Navigation Wand", "Select wand to use for navigation."), navTarget.wandToUse);
        bool navWithTrigger = EditorGUILayout.Toggle(new GUIContent("Navigate with Trigger", "Toggles navigation with trigger. Overrides Navigation Button."), navTarget.navWithTrigger);

        //Disable navigation button selection if trigger is used for navigation
        EditorGUI.BeginDisabledGroup(navWithTrigger);
        WandButton validNavButton = navTarget.navButton;
        WandButton navButton      = (WandButton)EditorGUILayout.EnumPopup(new GUIContent("Navigation Button", "Select button to use for navigation."), navTarget.navButton);

        //End navigation button disabled group
        EditorGUI.EndDisabledGroup();

        float moveSpeed   = EditorGUILayout.FloatField(new GUIContent("Movement Speed", "Set navigation movement speed."), navTarget.moveSpeed);
        float rotateSpeed = EditorGUILayout.FloatField(new GUIContent("Rotation Speed", "Set navigation rotation speed."), navTarget.rotateSpeed);

        //NAVIGATION ENDS

        //RESET STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Reset Settings", EditorStyles.boldLabel);
        WandButton validResetButton = navTarget.resetButton;
        WandButton resetButton      = (WandButton)EditorGUILayout.EnumPopup(new GUIContent("Reset Button", "Select button to reset CANOE position."), navTarget.resetButton);
        float      resetSpeed       = EditorGUILayout.FloatField(new GUIContent("Reset Speed", "Set the CANOE's speed when returning to its reset position."), navTarget.resetSpeed);
        Vector3    resetPosition    = EditorGUILayout.Vector3Field(new GUIContent("Reset Position", "Set the CANOE's reset position."), navTarget.resetPosition);
        Vector3    resetRotation    = EditorGUILayout.Vector3Field(new GUIContent("Reset Rotation", "Set the CANOE's reset rotation."), navTarget.resetRotation);

        //RESET ENDS

        //MISC STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Misc Settings", EditorStyles.boldLabel);
        GameObject cursor = (GameObject)EditorGUILayout.ObjectField(new GUIContent("Cursor Object", "Set object to display while navigating."), navTarget.cursor, typeof(Object), true);

        //MISC ENDS

        //End navigation disabled group
        EditorGUI.EndDisabledGroup();

        GUILayout.Space(20);

        EditorGUI.EndChangeCheck();

        Undo.RecordObject(navTarget, "Updated Navigator Settings");
        canoe = GameObject.Find("CC_CANOE").GetComponent <CC_CANOE>();

        //NAVIGATION STARTS
        navTarget.enableNavigation   = enableNavigation;
        navTarget.disableNavigationX = disableNavigationX;
        navTarget.disableNavigationY = disableNavigationY;
        navTarget.disableNavigationZ = disableNavigationZ;

        navTarget.lockRotation   = lockRotation;
        navTarget.wandToUse      = wandToUse;
        navTarget.navWithTrigger = navWithTrigger;

        string location = "CCaux_OmniNavigator/\"Navigation Settings\"/\"Navigation Button\"";

        //Button logic to keep user from selecting incorrect input for navigation button
        if (canoe.isVive() && !CC_INPUT.IsViveInput(navButton))
        {
            if (!CC_INPUT.IsEnumSeparator(navButton))
            {
                if (!CC_INPUT.IsViveInput(validNavButton))
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not Vive input. Defaulting to \"Menu\" button.");
                    navButton = navTarget.navButton = WandButton.Menu;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not Vive input.");
                    navButton = navTarget.navButton = validNavButton;
                }
            }
            throw new ExitGUIException();
        }
        else if (canoe.isOptiTrack() && !CC_INPUT.IsOptiTrackInput(navButton))
        {
            if (!CC_INPUT.IsEnumSeparator(navButton))
            {
                if (!CC_INPUT.IsOptiTrackInput(validNavButton))
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not OptiTrack input. Defaulting to \"X\" button.");
                    navButton = navTarget.navButton = WandButton.X;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + navButton + "\" is not OptiTrack input.");
                    navButton = navTarget.navButton = validNavButton;
                }
            }
            throw new ExitGUIException();
        }
        else
        {
            navTarget.navButton = navButton;
        }
        //Button logic end

        navTarget.moveSpeed   = moveSpeed;
        navTarget.rotateSpeed = rotateSpeed;
        //NAVIGATION ENDS

        //RESET STARTS
        location = "CCaux_OmniNavigator/\"Reset Settings\"/\"Reset Button\"";

        //Button logic to keep user from selecting incorrect input for reset button
        if (canoe.isVive() && !CC_INPUT.IsViveInput(resetButton))
        {
            if (!CC_INPUT.IsEnumSeparator(resetButton))
            {
                if (!CC_INPUT.IsViveInput(validResetButton))
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not Vive input. Defaulting to \"Menu\" button.");
                    resetButton = navTarget.resetButton = WandButton.Menu;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not Vive input.");
                    resetButton = navTarget.resetButton = validResetButton;
                }
            }
            throw new ExitGUIException();
        }
        else if (canoe.isOptiTrack() && !CC_INPUT.IsOptiTrackInput(resetButton))
        {
            if (!CC_INPUT.IsEnumSeparator(resetButton))
            {
                if (!CC_INPUT.IsOptiTrackInput(validResetButton))
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not OptiTrack input. Defaulting to \"X\" button.");
                    resetButton = navTarget.resetButton = WandButton.X;
                }
                else
                {
                    Debug.LogError(location + ": Wand button \"" + resetButton + "\" is not OptiTrack input.");
                    resetButton = navTarget.resetButton = validResetButton;
                }
            }
            throw new ExitGUIException();
        }
        else
        {
            navTarget.resetButton = resetButton;
        }
        //Button logic end

        navTarget.resetSpeed    = resetSpeed;
        navTarget.resetPosition = resetPosition;
        navTarget.resetRotation = resetRotation;
        //RESET ENDS

        //MISC STARTS
        navTarget.cursor = cursor;
        //MISC ENDS
    }
Ejemplo n.º 4
0
    /// <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();
            }
        }
    }
Ejemplo n.º 5
0
    public override void OnInspectorGUI()
    {
        //Get This Target
        canoeTarget = (CC_CANOE)target;
        //Disconnect the CC_CANOE prefab instance from the original prefab
        bool isPrefabOriginal = (PrefabUtility.GetPrefabParent(target) == null) && (PrefabUtility.GetPrefabObject(target) != null);

        if (!isPrefabOriginal)
        {
            PrefabUtility.DisconnectPrefabInstance(target);
        }

        EditorGUI.BeginChangeCheck();

        //TRACKING STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Tracking Settings", EditorStyles.boldLabel);
        bool vive      = EditorGUILayout.Toggle(new GUIContent("Vive Tracking", "Use the HTC Vive tracking system."), canoeTarget.vive);
        bool optitrack = EditorGUILayout.Toggle(new GUIContent("OptiTrack Tracking", "Use the OptiTrack tracking system."), canoeTarget.optitrack);

        //TRACKING ENDS

        //CAMERA STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Camera Settings", EditorStyles.boldLabel);
        selCamera       = (CC_CAMERA.SelectedCamera)EditorGUILayout.EnumPopup(new GUIContent("Selected Camera", "Select which camera to use. Keyboard Shortcut: 'P'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().selectCamera);
        enableStereo    = EditorGUILayout.Toggle(new GUIContent("Enable Stereo", "Enable/Disable stereoscopic. Keyboard Shortcut: '9'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().enableStereo);
        interaxial      = EditorGUILayout.IntField(new GUIContent("Interaxial", "Interaxial distance in millimeters.Keyboard Shortcut: '-' and '+'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().interaxial);
        destCameraIndex = (int)EditorGUILayout.Slider(new GUIContent("Destiny Camera Index", "Change the view to different cameras of Destiny. Keyboard Shortcut: '[' and ']'"), GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().destinyCameraIndex, 0, 7);
        float cameraForwartTilt = EditorGUILayout.Slider(new GUIContent("Camera Forward Tilt", "Change the foward tilt of the camera."), canoeTarget.cameraForwardTilt, -90f, 90f);

        //CAMERA ENDS

        //WANDS STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Wand Settings", EditorStyles.boldLabel);
        Wand simulatorActiveWand = (Wand)EditorGUILayout.EnumPopup(new GUIContent("Selected Wand", "The currently active simulator wand."), canoeTarget.simulatorActiveWand);

        CC_CANOE.WandModel wandModel = (CC_CANOE.WandModel)EditorGUILayout.EnumPopup(new GUIContent("Wand Model", "The wand model you wish to be visible. Keyboard Shortcut: '5'"), canoeTarget.wandModel);
        if (canoeTarget.isVive())
        {
            dpadType         = (DpadType)EditorGUILayout.EnumPopup(new GUIContent("Dpad Type", "The Dpad configuration (4 directions or 8 directions) you wish to use."), canoeTarget.dpadType);
            centerClickRange = EditorGUILayout.Slider(new GUIContent("Center Click Range", "Change the range of the Dpad center click."), canoeTarget.centerClickRange, 0.1f, 0.9f);
        }
        //WAND ENDS

        //SIM NAV STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Simulator Navigation Settings", EditorStyles.boldLabel);
        float navigationSpeed         = EditorGUILayout.FloatField(new GUIContent("Movement Speed", "Navigation speed of the simulator controls. (Only affects WASD key movement)"), canoeTarget.navigationSpeed);
        float navigationRotationSpeed = EditorGUILayout.FloatField(new GUIContent("Rotational Speed", "Rotational speed of the simulator controls. (Only affects WASD key movement)"), canoeTarget.navigationRotationSpeed);

        //SIM NAV ENDS

        //MISC STARTS
        GUILayout.Space(10);
        EditorGUILayout.LabelField("Misc Settings", EditorStyles.boldLabel);
        CC_CANOE.ShowScreen showScreen = (CC_CANOE.ShowScreen)EditorGUILayout.EnumPopup(new GUIContent("Show Screen", "Enable/Disable the visibility of the CyberCANOE's Screens. Typically you want this set to none unless you are debugging in the editor. Keyboard Shortcut: '6'"), canoeTarget.showScreen);
        bool applyGravity = EditorGUILayout.Toggle(new GUIContent("Apply Gravity", "Enable or disable gravity the Canoe/Player experiences. Does not affect other objects in the scene."), canoeTarget.applyGravity);
        bool kbcont       = EditorGUILayout.Toggle(new GUIContent("Keyboard Controls", "Enable or disable the keyboard controls. This affects the simualtor, camera, and canoe controls."), canoeTarget.kbcont);

        //MISC ENDS

        EditorGUI.EndChangeCheck();

        GUILayout.Space(20);
        GUIStyle style = new GUIStyle(GUI.skin.button);

        style.fontSize  = 12;
        style.fontStyle = FontStyle.Bold;

        if (GUI.changed)
        {
            try {
                Undo.RecordObject(canoeTarget, "Updated Canoe Settings");
                //TRACKING STARTS
                if (vive && !canoeTarget.vive)
                {
                    canoeTarget.vive      = true;
                    canoeTarget.optitrack = false;
                }
                else if (optitrack && !canoeTarget.optitrack)
                {
                    canoeTarget.vive      = false;
                    canoeTarget.optitrack = true;
                }
                //TRACKING ENDS

                //CAMERA STARTS
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().selectCamera       = selCamera;
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().enableStereo       = enableStereo;
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().destinyCameraIndex = destCameraIndex;
                GameObject.Find("CC_HEAD").GetComponent <CC_CAMERA>().interaxial         = interaxial;
                canoeTarget.cameraForwardTilt = cameraForwartTilt;
                //CAMERA ENDS

                //WAND STARTS
                canoeTarget.simulatorActiveWand = simulatorActiveWand;
                canoeTarget.wandModel           = wandModel;
                canoeTarget.dpadType            = dpadType;
                canoeTarget.centerClickRange    = centerClickRange;
                //WAND ENDS

                //SIM NAV STARTS
                canoeTarget.navigationSpeed         = navigationSpeed;
                canoeTarget.navigationRotationSpeed = navigationRotationSpeed;
                //SIM NAV ENDS

                //MISC STARTS
                canoeTarget.showScreen   = showScreen;
                canoeTarget.applyGravity = applyGravity;
                canoeTarget.kbcont       = kbcont;
                //MISC ENDS
            }
            catch (System.NullReferenceException) {
                Debug.Log("CC_HEAD can't be found. CC_HEAD should be a child of CC_CANOE.");
            }
        }
    }