Advertisement
Guest User

Untitled

a guest
Sep 16th, 2014
934
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.65 KB | None | 0 0
  1.         private void Form1_Load(object sender, EventArgs e)
  2.         {
  3.             MediaAttributes attributes = new MediaAttributes(1);
  4.             attributes.Set<Guid>(CaptureDeviceAttributeKeys.SourceType, CaptureDeviceAttributeKeys.SourceTypeVideoCapture.Guid);
  5.             Activate[] activates = MediaFactory.EnumDeviceSources(attributes);
  6.             foreach (var activate in activates)
  7.             {
  8.                 string uid = activate.Get(CaptureDeviceAttributeKeys.SourceTypeVidcapSymbolicLink);
  9.                 cameraList.Add(uid, activate);
  10.                 ComboboxCameraItem item = new ComboboxCameraItem(activate);
  11.                 leftCameraCombo.Items.Add(item);
  12.                 rightCameraCombo.Items.Add(item);
  13.  
  14.                 if (Properties.Settings.Default.leftCamera == uid)
  15.                 {
  16.                     leftCameraCombo.SelectedItem = item;
  17.                 }
  18.                 if (Properties.Settings.Default.rightCamera == uid)
  19.                 {
  20.                     rightCameraCombo.SelectedItem = item;
  21.                 }
  22.                
  23.             }
  24.            
  25.           // graphicsDeviceManager = new GraphicsDeviceManager(this);
  26.             OVR.Initialize();
  27.  
  28.  
  29.  
  30.             label1.Text = "Init OK";
  31.             hmd = OVR.HmdCreate(0) ?? OVR.HmdCreateDebug(HMDType.DK2);
  32.             if (hmd != null)
  33.             {
  34.                 hmd.ConfigureTracking(
  35.                     TrackingCapabilities.Orientation | TrackingCapabilities.Position |
  36.                     TrackingCapabilities.MagYawCorrection, TrackingCapabilities.None);
  37.             }
  38.             else
  39.             {
  40.                 label1.Text = "No Oculus connected";
  41.             }
  42.         }
  43.         private void button3_Click(object sender, EventArgs e)
  44.         {
  45.             Activate camera =
  46.                 cameraList[
  47.                     ((ComboboxCameraItem) leftCameraCombo.SelectedItem).Value.Get(
  48.                         CaptureDeviceAttributeKeys.SourceTypeVidcapSymbolicLink)];
  49.  
  50.             IntPtr leftIntPtr;
  51.             //"279a808d-aec7-40c8-9c6b-a6b492c78a66" is MediaSource class GUID
  52.             camera.ActivateObject(System.Guid.Parse("279a808d-aec7-40c8-9c6b-a6b492c78a66"), out leftIntPtr);
  53.             MediaSource source = new MediaSource(leftIntPtr);
  54.             PresentationDescriptor descriptor;
  55.             source.CreatePresentationDescriptor(out descriptor);
  56.             Variant time = new Variant();
  57.             time.ElementType = VariantElementType.UInt; //Is this VT_I8 ??
  58.             time.Value = 0; //Value = 0
  59.             source.BeginGetEvent(leftEyeBeginCallback, this);
  60.             source.Start(descriptor, null, time);
  61.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement