コード例 #1
0
        private async void SendCalibrationDataAsync()
        {
            using (MemoryStream memoryStream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(memoryStream))
                {
                    StorageFile file = (await KnownFolders.PicturesLibrary.TryGetItemAsync(@"CalibrationData.json").AsTask()) as StorageFile;
                    if (file != null)
                    {
                        byte[] contents = (await FileIO.ReadBufferAsync(file)).ToArray();
                        if (CalculatedCameraCalibration.TryDeserialize(contents, out CalculatedCameraCalibration calibration))
                        {
                            // Magic offset from Unity's underlying coordinate frame (WorldManager.GetNativeISpatialCoordinateSystemPtr()) and the head pose used for the camera.
                            // Poses are sent in the coordinate frame space because the Unity camera position uses prediction.
                            Matrix4x4 viewFromWorld = calibration.Extrinsics.ViewFromWorld;
                            Vector3   position      = viewFromWorld.GetColumn(3);
                            position += new Vector3(0f, 0.08f, 0.08f);
                            viewFromWorld.SetColumn(3, position);

                            calibration.Extrinsics.ViewFromWorld = viewFromWorld;
                            contents = calibration.Serialize();
                        }

                        message.Write("CalibrationData");
                        message.Write(contents.Length);
                        message.Write(contents);
                        networkManager.Broadcast(memoryStream.GetBuffer(), 0, memoryStream.Position);
                    }
                }
        }
コード例 #2
0
        private void SendDeviceInfo()
        {
            using (MemoryStream memoryStream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(memoryStream))
                {
                    message.Write(DeviceInfoObserver.DeviceInfoCommand);
                    message.Write(GetMachineName());
                    message.Write(GetIPAddress());

                    var data = memoryStream.ToArray();
                    networkManager.Broadcast(ref data);
                }
        }
コード例 #3
0
        private void SendDeviceInfo()
        {
            using (MemoryStream memoryStream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(memoryStream))
                {
                    message.Write(DeviceInfoObserver.DeviceInfoCommand);
                    message.Write(GetMachineName());
                    message.Write(GetIPAddress());
                    message.Flush();

                    networkManager.Broadcast(memoryStream.GetBuffer(), 0, memoryStream.Position);
                }
        }
コード例 #4
0
        private void SendCameraPose(float timestamp, Vector3 cameraPosition, Quaternion cameraRotation)
        {
            using (MemoryStream stream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(stream))
                {
                    message.Write(HolographicCameraObserver.CameraCommand);
                    message.Write(timestamp);
                    message.Write(cameraPosition);
                    message.Write(cameraRotation);
                    message.Flush();

                    networkManager.Broadcast(stream.GetBuffer(), 0, stream.Position);
                }
        }
コード例 #5
0
        private void SendDeviceInfo()
        {
            using (MemoryStream memoryStream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(memoryStream))
                {
                    message.Write(DeviceInfoObserver.DeviceInfoCommand);
                    message.Write(GetMachineName());
                    message.Write(GetIPAddress());
                    message.Flush();

                    memoryStream.TryGetBuffer(out var buffer);
                    networkManager.Broadcast(buffer.Array, buffer.Offset, buffer.Count);
                }
        }
コード例 #6
0
 private async void SendCalibrationDataAsync()
 {
     using (MemoryStream memoryStream = new MemoryStream())
         using (BinaryWriter message = new BinaryWriter(memoryStream))
         {
             StorageFile file = (await KnownFolders.PicturesLibrary.TryGetItemAsync(@"CalibrationData.json").AsTask()) as StorageFile;
             if (file != null)
             {
                 byte[] contents = (await FileIO.ReadBufferAsync(file)).ToArray();
                 message.Write("CalibrationData");
                 message.Write(contents.Length);
                 message.Write(contents);
                 networkManager.Broadcast(memoryStream.ToArray());
             }
         }
 }
        private void SendCalibrationData()
        {
            if (UnityCompositorInterface.IsCameraCalibrationInformationAvailable())
            {
                UnityCompositorInterface.GetCameraCalibrationInformation(out CompositorCameraIntrinsics compositorIntrinsics);
                CalculatedCameraCalibration calibration = new CalculatedCameraCalibration(compositorIntrinsics.AsCalculatedCameraIntrinsics(), new CalculatedCameraExtrinsics());
                byte[] serializedCalibration            = calibration.Serialize();

                using (MemoryStream memoryStream = new MemoryStream())
                    using (BinaryWriter message = new BinaryWriter(memoryStream))
                    {
                        message.Write("CalibrationData");
                        message.Write(serializedCalibration.Length);
                        message.Write(serializedCalibration);
                        memoryStream.TryGetBuffer(out var buffer);
                        networkManager.Broadcast(buffer.Array, buffer.Offset, buffer.Count);
                    }
            }
            else
            {
                Debug.LogError($"Expected that calibration data should be available when the {nameof(StationaryCameraCalibrationDataProvider)} component is enabled, but calibration data was not available");
            }
        }