Beispiel #1
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //compute only on refresh
            if (FRefresh.PinIsChanged)
            {
                System.Windows.Forms.Screen [] screens = System.Windows.Forms.Screen.AllScreens;

                //set slicecount
                FResolutionOutput.SliceCount       = screens.Length;
                FResolutionOffsetOutput.SliceCount = screens.Length;
                FWorkAreaOutput.SliceCount         = screens.Length;
                FWorkAreaOffsetOutput.SliceCount   = screens.Length;
                FBitsPerPixel.SliceCount           = screens.Length;
                FDeviceName.SliceCount             = screens.Length;
                FIsPrimary.SliceCount = screens.Length;

                //loop for all slices
                for (int i = 0; i <= screens.GetUpperBound(0); i++)
                {
                    //write data to outputs
                    FResolutionOutput.SetValue2D(i, screens[i].Bounds.Width, screens[i].Bounds.Height);
                    FResolutionOffsetOutput.SetValue2D(i, screens[i].Bounds.Left, screens[i].Bounds.Top);
                    FWorkAreaOutput.SetValue2D(i, screens[i].WorkingArea.Width, screens[i].WorkingArea.Height);
                    FWorkAreaOffsetOutput.SetValue2D(i, screens[i].WorkingArea.Left, screens[i].WorkingArea.Top);
                    FBitsPerPixel.SetValue(i, (double)screens[i].BitsPerPixel);
                    FDeviceName.SetString(i, screens[i].DeviceName);
                    FIsPrimary.SetValue(i, (double)screens[i].Primary.GetHashCode());
                }
            }
        }
Beispiel #2
0
        private void BalanceBoard()
        {
            FPinOutputExtButtons.SetValue(0, FRemote.WiimoteState.BalanceBoardState.WeightKg);

            FPinOutputExtAccelleration.SliceCount = 4;
            FPinOutputExtAccelleration.SetValue(0, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopLeft);
            FPinOutputExtAccelleration.SetValue(1, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopRight);
            FPinOutputExtAccelleration.SetValue(2, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft);
            FPinOutputExtAccelleration.SetValue(3, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomRight);

            //FPinOutputExtAccelleration.SliceCount = 1;
            //FPinOutputExtAccelleration.SetValue4D(0, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopLeft, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopRight, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomRight);

            FPinOutputExtJoystickLeft.SliceCount = 1;
            FPinOutputExtJoystickLeft.SetValue2D(0, FRemote.WiimoteState.BalanceBoardState.CenterOfGravity.X * 2, FRemote.WiimoteState.BalanceBoardState.CenterOfGravity.Y * 2);
        }
Beispiel #3
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FPinInVertices.PinIsChanged || FPinInCenter.PinIsChanged || FPinInRadius.PinIsChanged)
            {
                /*
                 * FHost.Log(TLogType.Debug, "FPinInVertices.SliceCount " + FPinInVertices.SliceCount);
                 * FHost.Log(TLogType.Debug, "FPinInCenter.SliceCount " + FPinInCenter.SliceCount);
                 * FHost.Log(TLogType.Debug, "FPinInRadius.SliceCount " + FPinInRadius.SliceCount);
                 */
                FPinOutVertices.SliceCount = FPinInVertices.SliceCount * FPinInCenter.SliceCount * FPinInRadius.SliceCount;
                int    index = 0;
                double pointX, pointY;
                double radius;
                double centerX, centerY;
                double inversionFactor;

                //loop for all slices
                for (int i = 0; i < FPinInVertices.SliceCount; i++)
                {
                    FPinInVertices.GetValue2D(i, out pointX, out pointY);
                    for (int j = 0; j < FPinInCenter.SliceCount; j++)
                    {
                        FPinInCenter.GetValue2D(j, out centerX, out centerY);
                        pointX -= centerX;
                        pointY -= centerY;

                        for (int k = 0; k < FPinInRadius.SliceCount; k++)
                        {
                            FPinInRadius.GetValue(k, out radius);
                            inversionFactor = radius * radius / (pointX * pointX + pointY * pointY);
                            pointX         *= inversionFactor;
                            pointY         *= inversionFactor;

                            pointX += centerX;
                            pointY += centerY;

                            FPinOutVertices.SetValue2D(index, pointX, pointY);
                            index++;
                        }
                    }
                }
            }
        }
