Пример #1
0
        /// <summary>
        ///     Makes all necessary calculations to figure out where the current point at this step of the animation is.
        /// </summary>
        /// <param name="gameTime"></param>
        /// <returns></returns>
        public bool Tick(GameTime gameTime)
        {
            if (actor != null && (actor.StatusType & StatusType.Update) == StatusType.Update)
            {
                bool done = Looper.Loop(loopMethod, ref currentTime, ref step, maxTime);

                float timePercent     = (float)currentTime / maxTime;
                float smoothedPercent = Smoother.SmoothValue(smoothing, timePercent);

                Vector3 currentPoint = Vector3.Lerp(isRelative ? Vector3.Zero : start, destination, smoothedPercent);

                FinalOperation finalOperation = PerformOperation(currentPoint, lastPoint);

                process(finalOperation);

                lastPoint = currentPoint;

                currentTime += gameTime.ElapsedGameTime.Milliseconds * step;

                if (done)
                {
                    if (resetAfterDone)
                    {
                        process(target => start);
                    }
                    callback?.Invoke();
                }

                return(done);
            }

            return(false);
        }
 public void SmoothChromatograms(Dictionary <MSPeak, XYData> chromatograms, Smoother smoother)
 {
     foreach (var peak in chromatograms.Keys.ToList())
     {
         chromatograms[peak] = smoother.Smooth(chromatograms[peak]);
     }
 }
Пример #3
0
        public FeatureSet(List <IntensityPoint> intensityPointList)
        {
            var pointList = WaterShedMapUtil.BuildWatershedMap(intensityPointList);

            Smoother.Smooth(ref pointList);
            FindFeatures(pointList);
        }
