Ejemplo n.º 1
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT               eff                   = (SET_EFFECT)structDictonary["SET_EFFECT"];
            PERIOD                   periodic              = (PERIOD)structDictonary["PERIOD"];
            CUSTOM_FORCE_PARAMETER   customForceParameter  = (CUSTOM_FORCE_PARAMETER)structDictonary["CUSTOM_FORCE_PARAMETER"];
            CUSTOM_FORCE_DATA_REPORT customForceDataReport = (CUSTOM_FORCE_DATA_REPORT)structDictonary["CUSTOM_FORCE_DATA_REPORT"];

            List <double> forces      = new List <double>();
            List <int>    samples     = customForceDataReport.samples;
            double        sampleCount = customForceParameter.sampleCount;
            double        period      = periodic.period;
            List <double> directions  = _calculationProvider.GetDirection(eff);

            int sampleIndex = (int)Math.Round((elapsedTime / period) * sampleCount);

            if (sampleIndex > samples.Count)
            {
                sampleIndex %= samples.Count;
            }

            foreach (var direction in directions)
            {
                forces.Add(samples[sampleIndex] * direction);
            }
            return(forces);
        }
Ejemplo n.º 2
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT eff      = (SET_EFFECT)structDictonary["SET_EFFECT"];
            PERIOD     periodic = (PERIOD)structDictonary["PERIOD"];
            ENVELOPE   env      = (ENVELOPE)structDictonary["ENVELOPE"];

            List <double> forces    = new List <double>();
            double        offset    = periodic.offset;
            double        magnitude = periodic.magnitude;
            double        phase     = periodic.phase;
            double        period    = periodic.period;

            magnitude = _calculationProvider.ApplyGain(magnitude, eff.gain);

            double angle     = ((elapsedTime / period) + (phase / _reportDescriptorProperties.MAX_PHASE) * period) * 2 * Math.PI;
            double sine      = Math.Sin(angle);
            double tempforce = sine * magnitude;

            tempforce += offset;

            double envelope = _calculationProvider.ApplyGain(_calculationProvider.GetEnvelope(env, elapsedTime, eff.duration), eff.gain);

            List <double> directions = _calculationProvider.GetDirection(eff);

            foreach (var direction in directions)
            {
                forces.Add(tempforce * envelope * direction);
            }
            return(forces);
        }
Ejemplo n.º 3
0
        public List <double> GetForce(JOYSTICK_INPUT joystickInput, Dictionary <string, object> structDictonary, double elapsedTime)
        {
            SET_EFFECT eff      = (SET_EFFECT)structDictonary["SET_EFFECT"];
            PERIOD     periodic = (PERIOD)structDictonary["PERIOD"];
            ENVELOPE   env      = (ENVELOPE)structDictonary["ENVELOPE"];

            List <double> forces    = new List <double>();
            double        offset    = periodic.offset;
            double        magnitude = periodic.magnitude;
            double        phase     = periodic.phase;
            double        period    = periodic.period;

            magnitude = _calculationProvider.ApplyGain(magnitude, eff.gain);

            double max       = offset + magnitude;
            double min       = offset - magnitude;
            double phasetime = (phase * period) / _reportDescriptorProperties.MAX_PHASE;
            double time      = elapsedTime + phasetime;
            double reminder  = time % period;
            double slope     = (max - min) / period;
            double tempforce = 0;

            tempforce  = slope * reminder;
            tempforce += min;

            double envelope = _calculationProvider.ApplyGain(_calculationProvider.GetEnvelope(env, elapsedTime, eff.duration), eff.gain);

            List <double> directions = _calculationProvider.GetDirection(eff);

            foreach (var direction in directions)
            {
                forces.Add(tempforce * envelope * direction);
            }
            return(forces);
        }