Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void GetPositionFromData()
- {
- if (currentData == null)
- {
- currentData = new PtzHeaderData(reader.GetAllData());
- }
- var previousValue = dataBuffer[dataBufferSize - 1].RY;
- var previousDelta = datalines[datalinesBufferSize - 1];
- Debug.Log("previousValue= " + previousValue);
- Debug.Log("previousDelta= " + previousDelta);
- for (var i = 0; i < dataBufferSize - 1; i++)
- {
- dataBuffer[i] = dataBuffer[i + 1];
- }
- for (int i = 0; i < datalinesBufferSize - 1; i++)
- {
- datalines[i] = datalines[i + 1];
- }
- var previousData = currentData;
- currentData = new PtzHeaderData(reader.GetAllData());
- dataBuffer[dataBufferSize - 1] = currentData;
- Debug.Log("currentValue " + currentData.RY);
- double delta = 0;
- double lastDeltasDelta = 0;
- if (previousDelta != Int32.MinValue)
- {
- delta = dataBuffer[dataBufferSize - 1].RY - previousValue;
- Debug.Log("delta= " + delta);
- lastDeltasDelta = Math.Abs(delta - previousDelta);
- Debug.Log("lastDeltasDelta " + lastDeltasDelta);
- if ( lastDeltasDelta >= 100)
- {
- currentData.RY = previousData.RY + (float)previousDelta;
- }
- }
- else
- {
- delta = 0;
- }
- datalines[datalinesBufferSize - 1] = delta;
- var data = currentData;// dataBuffer[currentFrame];
- // Debug.Log("Zoom " + data.Zoom + " " + data.Focus + " " + data.Iris);
- string res = "";
- float rx = (float)(data.RX / 65535 * Math.PI * 2) * Mathf.Rad2Deg;
- float ry = (float)(data.RY / 65535 * Math.PI * 2) * Mathf.Rad2Deg;
- float rz = (float)(data.RZ / 65535 * Math.PI * 2) * Mathf.Rad2Deg;
- CameraRotation = new Vector3(rx, ry, rz);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement