예제 #1
0
        public static void Main(string[] args)
        {
            OSVR.ClientKit.ClientContext context = new OSVR.ClientKit.ClientContext("org.opengoggles.exampleclients.managed.TrackerCallback");

            // This is just one of the paths. You can also use:
            // /me/hands/right
            // /me/head
            Interface lefthand = context.getInterface("/me/hands/left");

            TrackerCallbacks callbacks = new TrackerCallbacks();

            // The coordinate system is right-handed, withX to the right, Y up, and Z near.
            OSVR.ClientKit.PoseCallback poseCb = new PoseCallback(TrackerCallbacks.myTrackerCallback);
            lefthand.registerCallback(poseCb, IntPtr.Zero);

            // If you just want orientation
            OSVR.ClientKit.OrientationCallback oriCb = new OrientationCallback(TrackerCallbacks.myOrientationCallback);
            lefthand.registerCallback(oriCb, IntPtr.Zero);

            // or position
            OSVR.ClientKit.PositionCallback posCb = new PositionCallback(TrackerCallbacks.myPositionCallback);
            lefthand.registerCallback(posCb, IntPtr.Zero);

            // Pretend that this is your application's main loop
            for (int i = 0; i < 1000000; ++i)
            {
                context.update();
            }

            Console.WriteLine("Library shut down; exiting.");
        }
예제 #2
0
        public static void Main(string[] args)
        {
            ClientContext.PreloadNativeLibraries();
            using (ClientContext context = new ClientContext("com.osvr.exampleclients.managed.TrackerCallback"))
            {
                // This is just one of the paths. You can also use:
                // /me/hands/right
                // /me/head
                using (Interface lefthand = context.getInterface("/me/hands/left"))
                {

                    TrackerCallbacks callbacks = new TrackerCallbacks();
                    // The coordinate system is right-handed, withX to the right, Y up, and Z near.
                    var poseInterface = new PoseInterface(lefthand);
                    poseInterface.StateChanged += TrackerCallbacks.myTrackerCallback;

                    // If you just want orientation
                    var orientationInterface = new OrientationInterface(lefthand);
                    orientationInterface.StateChanged += TrackerCallbacks.myOrientationCallback;

                    // or position
                    var positionInterface = new PositionInterface(lefthand);
                    positionInterface.StateChanged += TrackerCallbacks.myPositionCallback;

                    // Pretend that this is your application's main loop
                    for (int i = 0; i < 1000000; ++i)
                    {
                        context.update();
                    }

                    Console.WriteLine("Library shut down; exiting.");
                }
            }
        }
        public static void Main(string[] args)
        {
            ClientContext.PreloadNativeLibraries();
			using (ClientContext context = new ClientContext("com.osvr.exampleclients.managed.TrackerCallback"))
            {
                // This is just one of the paths. You can also use:
                // /me/hands/right
                // /me/head
                using (Interface lefthand = context.getInterface("/me/hands/left"))
                {

                    TrackerCallbacks callbacks = new TrackerCallbacks();
                    // The coordinate system is right-handed, withX to the right, Y up, and Z near.
                    var poseInterface = new PoseInterface(lefthand);
                    poseInterface.StateChanged += TrackerCallbacks.myTrackerCallback;

                    // If you just want orientation
                    var orientationInterface = new OrientationInterface(lefthand);
                    orientationInterface.StateChanged += TrackerCallbacks.myOrientationCallback;

                    // or position
                    var positionInterface = new PositionInterface(lefthand);
                    positionInterface.StateChanged += TrackerCallbacks.myPositionCallback;

                    bool resetYawMode = false;
                    // Pretend that this is your application's main loop
                    for (int i = 0; i < 1000000; ++i)
                    {
                        // toggle between reset yaw mode and normal mode
                        // every 5000 iterations.
                        if (i % 5000 == 0)
                        {
                            resetYawMode = !resetYawMode;
                            if(resetYawMode)
                            {
                                context.SetRoomRotationUsingHead();
                            }
                            else
                            {
                                context.ClearRoomToWorldTransform();
                            }
                        }
                        context.update();
                    }

                    Console.WriteLine("Library shut down; exiting.");
                }
            }
        }
예제 #4
0
        public static void Main(string[] args)
        {
            ClientContext.PreloadNativeLibraries();
            using (ServerAutoStarter serverAutoStarter = new ServerAutoStarter())
                using (ClientContext context = new ClientContext("com.osvr.exampleclients.managed.TrackerCallback"))
                {
                    // This is just one of the paths. You can also use:
                    // /me/hands/right
                    // /me/head
                    using (Interface lefthand = context.getInterface("/me/hands/left"))
                    {
                        TrackerCallbacks callbacks = new TrackerCallbacks();
                        // The coordinate system is right-handed, withX to the right, Y up, and Z near.
                        var poseInterface = new PoseInterface(lefthand);
                        poseInterface.StateChanged += TrackerCallbacks.myTrackerCallback;

                        // If you just want orientation
                        var orientationInterface = new OrientationInterface(lefthand);
                        orientationInterface.StateChanged += TrackerCallbacks.myOrientationCallback;

                        // or position
                        var positionInterface = new PositionInterface(lefthand);
                        positionInterface.StateChanged += TrackerCallbacks.myPositionCallback;

                        bool resetYawMode = false;
                        // Pretend that this is your application's main loop
                        for (int i = 0; i < 1000000; ++i)
                        {
                            // toggle between reset yaw mode and normal mode
                            // every 5000 iterations.
                            if (i % 5000 == 0)
                            {
                                resetYawMode = !resetYawMode;
                                if (resetYawMode)
                                {
                                    context.SetRoomRotationUsingHead();
                                }
                                else
                                {
                                    context.ClearRoomToWorldTransform();
                                }
                            }
                            context.update();
                        }

                        Console.WriteLine("Library shut down; exiting.");
                    }
                }
        }