Example #1
0
    /// <summary>
    ///     Converts the given direction vector from world space to device space.
    /// </summary>
    /// <param name="vector">The direction vector in world space.</param>
    /// <returns>The equivalent direction vector in device space.</returns>
    public Vector3 WorldToDeviceDirection(UnityEngine.Vector3 vector)
    {
        // Transform the world direction to the local space of the array
        var localDirection = _arrayOrigin.InverseTransformDirection(vector);
        // Construct an Ultrahaptics Vector3
        // Note that the y and z coordinates are swapped as Ultrahaptics uses a coordinate system where the positive Y-axis is up
        var ultrahapticsDirection = new Vector3(localDirection.x, localDirection.z, localDirection.y);

        return(ultrahapticsDirection);
    }
Example #2
0
    // Update on every frame
    public void Update()
    {
        // The Leap Motion can see a hand, so get its palm position
        // Convert to our vector class, and then convert to our coordinate space

        //Vive Tracker Position
        Ultrahaptics.Vector3 uhPalmPosition = new Ultrahaptics.Vector3(ViveHand.transform.position.x, ViveHand.transform.position.y, ViveHand.transform.position.z);

        // Leap Motion hand position


        // From here, we can establish how many timepoints there are in a single "iteration" of the cosine wave
        for (int i = 0; i < _timepoint_count; i++)
        {
            float intensity = VM.intensity * (1.0f - (float)Math.Cos(2.0f * Math.PI * i / _timepoint_count));
            // Set a constant position of 20cm above the array
            _positions[i]   = new Ultrahaptics.Vector3(0.0f, 0.0f, 0.3f);
            _intensities[i] = (intensity);
        }

        _emitter.setEmissionCallback(callback, null);
    }