Exemplo n.º 1
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        unsafe public void Evaluate(int SpreadMax)
        {
            if (!ldRunning)
            {
                return;
            }
            else
            {
                PrintStatusMessage("");
            }

            double    tmp;
            double *  px, py;
            int       v, countx, county;
            int       frameOffset = 0;
            int       pointCount  = 0;
            RGBAColor color;

            int[] frames = new int[FFrameIn.SliceCount];

            for (int i = 0; i < frames.Length; i++)
            {
                FFrameIn.GetValue(i, out tmp);
                frames[i] = VMath.Zmod((int)tmp, ldMaxFrames);
            }

            FDoWriteIn.GetValue(0, out tmp);
            if (tmp > 0)
            {
                pointCount = Math.Max(Math.Max(FXIn.SliceCount, FYIn.SliceCount), FColorIn.SliceCount);

                // Setup a mapping of point and its special flags.
                pointFlagMap.Clear();
                int pointId;
                for (int j = 0; j < FCornerIn.SliceCount; j++)
                {
                    FCornerIn.GetValue(j, out tmp);
                    pointId = VMath.Zmod((int)tmp, pointCount);
                    if (pointFlagMap.ContainsKey(pointId))
                    {
                        pointFlagMap[pointId] |= FLAG_CORNER;
                    }
                    else
                    {
                        pointFlagMap[pointId] = FLAG_CORNER;
                    }
                }
                for (int j = 0; j < FTravelBlankIn.SliceCount; j++)
                {
                    FTravelBlankIn.GetValue(j, out tmp);
                    pointId = VMath.Zmod((int)tmp, pointCount);
                    if (pointFlagMap.ContainsKey(pointId))
                    {
                        pointFlagMap[pointId] |= FLAG_TRAVELBLANK;
                    }
                    else
                    {
                        pointFlagMap[pointId] = FLAG_TRAVELBLANK;
                    }
                }

                for (int j = 0; j < frames.Length; j++)
                {
                    LD.SetWorkingFrame(frames[j]);

                    // Get the frame size for this frame
                    FFrameSizeIn.GetValue(j, out tmp);
                    int frameSize = (int)tmp;
                    if (frameSize < 0)
                    {
                        frameSize = pointCount / Math.Abs(frameSize);
                    }
                    if (frameSize > pointBuffer.Length)
                    {
                        PrintStatusMessage("Too many points. Maximum number of points for each frame is: " + pointBuffer.Length);
                        frameSize = pointBuffer.Length;
                    }

                    // Create binSize many points
                    workingFrame           = new FrameEx();
                    workingFrame.NumPoints = frameSize;

                    FXIn.GetValuePointer(out countx, out px);
                    FYIn.GetValuePointer(out county, out py);

                    int flag;
                    for (int i = 0; i < frameSize; i++)
                    {
                        pointId = i + frameOffset;

                        pointBuffer[i] = new Point();
                        v = (int)(*(px + (pointId % countx)) * 8000);
                        pointBuffer[i].X = v;

                        v = (int)(*(py + (pointId % county)) * 8000);
                        pointBuffer[i].Y = v;

                        FColorIn.GetColor(pointId, out color);
                        //swapping r'n'b
                        var r = color.R;
                        color.R = color.B;
                        color.B = r;
                        pointBuffer[i].Color = color.Color.ToArgb();

                        if (pointFlagMap.TryGetValue(pointId, out flag))
                        {
                            if ((flag & FLAG_CORNER) > 0)
                            {
                                pointBuffer[i].VOtype = LD.PT_CORNER;
                            }
                            if ((flag & FLAG_TRAVELBLANK) > 0)
                            {
                                pointBuffer[i].VOtype |= LD.PT_TRAVELBLANK;
                                pointBuffer[i].Color   = 0;
                            }
                        }
                    }

                    // Get projection zone for this frame
                    FZoneIn.GetValue(j, out tmp);
                    workingFrame.PreferredProjectionZone = VMath.Zmod((int)(tmp - 1), 30);

                    // Is this a vector orientated frame?
                    FIsVectorFrameIn.GetValue(j, out tmp);
                    workingFrame.VectorFlag = tmp > 0 ? 1 : 0;

                    // Scan rate for this frame
                    FFrameScanRateIn.GetValue(j, out tmp);
                    workingFrame.ScanRate = (int)tmp;

                    // Set animation count
                    FAnimationCountIn.GetValue(j, out tmp);
                    workingFrame.AnimationCount = (int)tmp;

                    LD.WriteFrameFastEx(ref workingFrame, ref pointBuffer[0]);

                    frameOffset += frameSize;
                }
            }
            else
            {
                List <int> corners = new List <int>();

                for (int j = 0; j < frames.Length; j++)
                {
                    LD.SetWorkingFrame(frames[j]);

                    int numPoints = 0;
                    LD.ReadNumPoints(ref numPoints);

                    pointCount += numPoints;
                }

                FXOut.SliceCount              = pointCount;
                FYOut.SliceCount              = pointCount;
                FColorOut.SliceCount          = pointCount;
                FFrameSizeOut.SliceCount      = frames.Length;
                FFrameScanRateOut.SliceCount  = frames.Length;
                FIsVectorFrameOut.SliceCount  = frames.Length;
                FZoneOut.SliceCount           = frames.Length;
                FAnimationCountOut.SliceCount = frames.Length;

                for (int j = 0; j < frames.Length; j++)
                {
                    LD.SetWorkingFrame(frames[j]);

                    int frameSize = 0;
                    LD.ReadNumPoints(ref frameSize);
                    LD.ReadFrameEx(ref workingFrame, ref pointBuffer[0]);

                    for (int i = 0; i < frameSize; i++)
                    {
                        int slice = i + frameOffset;
                        FXOut.SetValue(slice, ((double)pointBuffer[i].X) / 8000.0);
                        FYOut.SetValue(slice, ((double)pointBuffer[i].Y) / 8000.0);
                        RGBAColor c = new RGBAColor();
                        c.Color = System.Drawing.Color.FromArgb(pointBuffer[i].Color);
                        FColorOut.SetColor(slice, c);

                        // Handle vector orientated flags
                        if ((pointBuffer[i].VOtype & LD.PT_CORNER) > 0)
                        {
                            corners.Add(slice);
                        }
                    }

                    FCornerOut.SliceCount = corners.Count;
                    for (int i = 0; i < corners.Count; i++)
                    {
                        FCornerOut.SetValue(i, corners[i]);
                    }

                    FFrameSizeOut.SetValue(j, frameSize);
                    FFrameScanRateOut.SetValue(j, workingFrame.ScanRate);
                    FIsVectorFrameOut.SetValue(j, workingFrame.VectorFlag != 0 ? 1.0 : 0.0);
                    FZoneOut.SetValue(j, workingFrame.PreferredProjectionZone + 1);
                    FAnimationCountOut.SetValue(j, workingFrame.AnimationCount);

                    frameOffset += frameSize;
                }
            }

            bool vdChanged   = PinsChanged(FVDPins);
            bool skewChanged = PinsChanged(FSkewPins);

            /*
             * bool scannerChanged = FActiveScannerIn.PinIsChanged;
             * if (scannerChanged)
             * {
             *      // Blank out all scanners
             *      LD.SetWorkingScanners(-1);
             *      LD.DisplayFrame(0);
             * }
             * int scannerFrameCount = Math.Max(frames.Length, FActiveScannerIn.SliceCount);
             */
            int scannerFrameCount = Math.Max(frames.Length, FWorkingTrackIn.SliceCount);

            for (int i = 0; i < scannerFrameCount; i++)
            {
                /*
                 * FActiveScannerIn.GetValue(i, out tmp);
                 * int scannerCode = (int) tmp;
                 * scannerCode = VMath.Clamp(scannerCode, -1, MAX_SCANNER_CODE);
                 * if (scannerCode == 0) scannerCode = 1; // 0 is illegal
                 * LD.SetWorkingScanners(scannerCode);
                 */
                FWorkingTrackIn.GetValue(i, out tmp);
                int trackCode = (int)tmp;
                LD.SetWorkingTracks(trackCode);

                LD.DisplayFrame(frames[i % frames.Length]);
                if (vdChanged)
                {
                    int[] arg = PinsAsArgumentList(FVDPins, i);
                    LD.DisplayObjectSettings(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]);
                }
                if (skewChanged)
                {
                    int[] arg = PinsAsArgumentList(FSkewPins, i);
                    LD.DisplaySkew(4, arg[0], 0);
                }
            }

            /*
             * LD.SetWorkingScanners(-1);
             */
            LD.DisplayUpdate();
        }
