Exemplo n.º 1
0
        private float w, x, y, z; // for Vector3 and Quaternion components

        #endregion Fields

        #region Constructors

        public PSMoveController(int index, PSMoveTracker tracker)
        {
            this.Index = index;
            this.tracker = tracker;
            this.Connect();

            this.position = new Vector3();
            this.rawPosition = new Vector3();
            this.centerPosition = new Vector3();
            this.rotation = new Quaternion();
            this.gyroscope = new Vector3();
            this.accelerometer = new Vector3();
            this.led = new RGB_Color();
            this.rumble = (char)0;
            this.buttons = 0;
            this.buttonsPressed = 0;
            this.buttonsReleased = 0;

            Global = new PSMoveGlobal(this);
        }
Exemplo n.º 2
0
        public static TssError UpdateQuaternion(int deviceId, Quaternion quaternion)
        {
            uint timestamp;
            var quat = new float[4];
            TssStreamPacket packet;
            TssError error;
            if (isStreaming)
            {
                error = tss_getLastStreamData(deviceId, out packet, 16, out timestamp);
                quat[0] = packet.quat[0];
                quat[1] = packet.quat[1];
                quat[2] = packet.quat[2];
                quat[3] = packet.quat[3];
            }
            else
            {
                error = tss_getTaredOrientationAsQuaternion((uint)deviceId, quat, out timestamp); //xyzw
            }
            quaternion.Update(quat[3], quat[0], quat[1], quat[2], false);

            return error;
        }
Exemplo n.º 3
0
        public static TssError UpdateSensor(uint deviceId, Quaternion quaternion, out byte button_state)
        {
            uint timestamp;
            var quat = new float[4];
            TssError error;
            if (stream_button_state)
            {
                TssStreamPacketQuatButton packet;
                error = tss_getLastStreamData(deviceId, out packet, 17, out timestamp);
                quat[0] = packet.quat[0];
                quat[1] = packet.quat[1];
                quat[2] = packet.quat[2];
                quat[3] = packet.quat[3];
                button_state = packet.button_state;
            }
            else
            {
                TssStreamPacketQuat packet;
                error = tss_getLastStreamData(deviceId, out packet, 16, out timestamp);
                quat[0] = packet.quat[0];
                quat[1] = packet.quat[1];
                quat[2] = packet.quat[2];
                quat[3] = packet.quat[3];
                button_state = 0;
            }
            quaternion.Update(quat[3], quat[0], quat[1], quat[2], false);

            return error;
        }