Пример #4
0
        private static void DrawToBitmap(IRaster raster, IRasterSymbolizer rasterSymbolizer, IntPtr rgbData, int stride, ProgressMeter pm)
        {
            if (raster.DataType == typeof(int))
            {
                DrawToBitmapT(raster.ToRaster <int>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(float))
            {
                DrawToBitmapT(raster.ToRaster <float>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(short))
            {
                DrawToBitmapT(raster.ToRaster <short>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(byte))
            {
                DrawToBitmapT(raster.ToRaster <byte>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(double))
            {
                DrawToBitmapT(raster.ToRaster <double>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else
            {
                DrawToBitmapT(raster, raster.NoDataValue, (row, col) => raster.Value[row, col], i => Marshal.ReadByte(rgbData, i), (i, b) => Marshal.WriteByte(rgbData, i, b), rasterSymbolizer, stride, pm);

                if (rasterSymbolizer.IsSmoothed)
                {
                    var mySmoother = new Smoother(stride, raster.NumColumns, raster.NumRows, rgbData, pm.ProgressHandler);
                    mySmoother.Smooth();
                }
            }
        }
Пример #5
0
    // Update is called once per frame
    void Update()
    {
        this.isTracked = XRNetworkClient.IsTracked(label);
        this.smoother  = Smoother.GetSmoother(smoothing);

        IMURot = GetIMURotation();
        var newIMU = Quaternion.Slerp(lastIMURot, IMURot, lowPassFactor);

        lastIMURot = IMURot;
        IMURot     = newIMU;

        velocity = (transform.position - lastPosition) / Time.deltaTime;
        velocity = Vector3.ClampMagnitude(velocity, maxMagnitude);

        imuOnly = !isTracked;

        if (mode != Mode.Rotation)
        {
            transform.position = GetCurrentPosition();
        }
        if (mode != Mode.Position)
        {
            transform.rotation = GetCurrentRotation();
        }

        lastPosition = transform.position;
        lastRotation = transform.rotation;
        lastTracked  = isTracked;
        if (lastTracked)
        {
            lastTrackedTime = Time.time;
        }
        lastVelocity = velocity;
    }
Пример #6
0
        private Kinect()
        {
            sensor = KinectSensor.GetDefault();
            sensor.Open();

            // Prepare sensor feed
            frameReader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth);
            frameReader.MultiSourceFrameArrived += frameReader_frameArrived;

            numBodies      = this.sensor.BodyFrameSource.BodyCount;
            gestureSources = new VisualGestureBuilderFrameSource[numBodies];
            gestureReaders = new VisualGestureBuilderFrameReader[numBodies];
            OpenBodyReader();
            OpenGestureReader();
            bodies = new Body[numBodies];

            //Coordinate Mapping
            coordinateMapper = sensor.CoordinateMapper;

            sensor.IsAvailableChanged += OnIsAvailableChanged;
            smoother = new Smoother();

            setHand(true);
            NextMode      = CursorModes.Idle;
            ModeFrameSkip = 0;
        }
Пример #7
0
        /// <summary>
        /// Creates a bitmap from this raster using the specified rasterSymbolizer.
        /// </summary>
        /// <param name="raster">The raster to draw to a bitmap.</param>
        /// <param name="rasterSymbolizer">The raster symbolizer to use for assigning colors.</param>
        /// <param name="rgbData">Byte values representing the ARGB image bytes.</param>
        /// <param name="stride">The stride</param>
        /// <param name="pm">The progress meter to use.</param>
        public static void DrawToBitmap(this IRaster raster, IRasterSymbolizer rasterSymbolizer, byte[] rgbData, int stride, ProgressMeter pm)
        {
            if (raster.DataType == typeof(int))
            {
                DrawToBitmapT(raster.ToRaster <int>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(float))
            {
                DrawToBitmapT(raster.ToRaster <float>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(short))
            {
                DrawToBitmapT(raster.ToRaster <short>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(byte))
            {
                DrawToBitmapT(raster.ToRaster <byte>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else if (raster.DataType == typeof(double))
            {
                DrawToBitmapT(raster.ToRaster <double>(), rasterSymbolizer, rgbData, stride, pm);
            }
            else
            {
                DrawToBitmapT(raster, raster.NoDataValue, (row, col) => raster.Value[row, col], i => rgbData[i], (i, b) => rgbData[i] = b, rasterSymbolizer, stride, pm);

                if (rasterSymbolizer.IsSmoothed)
                {
                    var mySmoother = new Smoother(stride, raster.NumColumns, raster.NumRows, rgbData, pm.ProgressHandler);
                    mySmoother.Smooth();
                }
            }
        }
Пример #8
0
        static void Main(string[] args)
        {
            Reader             reader = new Reader();
            List <Forecasting> forcs  = reader.ParseData();

            int    seasonTime    = 12;
            double stapwaarde    = 0.1;
            double stapwaardeNew = stapwaarde / 10;

            int totalData    = 48;
            int predictMonth = 3;

            Formules func     = new Formules(seasonTime);
            Smoother smoother = new Smoother();

            Main main = new Main(forcs, func, smoother, seasonTime);

            main.Run(); // run once

            //Update smoothnes of Alpha, Delta, Gamma
            //main.UpdateSmoothness(stapwaarde);
            //main.UpdateSmoothness(stapwaarde, true);
            //main.UpdateSmoothness(stapwaardeNew, false);

            // prediction
            main.Prediction(totalData, predictMonth);

            Console.ReadLine();
        }
Пример #9
0
    /// <summary>
    /// 音声入力デバイス選択待機
    /// </summary>
    protected void Init()
    {
        // コマンドライン引数
        DeviceName = CommandLineArgs.AudioInputDevice;
        if (DeviceName != null)
        {
            if (DeviceName == "" || Microphone.devices.Contains(DeviceName))
            {
                StartRecording();
            }
            else
            {
                Canvas.DisplayMessage($"Device named “{DeviceName}” do not exists.");
                DeviceName = null;
            }
        }
        else if (CommandLineArgs.HideTextDefault)
        {
            return;
        }

        if (DeviceName == null)
        {
            StartCoroutine("SelectMicrophone");
        }

        // 平滑化初期化
        // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_utils_the_smoother_utility.html
        SenseManager = SenseManager.CreateInstance();
        Smoother     = Smoother.CreateInstance(SenseManager.Session);
        SmoothMouth  = Smoother.Create1DWeighted(5);

        MonitorMicrophone();
    }
Пример #10
0
        protected virtual void InitializeProcessingTasks()
        {
            MSGenerator  = MSGeneratorFactory.CreateMSGenerator(Run.MSFileType);
            PeakDetector = PeakDetectorFactory.CreatePeakDetector(NewDeconToolsParameters);
            Deconvolutor = DeconvolutorFactory.CreateDeconvolutor(NewDeconToolsParameters);

            //the new iThrash imports the _peaks.txt file
            if (Deconvolutor is DeconTools.Backend.ProcessingTasks.Deconvoluters.InformedThrashDeconvolutor)
            {
                _deconvolutorRequiresPeaksFile = true;
            }

            //Will initialize these but whether or not they are used are determined elsewhere
            ZeroFiller = new DeconToolsZeroFiller(NewDeconToolsParameters.MiscMSProcessingParameters.ZeroFillingNumZerosToFill);
            Smoother   = new SavitzkyGolaySmoother(NewDeconToolsParameters.MiscMSProcessingParameters.SavitzkyGolayNumPointsInSmooth,
                                                   NewDeconToolsParameters.MiscMSProcessingParameters.SavitzkyGolayOrder);

            FitScoreCalculator = new DeconToolsFitScoreCalculator();
            ScanResultUpdater  = new ScanResultUpdater(NewDeconToolsParameters.ScanBasedWorkflowParameters.ProcessMS2);
            ResultValidator    = new ResultValidatorTask();

            IsosResultExporter = IsosExporterFactory.CreateIsosExporter(Run.ResultCollection.ResultType, ExporterType,
                                                                        IsosOutputFileName);

            ScanResultExporter = ScansExporterFactory.CreateScansExporter(Run.MSFileType, ExporterType,
                                                                          ScansOutputFileName);

            if (!_deconvolutorRequiresPeaksFile)
            {
                PeakListExporter = PeakListExporterFactory.Create(ExporterType, Run.MSFileType, PeakListExporterTriggerValue,
                                                                  PeakListOutputFileName);
            }

            PeakToMSFeatureAssociator = new PeakToMSFeatureAssociator();
        }
Пример #11
0
    private void OnDestroy()
    {
        //Debug.Log("ActorMover Destroy :" + gameObject.name);
        GameWorld.instance.RemoveAgent(aiAgent);

        aiAgent            = null;
        steeringBehaviour  = null;
        m_pHeadingSmoother = null;
    }
Пример #12
0
    protected void Init()
    {
        try
        {
            // RealSense初期化
            // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_face_general_procedure.html
            // 参考:.\Intel\RSSDK\sample\core\RawStreams.unity
            SenseManager = SenseManager.CreateInstance();

            FaceModule = FaceModule.Activate(SenseManager);
            FaceModule.FrameProcessed += FaceModule_FrameProcessed;
            FaceData = FaceModule.CreateOutput();

            FaceConfig = FaceModule.CreateActiveConfiguration();
            FaceConfig.TrackingMode = TrackingModeType.FACE_MODE_COLOR;
            FaceConfig.Expressions.Properties.Enabled = true;
            FaceConfig.ApplyChanges();

            SampleReader = SampleReader.Activate(SenseManager);
            SampleReader.EnableStream(StreamType.STREAM_TYPE_COLOR, 640, 480, 30);
            SampleReader.SampleArrived += SampleReader_SampleArrived;

            SenseManager.Init();
            SenseManager.StreamFrames(false);

            // RawStreams
            Texture = NativeTexturePlugin.Activate();
            Material.mainTexture      = new Texture2D(640, 480, TextureFormat.BGRA32, false);
            Material.mainTextureScale = new Vector2(-1, -1);
            TexPtr = Material.mainTexture.GetNativeTexturePtr();

            // 解像度取得
            StreamProfileSet profile;
            SenseManager.CaptureManager.Device.QueryStreamProfileSet(out profile);
            Resolution = profile.color.imageInfo;

            // 平滑化初期化
            // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_utils_the_smoother_utility.html
            Smoother = Smoother.CreateInstance(SenseManager.Session);

            SmoothBody      = Smoother.Create3DWeighted(BodyPosSmoothWeight);
            SmoothHead      = Smoother.Create3DWeighted(HeadAngSmoothWeight);
            SmoothEyes      = Smoother.Create2DWeighted(EyesPosSmoothWeight);
            SmoothEyesClose = Smoother.Create1DWeighted(EyesCloseSmoothWeight);
            SmoothBrowRai   = Smoother.Create1DWeighted(FaceSmoothWeight);
            SmoothBrowLow   = Smoother.Create1DWeighted(FaceSmoothWeight);
            SmoothSmile     = Smoother.Create1DWeighted(FaceSmoothWeight);
            SmoothKiss      = Smoother.Create1DWeighted(FaceSmoothWeight);
            SmoothMouth     = Smoother.Create1DWeighted(FaceSmoothWeight);
            SmoothTongue    = Smoother.Create1DWeighted(FaceSmoothWeight);
        }
        catch (Exception e)
        {
            ErrorLog.text  = "RealSense Error\n";
            ErrorLog.text += e.Message;
        }
    }
Пример #13
0
    override public void Erode(GameObject inTerrain)
    {
        Terrain     ter         = inTerrain.GetComponent <Terrain>();
        TerrainData terrainData = ter.terrainData;

        w       = terrainData.heightmapWidth;
        h       = terrainData.heightmapWidth;
        heights = terrainData.GetHeights(0, 0, w, h);

        float talus = smoothness / (float)w;

        for (int iterCount = 0; iterCount < iterations; iterCount++)
        {
            for (int x = 1; x < (w - 1); x++)
            {
                for (int y = 1; y < (h - 1); y++)
                {
                    int   lowestX = 0;
                    int   lowestY = 0;
                    float newHeight;
                    float currentHeight = heights[x, y];
                    float maxDifference = float.MinValue;

                    for (int i = -1; i <= 1; i += 1)
                    {
                        for (int j = -1; j <= 1; j += 1)
                        {
                            float currentDifference = currentHeight - heights[x + i, y + j];

                            if (currentDifference > maxDifference)
                            {
                                maxDifference = currentDifference;

                                lowestX = i;
                                lowestY = j;
                            }
                        }
                    }

                    if (maxDifference > talus)
                    {
                        newHeight = maxDifference / 2.0f;

                        heights[x, y] -= newHeight;
                        heights[x + lowestX, y + lowestY] += newHeight;
                    }
                }
            }
        }

        terrainData.SetHeights(0, 0, heights);

        if (doSmooth)
        {
            Smoother.Smoothen(inTerrain, 1);
        }
    }
Пример #14
0
    /// <summary>
    /// 音声入力デバイス選択待機
    /// </summary>
    protected void Init()
    {
        StartCoroutine("SelectMicrophone");

        // 平滑化初期化
        // 参考:https://software.intel.com/sites/landingpage/realsense/camera-sdk/v2016r3/documentation/html/index.html?doc_utils_the_smoother_utility.html
        Session     = Session.CreateInstance();
        Smoother    = Smoother.CreateInstance(Session);
        SmoothMouth = Smoother.Create1DWeighted(5);
    }
Пример #15
0
        private static void DrawToBitmapT <T>(Raster <T> raster, IRasterSymbolizer rasterSymbolizer, IntPtr rgbData, int stride, ProgressMeter pm)
            where T : struct, IEquatable <T>, IComparable <T>
        {
            DrawToBitmapT(raster, GetNoData(raster), (row, col) => raster.Data[row][col], i => Marshal.ReadByte(rgbData, i), (i, b) => Marshal.WriteByte(rgbData, i, b), rasterSymbolizer, stride, pm);

            if (rasterSymbolizer.IsSmoothed)
            {
                var mySmoother = new Smoother(stride, raster.NumColumns, raster.NumRows, rgbData, pm.ProgressHandler);
                mySmoother.Smooth();
            }
        }
Пример #16
0
 public void Setup()
 {
     uut = new Smoother();
     testModelLocation = Directory.GetParent(
         Directory.GetParent(
             Directory.GetParent(
                 Environment.CurrentDirectory).
             ToString()).
         ToString()) +
                         "\\TestModels";
 }
Пример #17
0
        /// <summary>
        /// Creates a bitmap from this raster using the specified rasterSymbolizer.
        /// </summary>
        /// <param name="raster">The raster to draw to a bitmap</param>
        /// <typeparam name="T">Type of the raster.</typeparam>
        /// <param name="rasterSymbolizer">The raster symbolizer to use for assigning colors</param>
        /// <param name="rgbData">Byte values representing the ARGB image bytes</param>
        /// <param name="stride">The stride</param>
        /// <param name="pm">The progress meter to use.</param>
        /// <exception cref="ArgumentNullException">rasterSymbolizer cannot be null</exception>
        public static void DrawToBitmapT <T>(Raster <T> raster, IRasterSymbolizer rasterSymbolizer, byte[] rgbData, int stride, ProgressMeter pm)
            where T : struct, IEquatable <T>, IComparable <T>
        {
            DrawToBitmapT(raster, GetNoData(raster), (row, col) => raster.Data[row][col], i => rgbData[i], (i, b) => rgbData[i] = b, rasterSymbolizer, stride, pm);

            if (rasterSymbolizer.IsSmoothed)
            {
                var mySmoother = new Smoother(stride, raster.NumColumns, raster.NumRows, rgbData, pm.ProgressHandler);
                mySmoother.Smooth();
            }
        }
        private static void CreateMouthRiverChunkForNode(List <Vector2Int> nodes, Vector2Int riverMouth, List <Vector2Int> riverMouthChunks, Side edge, Vector2Int closestNode)
        {
            var previousNodeOfClosestNode = nodes[nodes.IndexOf(closestNode) - 1];
            var externalNodeOf            = GetExternalNodeOf(edge, riverMouth);
            var riverChunk = new List <Vector2Int> {
                previousNodeOfClosestNode, closestNode, riverMouth, externalNodeOf
            };
            var smoothedChunk = Smoother.Smooth(riverChunk);

            riverMouthChunks.AddRange(smoothedChunk);
        }
Пример #19
0
        /// <summary>
        /// Pulls all XICs needed to perform charge correlation
        /// </summary>
        /// <param name="peaksToCorrelate"></param>
        /// <param name="MZList"></param>
        /// <param name="run"></param>
        /// <param name="startScan"></param>
        /// <param name="stopScan"></param>
        /// <returns></returns>
        private XYData[] GetCorrelationXICs(int peaksToCorrelate, IEnumerable <double> MZList, Run run, int startScan, int stopScan)
        {
            var XICArray = new XYData[peaksToCorrelate];
            var index    = 0;

            foreach (var mz in MZList)
            {
                XICArray[index] = Smoother.Smooth(_chromGen.GenerateChromatogram(run, startScan, stopScan, mz, 20));
                index++;
            }
            return(XICArray);
        }
Пример #20
0
        public SmoothingProcessor()
        {
            polynomialOrder = 2;
            windowSize      = 15;
            lambda          = 2.0;
            algorithm       = new SavitzkyGolaySmoother(polynomialOrder, windowSize);

            processingPanels.smootherAlgorithmComboBox.SelectedIndexChanged            += new EventHandler(optionsChanged);
            processingPanels.smootherSavitzkyGolayPolynomialOrderTrackBar.ValueChanged += new EventHandler(optionsChanged);
            processingPanels.smootherSavitzkyGolayWindowSizeTrackBar.ValueChanged      += new EventHandler(optionsChanged);
            processingPanels.smootherWhittakerLambdaTextBox.TextChanged += new EventHandler(optionsChanged);
        }
Пример #21
0
 //private Vector previousPos;
 public LeapParser3(Models models)
 {
     swipes      = new LimitedQueue <int>(5);
     smoother    = new Smoother();
     this.models = models;
     timer       = 0f;
     controller  = new Controller();
     // CONFIGURE LEAP ////////////////////
     controller.EnableGesture(Gesture.GestureType.TYPESWIPE);
     controller.Config.SetFloat("Gesture.Swipe.MinLength", 150f);            //DEFAULT 150f in mm
     controller.Config.SetFloat("Gesture.Swipe.MinVelocity", 500f);          //DEFAULT 1000f in mm/s
     controller.Config.Save();
 }
Пример #22
0
    protected virtual void Awake()
    {
        behaviours = new List <Behaviour>();
        owner      = GetComponent <Agent>();
        ownerType  = owner.GetType();

        smoother = new Smoother(smootherSampleSize);

        range = new AABB(transform.position, Vector3.one * radius);

        NearEntities = new List <Agent>();
        buffer       = new List <Entity>();
    }
Пример #23
0
        public void ErodeMap()
        {
            var eroder = new Eroder(heights, eroderSettings);

            foreach (int i in Enumerable.Range(0, 5000))
            {
                eroder.Erode();
            }

            var smoother = new Smoother(heights);

            heights = smoother.Smooth(4, 1.0f);
            GetComponent <Terrain>().terrainData.SetHeights(0, 0, heights);
        }
 private void SetupVisualizer()
 {
     smoother1          = new Smoother(4, 6);
     smoother2          = new Smoother(4, 12);
     smoother3          = new Smoother(4, 14);
     smoother4          = new Smoother(4, 14);
     smoother5          = new Smoother(4, 15);
     smoother6          = new Smoother(4, 16);
     smoother7          = new Smoother(4, 16);
     smoother8          = new Smoother(4, 15);
     smoother9          = new Smoother(4, 14);
     averageSmoother    = new Smoother(1000, 100);
     Blurple            = (Color)App.Current.Resources["BlurpleColor"];
     TransparentBlurple = (Color)App.Current.Resources["BlurpleColorTransparent"];
 }
        /// <summary>
        /// Returns the Quaternion representing the rotation of the given label. Can be redefined in children classes to change the smoothing logic. Current smoothing logic is as follows:<para><example> <see cref="GenericDeviceController.Smoothing"/> ? <see cref="Smoother.Average(Queue{Quaternion})"/> : queue.LastOrDefault()</example></para>
        /// </summary>
        /// <param name="label">The label to get the rotation.</param>
        /// <returns>A Quaternion representing the rotation of the given label.</returns>
        public virtual Quaternion GetRotation(string label)
        {
            if (RotationLocks.ContainsKey(label) == false)
            {
                return(Quaternion.identity);
            }

            var @lock = RotationLocks[label];
            var queue = RotationQueues[label];

            lock (@lock)
            {
                return(Controller.Smoothing ? Smoother.Average(queue) : queue.Count == 0 ? Quaternion.identity : queue.Last().Rotation);
            }
        }
        /// <summary>
        /// Returns the float value of the given label. Can be redefined in children classes to change the smoothing logic. Current smoothing logic is as follows:<para><example> <see cref="GenericDeviceController.Smoothing"/> ? <see cref="Smoother.Average(Queue{Vector3})"/> : queue.LastOrDefault()</example></para>
        /// </summary>
        /// <param name="label">The label to get the float value.</param>
        /// <returns>A float value of the given label.</returns>
        public virtual float GetFloat(string label)
        {
            if (FloatQueues.ContainsKey(label) == false)
            {
                return(0f);
            }

            var @lock = FloatLocks[label];
            var queue = FloatQueues[label];

            lock (@lock)
            {
                return(Controller.Smoothing ? Smoother.Average(queue) : queue.Count == 0 ? 0f : queue.Last().Value);
            }
        }
Пример #27
0
    public override void OnStartClient()
    {
        var setup = FindObjectOfType <GameFlow>().setup;

        _smoother = new Smoother <RawPoint>();  // original
        _smoother.saccadeThreshold = 30;        // 30
        _smoother.timeWindow       = 100;       // 150
        _smoother.dampFixation     = 250;       // 700

        _simulate = simulate || setup.mode == Setup.Mode.HeadGaze || (Environment.UserName == "csolsp" && Screen.currentResolution.width == 1920);

        if (_simulate)
        {
            _simulator         = FindObjectOfType <GazeSimulator>();
            _simulator.Sample += onSimulatorSample;
            _simulator.State  += onSimulatorState;
            _simulator.Device += onSimulatorDevice;
            _simulator.Initialize();
            return;
        }

        gazeControls.SetActive(true);

        _ws         = new WebSocketSharp.WebSocket("ws://localhost:8086/");
        _ws.OnOpen += (sender, e) =>
        {
            print("WS:> Connected");
        };
        _ws.OnClose += (sender, e) =>
        {
            print("WS:> Disconnected");
        };
        _ws.OnError += (sender, e) =>
        {
            print($"WS:> Error {e.Message}");
        };
        _ws.OnMessage += (sender, e) =>
        {
            //print($"WS:> MSG {e.Data}");
            lock (_messages)
            {
                _messages.Enqueue(e.Data);
            }
        };

        _ws.ConnectAsync();
    }
        /// <summary>
        /// Returns the Vector3 representing the position of the given label. Can be redefined in children classes to change the smoothing logic. Current smoothing logic is as follows:<para><example> <see cref="GenericDeviceController.Smoothing"/> ? <see cref="Smoother.Average(System.Collections.Generic.Queue{Neurorehab.Scripts.Devices.UdpPosition})"/> : queue.LastOrDefault()</example></para>
        /// </summary>
        /// <param name="label">The label to get the rotation.</param>
        /// <returns>A Vector3 representing the rotation of the given label.</returns>
        public virtual Vector3 GetPosition(string label)
        {
            if (PositionLocks.ContainsKey(label) == false)
            {
                return(Vector3.zero);
            }

            var @lock = PositionLocks[label];
            var queue = PositionQueues[label];

            lock (@lock)
            {
                return((Controller.Smoothing ?
                        Smoother.Average(queue) : queue.Count == 0 ?
                        Vector3.zero : queue.Last().Position) * Controller.PositionMultiplier);
            }
        }
Пример #29
0
        public RenderGameState2(/*CanvasControl canvas,*/ IZoomer zoomer, TextBlock leftScore, TextBlock rightScore)
        {
            //this.canvas = canvas ?? throw new ArgumentNullException(nameof(canvas));
            this.zoomer     = new Smoother(zoomer) ?? throw new ArgumentNullException(nameof(zoomer));
            this.leftScore  = leftScore ?? throw new ArgumentNullException(nameof(leftScore));
            this.rightScore = rightScore ?? throw new ArgumentNullException(nameof(rightScore));


            //bell = new MediaPlayer();
            //bell.Source = MediaSource.CreateFromUri(new Uri($"ms-appx:///Assets/bell.wav"));

            //var random = new Random();
            //for (int i = 0; i < 10; i++)
            //{
            //    var player = new MediaPlayer();
            //    player.Source = MediaSource.CreateFromUri(new Uri($"ms-appx:///Assets/hit{random.Next(1, 4)}.wav"));
            //    collisionSounds.AddLast(player);
            //}
        }
Пример #30
0
 /// <summary>
 /// Setup FFT
 /// </summary>
 private void fftInitialize(object sender, RoutedEventArgs e)
 {
     // If FFT is enabled, setup render smoothers for each data point
     if (Storage.Settings.ExpensiveRender)
     {
         smoother1          = new Smoother(4, 6);
         smoother2          = new Smoother(4, 12);
         smoother3          = new Smoother(4, 14);
         smoother4          = new Smoother(4, 14);
         smoother5          = new Smoother(4, 15);
         smoother6          = new Smoother(4, 16);
         smoother7          = new Smoother(4, 16);
         smoother8          = new Smoother(4, 15);
         smoother9          = new Smoother(4, 14);
         averageSmoother    = new Smoother(1000, 100);
         Blurple            = (Color)App.Current.Resources["BlurpleColor"];
         TransparentBlurple = (Color)App.Current.Resources["BlurpleColorTransparent"];
         initailized        = true;
     }
 }