static void Main(string[] args) { ClientContext.PreloadNativeLibraries(); using (ServerAutoStarter serverAutoStarter = new ServerAutoStarter()) using (OSVR.ClientKit.ClientContext context = new OSVR.ClientKit.ClientContext("com.osvr.exampleclients.managed.Imaging")) { // there are three types of interfaces for eye tracking, 2D, 3D, and blinking #if NET20 using (var imaging = ImagingInterface.GetInterface(context, "/camera")) #else using (var imaging = context.GetImagingInterface("/camera")) #endif { imaging.StateChanged += imaging_StateChanged; // Pretend that this is your application's main loop for (int i = 0; i < 10000000; ++i) { context.update(); } Console.WriteLine("Library shut down; exiting."); } } }
//////////////////////////////////////////////////////////////////////////////////////////////// /*--------------------------------------------------------------------------------------------*/ public void Start() { vInterface = ImagingInterface.GetInterface(ContextProvider.Context, "/camera/" + (IsLeft ? "left" : "right")); vInterface.StateChanged += HandleChanged; vTex = new Texture2D(ImageWidth, ImageHeight); var mat = new Material(Shader.Find("Diffuse")); mat.mainTexture = vTex; vGameObj = GameObject.CreatePrimitive(PrimitiveType.Quad); vGameObj.transform.SetParent(gameObject.transform, false); vGameObj.transform.localRotation = Quaternion.FromToRotation(Vector3.down, Vector3.forward); vGameObj.transform.localScale = new Vector3(1, (float)ImageHeight / ImageWidth, 1) * 0.06f; vGameObj.GetComponent <MeshRenderer>().material = mat; }