Example #1
0
        /// <summary>
        /// Updates the VRPN tracker whenever it changes position
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"> Information about the object tracked</param>
        private void PositionChanged(object sender, TrackerChangeEventArgs e)
        {
            //We convert movement to millimeters.

            _position = new Microsoft.Xna.Framework.Vector3((float)e.Position.X, (float)e.Position.Y, (float)e.Position.Z);
            _xpos     = (float)e.Position.X;
            _ypos     = (float)e.Position.Y;
            _zpos     = (float)e.Position.Z;

            // tools inverts e.Orientation.Z for packetizing/sending, so invert it back
            _orientation = new Microsoft.Xna.Framework.Quaternion((float)e.Orientation.X, (float)e.Orientation.Y, (float)e.Orientation.Z, (float)e.Orientation.W);
            Vector3Helper.QuaternionToEuler(e.Orientation.X, e.Orientation.Y, e.Orientation.Z, e.Orientation.W,
                                            out _yaw, out _pitch, out _roll);
            _pitch *= -1;

            Matrix.CreateFromQuaternion(ref _orientation, out worldTransform);
            worldTransform.Translation = _position;
        }