Example #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)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FPositionInput.PinIsChanged || FVectorSizeInput.PinIsChanged || FP1Input.PinIsChanged ||
                FP2Input.PinIsChanged || FP3Input.PinIsChanged || FP4Input.PinIsChanged)
            {
                //get vector size
                double vs;
                FVectorSizeInput.GetValue(0, out vs);
                int vectorSize = (int)vs;

                SpreadMax = Math.Max(SpreadMax, FPositionInput.SliceCount * vectorSize);

                //first set slicecounts for all outputs
                //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default
                FValueOutput.SliceCount = SpreadMax;

                //the variables to fill with the input data
                Vector2D vectorSlice;
                double   p1Slice;
                double   p2Slice;
                double   p3Slice;
                double   p4Slice;

                //loop for all slices
                for (int i = 0; i < SpreadMax; i++)
                {
                    //read data from inputs
                    FPositionInput.GetValue2D(i / vectorSize, out vectorSlice.x, out vectorSlice.y);
                    FP1Input.GetValue(i, out p1Slice);
                    FP2Input.GetValue(i, out p2Slice);
                    FP3Input.GetValue(i, out p3Slice);
                    FP4Input.GetValue(i, out p4Slice);

                    //function per slice
                    p1Slice = VMath.Bilerp(vectorSlice, p1Slice, p2Slice, p3Slice, p4Slice);

                    //write data to outputs
                    FValueOutput.SetValue(i, p1Slice);
                }
            }
        }