コード例 #1
0
        public void TestContracts()
        {
            ISensorFusion fusion = Factory.CreateSensorFusion();

            fusion.Dispose();
            fusion.IsDisposed.Should().BeTrue();
            fusion.Dispose();             //< Must be allowed

            //
            // Get
            //
            new Action(() => { var unused = fusion.IsAttachedToSensor; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.IsGravityEnabled; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.IsPredictionEnabled; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.Orientation; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.PredictedOrientation; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.PredictionTime; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.YawMultiplier; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.AccelGain; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.Acceleration; }).ShouldThrow <ObjectDisposedException>();
            new Action(() => { var unused = fusion.AngularVelocity; }).ShouldThrow <ObjectDisposedException>();

            //
            // Set
            //

            new Action(() => fusion.AccelGain           = 1.5f).ShouldThrow <ObjectDisposedException>();
            new Action(() => fusion.YawMultiplier       = 1.5f).ShouldThrow <ObjectDisposedException>();
            new Action(() => fusion.IsPredictionEnabled = true).ShouldThrow <ObjectDisposedException>();
            new Action(() => fusion.PredictionTime      = TimeSpan.FromDays(1)).ShouldThrow <ObjectDisposedException>();

            new Action(fusion.Reset).ShouldThrow <ObjectDisposedException>();
        }
コード例 #2
0
        public DeviceResources(IFactory factory, IDeviceHandle <IHMDDevice, IHMDInfo> handle)
        {
            if (factory == null || handle == null)
            {
                throw new ArgumentNullException();
            }

            Info   = handle.DeviceInfo;
            Device = handle.CreateDevice();
            Sensor = Device.Sensor;
            Fusion = factory.CreateSensorFusion(Sensor);

            if (Info == null)
            {
                throw new ArgumentNullException();
            }
            if (Device == null)
            {
                throw new ArgumentNullException();
            }
            if (Sensor == null)
            {
                throw new ArgumentNullException();
            }

            Key = new DeviceKey(Sensor.Info);
        }
コード例 #3
0
ファイル: DeviceResources.cs プロジェクト: staubhp/RiftDotNet
		public DeviceResources(IFactory factory, IDeviceHandle<IHMDDevice, IHMDInfo> handle)
		{
			if (factory == null || handle == null)
				throw new ArgumentNullException();

			Info = handle.DeviceInfo;
			Device = handle.CreateDevice();
			Sensor = Device.Sensor;
			Fusion = factory.CreateSensorFusion(Sensor);

			if (Info == null)
				throw new ArgumentNullException();
			if (Device == null)
				throw new ArgumentNullException();
			if (Sensor == null)
				throw new ArgumentNullException();

			Key = new DeviceKey(Sensor.Info);
		}
コード例 #4
0
        public DeviceResources(IFactory factory, IDeviceHandle<IHMDDevice, IHMDInfo> handle)
        {
            if (factory == null || handle == null)
                throw new ArgumentNullException();

            Info = handle.DeviceInfo;
            Device = handle.CreateDevice();
            Sensor = Device.Sensor;
            Fusion = factory.CreateSensorFusion(Sensor);

            if (Info == null)
                throw new ArgumentNullException();
            if (Device == null)
                throw new ArgumentNullException();
            if (Sensor == null)
                System.Diagnostics.Trace.TraceWarning("Unable to create Sensor");

            if (Sensor != null)
                Key = new DeviceKey(Sensor.Info);
        }
コード例 #5
0
        private OculusOrientation()
        {
            manager = Factory.CreateDeviceManager();
            fusion = Factory.CreateSensorFusion();
            var devices = manager.HMDDevices;
            if (devices.Length <= 0)
            {
                throw new Exception("No Oculus Hardware found");
            }
            var handle = devices[0];
            Console.WriteLine("Found an HMD device: " + handle.DeviceInfo.DisplayDevice);

            device = handle.CreateDevice();

            fusion.AttachedDevice = device.Sensor;

            fusion.IsPredictionEnabled = true;

            updateThread = new Thread(new ThreadStart(updateOrientation));
            updateThread.Start();
        }