/// <summary>
    /// Add the Destiny ClusterInput settings for Vive for the correct syncing through all clients and masters.
    /// This uses VRPN servers that are launched on Kanaloa 1.
    /// </summary>
    private static void addViveClusterInputs()
    {
        //Head and wand ClusterInput entries added
        ClusterInput.AddInput("head", "CC_FLAT_HEAD", CC_CONFIG.serverIP, 0, ClusterInputType.Tracker);
        ClusterInput.AddInput("leftWand", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 0, ClusterInputType.Tracker);
        ClusterInput.AddInput("rightWand", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 0, ClusterInputType.Tracker);

        //Left wand axis ClusterInput entries added
        ClusterInput.AddInput("leftXAxis", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 0, ClusterInputType.CustomProvidedInput);
        ClusterInput.AddInput("leftYAxis", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 1, ClusterInputType.CustomProvidedInput);
        ClusterInput.AddInput("leftTriggerAxis", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 2, ClusterInputType.CustomProvidedInput);

        //Left wand button ClusterInput entries added
        ClusterInput.AddInput("leftMenu", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 1, ClusterInputType.Button);
        ClusterInput.AddInput("leftGrip", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 2, ClusterInputType.Button);
        ClusterInput.AddInput("leftTrackpad", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 32, ClusterInputType.CustomProvidedInput);
        ClusterInput.AddInput("leftTrigger", "CC_FLAT_WAND0", CC_CONFIG.serverIP, 33, ClusterInputType.CustomProvidedInput);

        //Right wand axis ClusterInput entries added
        ClusterInput.AddInput("rightXAxis", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 0, ClusterInputType.CustomProvidedInput);
        ClusterInput.AddInput("rightYAxis", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 1, ClusterInputType.CustomProvidedInput);
        ClusterInput.AddInput("rightTriggerAxis", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 2, ClusterInputType.CustomProvidedInput);

        //Right wand button ClusterInput entries added
        ClusterInput.AddInput("rightMenu", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 1, ClusterInputType.Button);
        ClusterInput.AddInput("rightGrip", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 2, ClusterInputType.Button);
        ClusterInput.AddInput("rightTrackpad", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 32, ClusterInputType.CustomProvidedInput);
        ClusterInput.AddInput("rightTrigger", "CC_FLAT_WAND1", CC_CONFIG.serverIP, 33, ClusterInputType.CustomProvidedInput);
    }
    /// <summary>
    /// Add the Destiny ClusterInput settings for OptiTrack for the correct syncing through all clients and masters.
    /// This uses VRPN servers that are launched on Kanaloa 1.
    /// </summary>
    private static void addOptiTrackClusterInputs()
    {
        //Head entry added
        ClusterInput.AddInput("head", "CC_FLAT_HEAD", CC_CONFIG.trackerIP, 0, ClusterInputType.Tracker);
        //Wand entries added
        ClusterInput.AddInput("leftWand", "CC_FLAT_WAND0", CC_CONFIG.trackerIP, 0, ClusterInputType.Tracker);
        ClusterInput.AddInput("rightWand", "CC_FLAT_WAND1", CC_CONFIG.trackerIP, 0, ClusterInputType.Tracker);

        //Left axis entries added
        ClusterInput.AddInput("leftXAxis", "XInput0", CC_CONFIG.controllerIP, 0, ClusterInputType.Axis);
        ClusterInput.AddInput("leftYAxis", "XInput0", CC_CONFIG.controllerIP, 1, ClusterInputType.Axis);
        ClusterInput.AddInput("leftTriggerAxis", "XInput0", CC_CONFIG.controllerIP, 5, ClusterInputType.Axis);
        ClusterInput.AddInput("leftDpad", "XInput0", CC_CONFIG.controllerIP, 4, ClusterInputType.Axis);
        //Left button entries added
        ClusterInput.AddInput("leftX", "XInput0", CC_CONFIG.controllerIP, 0, ClusterInputType.Button);
        ClusterInput.AddInput("leftO", "XInput0", CC_CONFIG.controllerIP, 1, ClusterInputType.Button);
        ClusterInput.AddInput("leftShoulder", "XInput0", CC_CONFIG.controllerIP, 4, ClusterInputType.Button);

        //Right axis entries added
        ClusterInput.AddInput("rightXAxis", "XInput1", CC_CONFIG.controllerIP, 0, ClusterInputType.Axis);
        ClusterInput.AddInput("rightYAxis", "XInput1", CC_CONFIG.controllerIP, 1, ClusterInputType.Axis);
        ClusterInput.AddInput("rightTriggerAxis", "XInput1", CC_CONFIG.controllerIP, 5, ClusterInputType.Axis);
        ClusterInput.AddInput("rightDpad", "XInput1", CC_CONFIG.controllerIP, 4, ClusterInputType.Axis);
        //Right button entries added
        ClusterInput.AddInput("rightX", "XInput1", CC_CONFIG.controllerIP, 0, ClusterInputType.Button);
        ClusterInput.AddInput("rightO", "XInput1", CC_CONFIG.controllerIP, 1, ClusterInputType.Button);
        ClusterInput.AddInput("rightShoulder", "XInput1", CC_CONFIG.controllerIP, 4, ClusterInputType.Button);
    }
 // Use this for initialization
 void Start()
 {
     ClusterInput.AddInput("MouseTestX", "testDevice1", "10.0.1.28", 0, ClusterInputType.CustomProvidedInput);
     ClusterInput.AddInput("MouseTestY", "testDevice2", "10.0.1.28", 0, ClusterInputType.CustomProvidedInput);
     if (ClusterNetwork.IsMasterOfCluster())
     {
         Debug.Log("I am the cluster master");
     }
     else
     {
         Debug.Log("I am the cluster slave");
     }
 }
 /// <summary>
 /// Obtains the correct trackpad and trigger button values directly from VRPN and sets
 /// ClusterInput entries to correct value. Implemented because initial values
 /// from ClusterInput are incorrect.
 /// </summary>
 private static System.Collections.IEnumerator endOfFrameForMaster() {
     yield return new WaitForEndOfFrame();
     //Trackpad button updates
     ClusterInput.SetButton("leftTrackpad", VRPN.vrpnButton("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 32));
     ClusterInput.SetButton("rightTrackpad", VRPN.vrpnButton("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 32));
     //Trackpad axis updates
     ClusterInput.SetAxis("leftXAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 0));
     ClusterInput.SetAxis("leftYAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 1));
     ClusterInput.SetAxis("rightXAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 0));
     ClusterInput.SetAxis("rightYAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 1));
     //Trigger button updates
     ClusterInput.SetButton("leftTrigger", VRPN.vrpnButton("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 33));
     ClusterInput.SetButton("rightTrigger", VRPN.vrpnButton("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 33));
     //Trigger axis updates
     ClusterInput.SetAxis("leftTriggerAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND0@" + CC_CONFIG.serverIP, 2));
     ClusterInput.SetAxis("rightTriggerAxis", (float)VRPN.vrpnAnalog("CC_FLAT_WAND1@" + CC_CONFIG.serverIP, 2));
 }
    // Update is called once per frame
    void Update()
    {
        if (ClusterNetwork.IsMasterOfCluster())
        {
            Vector3 mousepos = Input.mousePosition;
            mousepos.x /= Screen.width;
            mousepos.y /= Screen.height;
            ClusterInput.SetAxis("MouseTestX", mousepos.x);
            ClusterInput.SetAxis("MouseTestY", mousepos.y);
            Debug.Log("SetAxis to" + mousepos.ToString());
        }

        Vector2 pos = new Vector2();

        pos.x = ClusterInput.GetAxis("MouseTestX");
        pos.y = ClusterInput.GetAxis("MouseTestY");
        this.transform.position = new Vector3(pos.x, pos.y, 5.0f);
        Debug.Log("getAxis" + pos.ToString());
    }
示例#6
0
    /// <summary>
    /// Abstract method to return raw data from the device.
    /// Returns the trigger based raw device value.
    /// </summary>
    /// <returns>Raw (untransformed) device data</returns>
    public override object GetRawValue()
    {
        /// Get current device state
        bool curVal   = ClusterInput.GetButton(id);
        int  curFrame = Time.frameCount;
        bool retVal   = false;

        /// If the value has already been retreived this frame, the return
        /// the result.
        if (curFrame == lastFrame)
        {
            retVal = lastRetVal;
        }
        else
        {
            /// Otherwise get the value of the button and save state.
            if (Trigger == ToggleState.Value)
            {
                retVal = curVal;
            }
            else if (Trigger == ToggleState.Press)
            {
                retVal = curVal && !lastValue;
            }
            else if (Trigger == ToggleState.Release)
            {
                retVal = !curVal && lastValue;
            }
            else
            {
                retVal = false;
            }

            lastValue  = curVal;
            lastFrame  = curFrame;
            lastRetVal = retVal;
        }

        /// return the button value.
        return(retVal);
    }
    // Update is called once per frame
    void Update()
    {
        List <Device> vrpnDevices = (from device in InputManager.map.Devices
                                     where device is VRPN
                                     select device).ToList();

        if (VRPNTimeline == VRPNTimelineType.Off ||
            timelines.Count != vrpnDevices.Count())
        {
            foreach (TimeLine iv in timelines)
            {
                Destroy(iv.gameObject);
            }
            timelines.Clear();
        }

        if (VRPNTimeline != VRPNTimelineType.Off)
        {
            if (timelines.Count < vrpnDevices.Count)
            {
                for (int i = 0; i < vrpnDevices.Count; i++)
                {
                    GameObject plot = new GameObject();
                    plot.transform.parent = transform;
                    plot.name             = vrpnDevices[i].ToString();

                    TimeLine iv = plot.AddComponent <TimeLine>();
                    timelines.Add(iv);

                    plot.transform.localPosition =
                        new Vector3(0, -i * .3f);
                }
            }

            for (int i = 0; i < vrpnDevices.Count; i++)
            {
                // Only VRPN devices are shown.
                VRPN device = vrpnDevices[i] as VRPN;

                float value = 0f;

                if (VRPNTimeline == VRPNTimelineType.FromClusterInput)
                {
                    if (device.InputType == ClusterInputType.Axis)
                    {
                        value = ClusterInput.GetAxis(device.id);
                    }

                    if (device.InputType == ClusterInputType.Button)
                    {
                        value = ClusterInput.GetButton(device.id) ? 1f : 0f;
                    }
                }
                else
                {
                    object valueObject = null;

                    if (VRPNTimeline == VRPNTimelineType.FromDeviceClassRaw)
                    {
                        valueObject = device.GetRawValue();
                    }

                    if (VRPNTimeline == VRPNTimelineType.FromDeviceClassTransformed)
                    {
                        valueObject = device.GetValue();
                    }

                    value = (device.GetRawValue() as float?).GetValueOrDefault();

                    if (valueObject is bool)
                    {
                        value = (valueObject as bool?).GetValueOrDefault() ? 1.0f : 0f;
                    }
                }

                timelines[i].AddPt(value);
            }
        }
    }
 public icClusterInput(string s)
 {
     this.inputName = s;
     ClusterInput.AddInput(this.inputName, this.inputName, icClusterInput.masterIP, 0, ClusterInputType.CustomProvidedInput);
 }
 public float GetValue()
 {
     return(ClusterInput.GetAxis(this.inputName));
 }
 public void SetValue(float f)
 {
     ClusterInput.SetAxis(inputName, f);
 }
 public bool GetValue()
 {
     return(ClusterInput.GetButton(this.inputName));
 }
 public void SetValue(bool f)
 {
     ClusterInput.SetButton(this.inputName, f);
 }
    /// <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();
            }
        }
    }
示例#14
0
 /// <summary>
 /// Return the tracker data.
 /// </summary>
 /// <returns>Raw (untransformed) device data</returns>
 public override object GetRawValue()
 {
     return(new TrackerData(ClusterInput.GetTrackerPosition(id),
                            ClusterInput.GetTrackerRotation(id)));
 }
示例#15
0
 /// <summary>
 /// Return the value of the axis.
 /// </summary>
 /// <returns>Axis value</returns>
 public override object GetRawValue()
 {
     return(ClusterInput.GetAxis(id));
 }
示例#16
0
 /// <summary>
 /// Configure the VRPN device with the Unity ClusterInput service.
 /// </summary>
 public override void Configure()
 {
     /// Addes the VRPN device to the Unity Cluster Input class.
     ClusterInput.AddInput(id.ToString(), Device, Server, Index, InputType);
 }