Beispiel #4
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FDistortion.PinIsChanged ||
                FFocalLength.PinIsChanged ||
                FPrincipalPoint.PinIsChanged ||
                FResolution.PinIsChanged)
            {
                //get the distortion values
                FDistortion.GetValue4D(0, out FDist.x, out FDist.y, out FDist.z, out FDist.w);
                FFocalLength.GetValue2D(0, out FFocal.x, out FFocal.y);
                FPrincipalPoint.GetValue2D(0, out FPrincipal.x, out FPrincipal.y);
                FResolution.GetValue2D(0, out FReso.x, out FReso.y);
            }

            //set slicecounts for output
            //here its the same as the input
            SpreadMax          = FInput.SliceCount;
            FOutput.SliceCount = SpreadMax;
            FTries.SliceCount  = SpreadMax;

            //the variable to fill with the input data
            Vector2D currentPosition;

            //loop for all slices
            for (int i = 0; i < SpreadMax; i++)
            {
                //read data from inputs
                FInput.GetValue2D(i, out currentPosition.x, out currentPosition.y);

                int tries;

                //function per slice
                currentPosition = Undistort(currentPosition, FFocal, FPrincipal, FDist, FReso, out tries);

                //write data to outputs
                FOutput.SetValue2D(i, currentPosition.x, currentPosition.y);
                FTries.SetValue(i, tries);
            }
        }
Beispiel #5
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            double width; FPinWidth.GetValue(0, out width);
            double height; FPinHeight.GetValue(0, out height);

            // if something changed, recreate Trafo
            if (FInputGridFrom.PinIsChanged || FInputGridTo.PinIsChanged || width != FWidth || height != FHeight)
            {
                // prepare GridTransformer
                FTrafo = new GridTransformer();

                int     i, j;
                Point2D p1, p2, p3;

                FWidth  = (int)width;
                FHeight = (int)height;

                // check Input ranges
                FBufSize = (int)height * (int)width * 2;
                if (FInputGridFrom.SliceCount != FBufSize || FInputGridTo.SliceCount != FBufSize)
                {
                    return;
                }


                // loop through points and create triangles
                for (i = 0; i < FHeight - 1; ++i)
                {
                    for (j = 0; j < FWidth - 1; ++j)
                    {
                        int index = j + i * FWidth;

                        // upper triangle
                        FInputGridFrom.GetValue2D(index, out p1.x, out p1.y);
                        FInputGridFrom.GetValue2D(index + 1, out p2.x, out p2.y);
                        FInputGridFrom.GetValue2D(index + FWidth, out p3.x, out p3.y);
                        Triangle triFrom1 = new Triangle(p1, p2, p3);

                        FInputGridTo.GetValue2D(index, out p1.x, out p1.y);
                        FInputGridTo.GetValue2D(index + 1, out p2.x, out p2.y);
                        FInputGridTo.GetValue2D(index + FWidth, out p3.x, out p3.y);
                        Triangle triTo1 = new Triangle(p1, p2, p3);

                        FTrafo.Insert(triFrom1, triTo1);

                        // lower triangle
                        FInputGridFrom.GetValue2D(index + 1, out p1.x, out p1.y);
                        FInputGridFrom.GetValue2D(index + FWidth, out p2.x, out p2.y);
                        FInputGridFrom.GetValue2D(index + FWidth + 1, out p3.x, out p3.y);
                        Triangle triFrom2 = new Triangle(p1, p2, p3);

                        FInputGridTo.GetValue2D(index + 1, out p1.x, out p1.y);
                        FInputGridTo.GetValue2D(index + FWidth, out p2.x, out p2.y);
                        FInputGridTo.GetValue2D(index + FWidth + 1, out p3.x, out p3.y);
                        Triangle triTo2 = new Triangle(p1, p2, p3);

                        FTrafo.Insert(triFrom2, triTo2);
                    }
                }
            }

            ///////////////////////////////////////////////////////
            // do transformation

            // prepare data
            int            sliceCount = FInputPoints.SliceCount;
            Point2D        pIn, pOut;
            List <Point2D> pList = new List <Point2D>();

            int[] hitter;
            hitter = new int[sliceCount / 2];
            int number = (sliceCount / 2);

            // loop throug input points and calc Transformation
            for (int i = 0; i < sliceCount / 2; ++i)
            {
                FInputPoints.GetValue2D(i, out pIn.x, out pIn.y);
                if (FTrafo.Transform(pIn, out pOut))   // inside ?
                {
                    pList.Add(pOut);
                    hitter[i] = 1;
                }
                else
                {
                    hitter[i] = 0;
                }
            }

            // set final slicecount
            FOutputPoints.SliceCount = pList.Count * 2;
            FOutputHit.SliceCount    = number;
            // set output
            for (int i = 0; i < pList.Count; ++i)
            {
                FOutputPoints.SetValue2D(i, pList[i].x, pList[i].y);
                FOutputHit.SetValue(i, hitter[i]);
            }
            for (int i = 0; i < number; ++i)
            {
                FOutputHit.SetValue(i, hitter[i]);
            }
        }