Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 KB | None | 0 0
  1.   void GetPositionFromData()
  2.     {
  3.         if (currentData == null)
  4.         {
  5.             currentData = new PtzHeaderData(reader.GetAllData());
  6.         }
  7.  
  8.         var previousValue = dataBuffer[dataBufferSize - 1].RY;
  9.         var previousDelta = datalines[datalinesBufferSize - 1];
  10.  
  11.         Debug.Log("previousValue= " + previousValue);
  12.         Debug.Log("previousDelta= " + previousDelta);
  13.  
  14.         for (var i = 0; i < dataBufferSize - 1; i++)
  15.         {
  16.             dataBuffer[i] = dataBuffer[i + 1];
  17.         }
  18.         for (int i = 0; i < datalinesBufferSize - 1; i++)
  19.         {
  20.             datalines[i] = datalines[i + 1];
  21.         }
  22.  
  23.         var previousData = currentData;
  24.         currentData = new PtzHeaderData(reader.GetAllData());
  25.         dataBuffer[dataBufferSize - 1] = currentData;
  26.         Debug.Log("currentValue " + currentData.RY);
  27.         double delta = 0;
  28.         double lastDeltasDelta = 0;
  29.  
  30.  
  31.         if (previousDelta != Int32.MinValue)
  32.         {
  33.             delta = dataBuffer[dataBufferSize - 1].RY - previousValue;
  34.             Debug.Log("delta= " + delta);
  35.             lastDeltasDelta = Math.Abs(delta - previousDelta);
  36.             Debug.Log("lastDeltasDelta " + lastDeltasDelta);
  37.             if ( lastDeltasDelta >= 100)
  38.             {
  39.                 currentData.RY = previousData.RY + (float)previousDelta;
  40.             }
  41.         }
  42.         else
  43.         {
  44.             delta = 0;
  45.          
  46.         }
  47.         datalines[datalinesBufferSize - 1] = delta;
  48.  
  49.         var data = currentData;// dataBuffer[currentFrame];
  50.  
  51.        // Debug.Log("Zoom " + data.Zoom + " " + data.Focus + " " + data.Iris);
  52.         string res = "";
  53.         float rx = (float)(data.RX / 65535 * Math.PI * 2) * Mathf.Rad2Deg;
  54.         float ry = (float)(data.RY / 65535 * Math.PI * 2) * Mathf.Rad2Deg;
  55.         float rz = (float)(data.RZ / 65535 * Math.PI * 2) * Mathf.Rad2Deg;
  56.         CameraRotation = new Vector3(rx, ry, rz);
  57.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement