Exemplo n.º 1
0
        /*
         * Desc: Used by the MoveServer to parse 'b' packets to the controller.
         * msg format: b msgNo controller tx ty tz ux uy trackingMove
         */
        public Boolean updatePositionData(String[] positionData)
        {
            int c = int.Parse(positionData[2]);

            if (c == controllerNumber)
            {
                if (!active)
                {
                    active = true;
                }
                // Used to set the controllers properties

                // Set our new values from the packet.
                Vector3 prevPosRaw = positionRaw;

                positionRaw.Set(float.Parse(positionData[3]) / 100f, float.Parse(positionData[4]) / 100f, float.Parse(positionData[5]) / 100f);
                //Debug.Log(positionRaw.ToString());
                positionNorm.Set(float.Parse(positionData[6]), float.Parse(positionData[7]), 0);

                currentlyTracked = positionData[8] == "0" ? false : true;

                // Process the new values.
                double newTime = System.DateTime.Now.Ticks * .0000001;
                if (currTime_b != -1)
                {
                    delta_t_b = newTime - currTime_b;
                }
                currTime_b = newTime;

                // Store the last smoothed position for velocity calc.
                Vector3 prevPosSmooth = positionSmoothed.getSmoothedVector();

                positionSmoothed.updateRaw(positionRaw);
                positionNormSmooothed.updateRaw(positionNorm);

                // Calculate velocity.
                velocityRaw.Set((float)((positionRaw.x - prevPosRaw.x) / delta_t_b), (float)((positionRaw.x - prevPosRaw.x) / delta_t_b), (float)((positionRaw.x - prevPosRaw.x) / delta_t_b));
                if (prevPosSmooth != null)
                {
                    Vector3 posSmooth = positionSmoothed.getSmoothedVector();
                    velocitySmoothed.Set((float)((posSmooth.x - prevPosSmooth.x) / delta_t_b), (float)((posSmooth.x - prevPosSmooth.x) / delta_t_b), (float)((posSmooth.x - prevPosSmooth.x) / delta_t_b));
                }
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
 public Vector3 getPositionNormSmooth()
 {
     return(positionNormSmooothed.getSmoothedVector());
 }
Exemplo n.º 3
0
 public Vector3 getMagnetometerSmooth()
 {
     return(magnetometerSmoothed.getSmoothedVector());;
 }
Exemplo n.º 4
0
 public Vector3 getAccelerometerSmooth()
 {
     return(accelerometerSmoothed.getSmoothedVector());
 }
Exemplo n.º 5
0
 public Vector3 getGyroscopeSmooth()
 {
     return(gyroscopeSmoothed.getSmoothedVector());
 }