Example #1
0
        public static void Update()
        {
            if (!SenselMaster.Update())
            {
                return;
            }

            var inputs = SenselMaster.Contacts;

            // Pick the new contacts up.
            _newContactCount = 0;
            for (var i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].state == (int)SenselContactState.CONTACT_START)
                {
                    _contactArray[_newContactCount++] = ConvertContact(ref inputs, i);
                }
            }

            // Collect the rest of the contacts.
            _contactCount = _newContactCount;
            for (var i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].state != (int)SenselContactState.CONTACT_START)
                {
                    _contactArray[_contactCount++] = ConvertContact(ref inputs, i);
                }
            }
        }
Example #2
0
        public void Update()
        {
            SenselMaster.Update();

            float sum     = 0f;
            float average = 0f;

            // Transfer the force array to the raw input texture.
            unsafe {
                var input = SenselMaster.ForceArray;
                if (input.IsCreated)
                {
                    _rawInput.LoadRawTextureData(
                        (System.IntPtr)input.GetUnsafePtr(),
                        sizeof(float) * input.Length
                        );
                    _rawInput.Apply();

                    for (int i = 0; i < input.Length; i++)
                    {
                        sum += input[i];
                    }
                    average = sum / input.Length;
                }
            }

            _forceSum     = sum;
            _forceAverage = average;

            _filter.SetFloat(_idSensitivity, sensitivity);
            _filter.SetFloat(_idPower, power);

            // Apply the prefilter (vertical flip).
            Graphics.Blit(_rawInput, _filteredInput, _filter, 0);

            // Apply the gaussian blur filter.
            ApplyBlurFilter(_filteredInput);
        }
Example #3
0
        public void Update()
        {
            SenselMaster.Update();

            // Transfer the force array to the raw input texture.
            unsafe {
                var input = SenselMaster.ForceArray;
                if (input.IsCreated)
                {
                    _rawInput.LoadRawTextureData(
                        (System.IntPtr)input.GetUnsafePtr(),
                        sizeof(float) * input.Length
                        );
                    _rawInput.Apply();
                }
            }

            // Apply the prefilter (vertical flip).
            Graphics.Blit(_rawInput, _filteredInput, _filter, 0);

            // Apply the gaussian blur filter.
            ApplyBlurFilter(_filteredInput);
        }
Example #4
0
        static void Update()
        {
            SenselMaster.Update();

            // Check if it has been already called in the current frame.
            var now = UnityEngine.Time.frameCount;

            if (now == _lastUpdate)
            {
                return;
            }

            var inputs = SenselMaster.Contacts;

            // Pick the new contacts up.
            _newContactCount = 0;
            for (var i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].state == (int)SenselContactState.CONTACT_START)
                {
                    _contactArray[_newContactCount++] = ConvertContact(ref inputs, i);
                }
            }

            // Collect the rest of the contacts.
            _contactCount = _newContactCount;
            for (var i = 0; i < inputs.Length; i++)
            {
                if (inputs[i].state != (int)SenselContactState.CONTACT_START)
                {
                    _contactArray[_contactCount++] = ConvertContact(ref inputs, i);
                }
            }

            _lastUpdate = now;
        }