// 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());
    }
    // 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);
            }
        }
    }
Пример #3
0
 public float GetValue()
 {
     return(ClusterInput.GetAxis(this.inputName));
 }
Пример #4
0
 /// <summary>
 /// Return the value of the axis.
 /// </summary>
 /// <returns>Axis value</returns>
 public override object GetRawValue()
 {
     return(ClusterInput.GetAxis(id));
 }