Exemplo n.º 1
0
        /// <summary>
        /// this function is to update the live rendering points which comes from ultraleap live rendering feature
        /// </summary>
        /// <param name="updated_x"> the new x coordinate</param>
        /// <param name="updated_y"> the new y coordinate</param>
        public static void updateLiveRenderPoint(float updated_x, float updated_y)
        {
            if (emitter != null)
            {
                Vector3 position = new Vector3((float)(updated_x * Ultrahaptics.Units.metres), (float)(updated_y * Ultrahaptics.Units.metres), (float)(0.20 * Ultrahaptics.Units.metres));
                AmplitudeModulationControlPoint point = new AmplitudeModulationControlPoint(position, intensity, frequency);
                var points = new List <AmplitudeModulationControlPoint> {
                    point
                };
                emitter.update(points);
                Console.WriteLine(updated_x + " " + updated_y);
            }
            if (Stop)
            {
                try {
                    emitter.update(new List <AmplitudeModulationControlPoint> {
                    });
                    emitter.Dispose();
                    emitter = null;
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }

                Stop = false;
                return;
            }
        }
Exemplo n.º 2
0
 // Ensure the emitter is immediately disposed when destroyed
 void OnDestroy()
 {
     _emitter.Dispose();
     _emitter = null;
     _alignment.Dispose();
     _alignment = null;
 }
    public static void Main(string[] args)
    {
        // Create an emitter, which connects to the first connected device
        AmplitudeModulationEmitter emitter = new AmplitudeModulationEmitter();

        // Set the position of the new control point
        Vector3 position = new Vector3(0.0f, 0.0f, 0.2f);
        // Set how intense the feeling at the new control point will be
        float intensity = 1.0f;
        // Set the frequency of the control point, which can change the feeling of the sensation
        float frequency = 200.0f;

        // Define the control point
        AmplitudeModulationControlPoint point = new AmplitudeModulationControlPoint(position, intensity, frequency);
        var points = new List <AmplitudeModulationControlPoint> {
            point
        };
        // Instruct the device to stop any existing actions and start producing this control point
        bool isOK = emitter.update(points);

        // The emitter will continue producing this point until instructed to stop

        // Wait until the program is ready to stop
        Console.ReadKey();

        // Stop the emitter
        emitter.stop();

        // Dispose/destroy the emitter
        emitter.Dispose();
        emitter = null;
    }