Exemplo n.º 2
0
        public override void Evaluate(int SpreadMax)
        {
            //calc input spreadcount
            int inputSpreadCount = GetSpreadMax();

            //create or delete button groups
            int diff = inputSpreadCount - FControllerGroups.Count;

            if (diff > 0)
            {
                for (int i = 0; i < diff; i++)
                {
                    FControllerGroups.Add(new SliderGroup());
                }
            }
            else if (diff < 0)
            {
                for (int i = 0; i < -diff; i++)
                {
                    FControllerGroups.RemoveAt(FControllerGroups.Count - 1 - i);
                }
            }

            //update parameters
            int slice;

            if (FCountXIn.PinIsChanged ||
                FCountYIn.PinIsChanged ||
                FSizeXIn.PinIsChanged ||
                FSizeYIn.PinIsChanged ||
                FIsXSliderIn.PinIsChanged ||
                FSizeSliderIn.PinIsChanged ||
                FTransformIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged ||
                FSliderColorIn.PinIsChanged ||
                FSliderSpeedIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    SliderGroup group = (SliderGroup)FControllerGroups[slice];

                    Matrix4x4 trans;
                    Vector2D  count, size;
                    double    sizeSlider, sliderSpeed, isX;
                    RGBAColor col, over, active, slider;

                    FTransformIn.GetMatrix(slice, out trans);
                    FCountXIn.GetValue(slice, out count.x);
                    FCountYIn.GetValue(slice, out count.y);
                    FSizeXIn.GetValue(slice, out size.x);
                    FSizeYIn.GetValue(slice, out size.y);
                    FSizeSliderIn.GetValue(slice, out sizeSlider);
                    FColorIn.GetColor(slice, out col);
                    FOverColorIn.GetColor(slice, out over);
                    FActiveColorIn.GetColor(slice, out active);
                    FSliderColorIn.GetColor(slice, out slider);
                    FSliderSpeedIn.GetValue(slice, out sliderSpeed);
                    FIsXSliderIn.GetValue(slice, out isX);

                    group.UpdateTransform(trans, count, size, sizeSlider, col, over, active, slider, sliderSpeed, isX >= 0.5);
                }
            }

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

            for (slice = 0; slice < inputSpreadCount; slice++)
            {
                SliderGroup group = (SliderGroup)FControllerGroups[slice];

                outcount += group.FControllers.Length;
                FSpreadCountsOut.SetValue(slice, group.FControllers.Length);
            }

            //update mouse and colors
            bool valueSet = false;

            if (FMouseXIn.PinIsChanged ||
                FMouseYIn.PinIsChanged ||
                FLeftButtonIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged ||
                FSliderColorIn.PinIsChanged ||
                FCountXIn.PinIsChanged ||
                FCountYIn.PinIsChanged ||
                FLastMouseLeft)
            {
                Vector2D mouse;
                double   mouseLeft;

                FMouseXIn.GetValue(0, out mouse.x);
                FMouseYIn.GetValue(0, out mouse.y);
                FLeftButtonIn.GetValue(0, out mouseLeft);

                bool mouseDown    = mouseLeft >= 0.5;
                bool mousDownEdge = mouseDown && !FLastMouseLeft;

                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    SliderGroup group = (SliderGroup)FControllerGroups[slice];
                    valueSet |= group.UpdateMouse(mouse, mousDownEdge, mouseDown);
                }

                FLastMouseLeft = mouseDown;
            }

            //set value
            slice = 0;
            if (FValueIn.PinIsChanged ||
                FSetValueIn.PinIsChanged)
            {
                for (int i = 0; i < inputSpreadCount; i++)
                {
                    SliderGroup group  = (SliderGroup)FControllerGroups[i];
                    int         pcount = group.FControllers.Length;

                    for (int j = 0; j < pcount; j++)
                    {
                        double val;

                        FSetValueIn.GetValue(slice, out val);

                        if (val >= 0.5)
                        {
                            //update value
                            FValueIn.GetValue(slice, out val);
                            group.UpdateValue((Slider)group.FControllers[j], val);

                            valueSet = true;
                        }
                        else if (FFirstframe)
                        {
                            //load from config pin on first frame
                            FInternalValueConfig.GetValue(slice, out val);
                            group.UpdateValue((Slider)group.FControllers[j], val);
                        }

                        slice++;
                    }
                }
            }


            //write output to pins
            FValueOut.SliceCount = outcount;
            if (outcount != FInternalValueConfig.SliceCount)
            {
                FInternalValueConfig.SliceCount = outcount;
            }
            FTransformOut.SliceCount = outcount * 2;
            FColorOut.SliceCount     = outcount * 2;
            FHitOut.SliceCount       = outcount;
            FActiveOut.SliceCount    = outcount;
            FMouseOverOut.SliceCount = outcount;

            slice = 0;
            for (int i = 0; i < inputSpreadCount; i++)
            {
                SliderGroup group  = (SliderGroup)FControllerGroups[i];
                int         pcount = group.FControllers.Length;

                for (int j = 0; j < pcount; j++)
                {
                    Slider s = (Slider)group.FControllers[j];

                    FTransformOut.SetMatrix(slice * 2, s.Transform);
                    FTransformOut.SetMatrix(slice * 2 + 1, s.SliderTransform);
                    FColorOut.SetColor(slice * 2, s.CurrentCol);
                    FColorOut.SetColor(slice * 2 + 1, s.ColorSlider);
                    FValueOut.SetValue(slice, s.Value);
                    FMouseOverOut.SetValue(slice, s.MouseOver ? 1 : 0);
                    FHitOut.SetValue(slice, s.Hit ? 1 : 0);
                    FActiveOut.SetValue(slice, s.Active ? 1 : 0);

                    //update config pin
                    if (valueSet)
                    {
                        double val;
                        FInternalValueConfig.GetValue(slice, out val);

                        if (Math.Abs(s.Value - val) > 0.00000001)
                        {
                            FInternalValueConfig.SetValue(slice, s.Value);
                        }
                    }

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }
Exemplo n.º 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 (FWindowWidth != this.Width)
            {
                FWindowWidth = this.Width;
                double columns;
                FColumns.GetValue(0, out columns);
                foreach (ComboBoxSpread cb in FComboList)
                {
                    cb.SetBox((int)columns, (int)(FWindowWidth / columns));
                }
                Refresh();
            }

            //set output Slicecount
            FSelectIndex.SliceCount = FComboList.Count;
            FItem.SliceCount        = FComboList.Count;

            if (selectedIndex.Count > FComboList.Count)
            {
                int diff = selectedIndex.Count - FComboList.Count;
                selectedIndex.RemoveRange(FComboList.Count, diff);
                selectedItem.RemoveRange(FComboList.Count, diff);
            }

            //if any of the inputs has changed
            //recompute the outputs
            int binIncrement = 0;

            for (int i = 0; i < FComboList.Count; i++)
            {
                double tmpBinSize;
                FBinSize.GetValue(i, out tmpBinSize);
                int curBinSize = (int)tmpBinSize;
                if (curBinSize < 0)
                {
                    curBinSize = FItems.SliceCount;
                }

                if (FItems.PinIsChanged || FComboList[i].Items.Count != curBinSize)
                {
                    List <Color> curColorList = new List <Color>();
                    for (int j = 0; j < curBinSize; j++)
                    {
                        RGBAColor currentColor;
                        FItems.GetColor(binIncrement + j, out currentColor);
                        curColorList.Add(currentColor.Color);
                    }

                    if (!FComboList[i].Items.Equals(curColorList))
                    {
                        FComboList[i].Items.Clear();
                        foreach (Color s in curColorList)
                        {
                            FComboList[i].Items.Add(s);
                        }
                        curColorList.Clear();
                    }
                }
                binIncrement += curBinSize;

                if (selectedIndex.Count < i + 1)
                {
                    selectedIndex.Add(0);
                    selectedItem.Add(VColor.White);
                }

                double curBangSelect;
                FDoSelect.GetValue(i, out curBangSelect);
                if (curBangSelect > 0)
                {
                    double currentValueSlice;
                    FSelectItem.GetValue(i, out currentValueSlice);
                    int selectIndex = (int)(currentValueSlice % FComboList[i].Items.Count);
                    FComboList[i].SelectedItem = FComboList[i].Items[selectIndex];
                }

                RGBAColor outColor = new RGBAColor();
                if (FComboList[i].SelectedItem != null && FComboList[i].isDropDown == false)
                {
                    selectedIndex[i] = FComboList[i].SelectedIndex;
                    outColor.Color   = (Color)FComboList[i].SelectedItem;
                    selectedItem[i]  = outColor;
                }

                if (FComboList[i].SelectedItem == null)
                {
                    double curDefault;
                    FDefault.GetValue(i, out curDefault);
                    FComboList[i].SelectedItem = FComboList[i].Items[(int)curDefault];
                    selectedIndex[i]           = FComboList[i].SelectedIndex;
                    outColor.Color             = (Color)FComboList[i].SelectedItem;
                    selectedItem[i]            = outColor;
                }

                FSelectIndex.SetValue(i, selectedIndex[i]);
                FItem.SetColor(i, selectedItem[i]);
            }
        }