Exemplo n.º 4
0
        public static void Render()
        {
            Stop = false;
            string file_name = Path.Combine(Environment.CurrentDirectory, "list.csv");

            emitter = new AmplitudeModulationEmitter();


            for (; ;)
            {
                using (TextFieldParser parser = new TextFieldParser(file_name))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    while (!parser.EndOfData)
                    {
                        double x = 1000, y = 1000;
                        //Processing row
                        string[] fields = parser.ReadFields();
                        foreach (string field in fields)
                        {
                            //TODO: Process field
                            if (x == 1000)
                            {
                                x = double.Parse(field);
                            }
                            else if (y == 1000)
                            {
                                y = double.Parse(field);
                            }
                        }
                        Vector3 position = new Vector3((float)(x * Ultrahaptics.Units.metres), (float)(y * Ultrahaptics.Units.metres), (float)(0.20 * Ultrahaptics.Units.metres));
                        AmplitudeModulationControlPoint point = new AmplitudeModulationControlPoint(position, intensity, frequency);
                        var points = new List <AmplitudeModulationControlPoint> {
                            point
                        };
                        emitter.update(points);

                        //this condition will stop emitter from processing further
                        if (Stop)
                        {
                            emitter.update(new List <AmplitudeModulationControlPoint> {
                            });

                            emitter.Dispose();
                            emitter = null;
                            Stop    = false;
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
    public static void Main(string[] args)
    {
        // Width of the kit, refer to the User Guide of your device
        float width = 0.210f;  // meters
        // affine transformation matrix placing the device half its width to the left in the global space
        Transform left_tr = new Transform();

        left_tr.setOrigin(new Vector3(-width / 2, 0.0f, 0.0f));
        // affine transformation matrix placing the device half its width to the right in the global space
        Transform right_tr = new Transform();

        right_tr.setOrigin(new Vector3(width / 2, 0.0f, 0.0f));

        // Create an emitter, which connects to the first connected device
        // Please make sure to use the correct identifiers for your devices
        AmplitudeModulationEmitter emitter = new AmplitudeModulationEmitter("USX:USX-00000000", left_tr);

        emitter.addDevice("USX:USX-00000001", right_tr);

        // Set the position of the new control point
        Vector3 position1 = new Vector3(-0.05f, 0.0f, 0.2f);
        Vector3 position2 = new Vector3(0.05f, 0.0f, 0.2f);
        // Set how intense the feeling at the new control point will be
        float intensity = 1.0f;
        // Set the frequency of the control point, which can change the feeling of the sensation
        float frequency = 200.0f;

        // Define the control point
        AmplitudeModulationControlPoint point1 = new AmplitudeModulationControlPoint(position1, intensity, frequency);
        AmplitudeModulationControlPoint point2 = new AmplitudeModulationControlPoint(position2, intensity, frequency);
        var points = new List <AmplitudeModulationControlPoint> {
            point1, point2
        };
        // Instruct the device to stop any existing actions and start producing this control point
        bool isOK = emitter.update(points);

        // The emitter will continue producing this point until instructed to stop

        // Wait until the program is ready to stop
        Console.ReadKey();

        // Stop the emitter
        emitter.stop();

        // Dispose/destroy the emitter
        emitter.Dispose();
        emitter = null;
    }
Exemplo n.º 6
0
    public static void Main(string[] args)
    {
        // Create an emitter, which connects to the first connected device
        AmplitudeModulationEmitter emitter = new AmplitudeModulationEmitter();

        // Create an aligment object which relates the tracking and device spaces
        Alignment alignment = emitter.getDeviceInfo().getDefaultAlignment();

        // Create a Leap Contoller
        Controller controller = new Controller();

        ButtonWidget button = new ButtonWidget();

        // Set the position of the new control point
        Vector3 position = new Vector3(0.0f, 0.0f, 0.2f);
        // Set how intense the feeling at the new control point will be
        float intensity = 1.0f;
        // Set the frequency of the control point, which can change the feeling of the sensation
        float frequency = 200.0f;

        // Define the control point
        AmplitudeModulationControlPoint point = new AmplitudeModulationControlPoint(position, intensity, frequency);
        var points = new List <AmplitudeModulationControlPoint> {
            point
        };

        // Wait for leap
        if (!controller.IsConnected)
        {
            Console.WriteLine("Waiting for Leap");
            while (!controller.IsConnected)
            {
                System.Threading.Thread.Sleep(1000);
                Console.WriteLine(".");
            }
            Console.WriteLine("\n");
        }

        controller.EnableGesture(Gesture.GestureType.TYPE_KEY_TAP);

        if (controller.Config.SetFloat("Gesture.Swipe.MinDistance", 30) &&
            controller.Config.SetFloat("Gesture.Swipe.MinDownVelocity", 30) &&
            controller.Config.SetFloat("Gesture.Swipe.MinSeconds", 0.01f))
        {
            controller.Config.Save();
        }

        bool button_on = true;

        new Stopwatch();

        for (;;)
        {
            Frame    frame = controller.Frame();
            HandList hands = frame.Hands;

            if (!hands.IsEmpty && button_on)
            {
                Hand hand = hands[0];

                for (int i = 0; i < frame.Gestures().Count; i++)
                {
                    Gesture gesture = frame.Gestures()[i];

                    if (gesture.Type == Gesture.GestureType.TYPE_KEY_TAP)
                    {
                        button_on = false;

                        emitter.stop();
                        break;
                    }
                }
                position = new Vector3(hand.PalmPosition.x, hand.PalmPosition.y, hand.PalmPosition.z);
                Vector3 normal    = new Vector3(-hand.PalmNormal.x, -hand.PalmNormal.y, -hand.PalmNormal.z);
                Vector3 direction = new Vector3(hand.Direction.x, hand.Direction.y, hand.Direction.z);

                Vector3 device_position  = alignment.fromTrackingPositionToDevicePosition(position);
                Vector3 device_normal    = alignment.fromTrackingDirectionToDeviceDirection(normal).normalize();
                Vector3 device_direction = alignment.fromTrackingDirectionToDeviceDirection(direction).normalize();
                Vector3 device_palm_x    = device_direction.cross(device_normal).normalize();

                device_position += (device_direction * MathF.Cos(button.angle) + device_palm_x * MathF.Sin(button.angle)) * button.radius;

                points[0].setPosition(device_position);
                // Instruct the device to stop any existing actions and start producing this control point
                emitter.update(points);
                // The emitter will continue producing this point until instructed to stop

                button.angle += 0.05f;
                button.angle  = button.angle % (2.0f * PI);
            }
            else if (!hands.IsEmpty && !button_on)
            {
                emitter.stop();

                for (int i = 0; i < frame.Gestures().Count; i++)
                {
                    Gesture gesture = frame.Gestures()[i];

                    if (gesture.Type == Gesture.GestureType.TYPE_KEY_TAP)
                    {
                        button_on = true;

                        emitter.stop();
                        break;
                    }
                }
            }
            else
            {
                emitter.stop();
            }
            System.Threading.Thread.Sleep(10);
        }

        // Dispose/destroy the emitter
        emitter.Dispose();
        emitter = null;

        controller.Dispose();
    }
 private void OnDisable()
 {
     // Stop the emitter when this GameObject is destroyed
     _amEmitter.stop();
     _amEmitter.Dispose();
 }
Exemplo n.º 8
0
 // Ensure the emitter is immediately disposed when destroyed
 void OnDestroy()
 {
     _emitter.Dispose();
     _emitter = null;
 }