Esempio n. 1
0
        public override void Evaluate(int SpreadMax)
        {
            //calc input spreadcount
            int inputSpreadCount = SpreadMax;

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

            if (diff > 0)
            {
                for (int i = 0; i < diff; i++)
                {
                    FControllerGroups.Add(new RadioButtonGroup());
                }
            }
            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 ||
                FTransformIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];

                    Matrix4x4 trans;
                    Vector2D  count, size;
                    RGBAColor col, over, active;

                    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);
                    FColorIn.GetColor(slice, out col);
                    FOverColorIn.GetColor(slice, out over);
                    FActiveColorIn.GetColor(slice, out active);

                    group.UpdateTransform(trans, count, size, col, over, active);
                }
            }


            //update mouse and colors
            bool valueSet = false;

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

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

                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];
                    valueSet = group.UpdateMouse(mouse, (mouseLeft >= 0.5) && !FLastMouseLeft, mouseLeft >= 0.5);
                }

                valueSet       = FLastMouseLeft && mouseLeft < 0.5;
                FLastMouseLeft = mouseLeft >= 0.5;
            }

            if (FValueIn.PinIsChanged ||
                FSetValueIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RadioButtonGroup group = (RadioButtonGroup)FControllerGroups[slice];

                    double val;

                    FSetValueIn.GetValue(slice, out val);

                    if (val >= 0.5)
                    {
                        //update value
                        FValueIn.GetValue(slice, out val);
                        group.UpdateValue((int)Math.Round(val));
                        valueSet = true;
                    }
                    else if (FFirstframe)
                    {
                        //load from config pin on first frame
                        FInternalValueConfig.GetValue(slice, out val);
                        group.UpdateValue((int)Math.Round(val));
                    }
                }
            }

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

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

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



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

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

                FValueOut.SetValue(i, group.SelectedSlice);
                if (valueSet)
                {
                    FInternalValueConfig.SetValue(i, group.SelectedSlice);
                }

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

                    FTransformOut.SetMatrix(slice, b.Transform);
                    FColorOut.SetColor(slice, b.CurrentCol);
                    FMouseOverOut.SetValue(slice, b.MouseOver ? 1 : 0);
                    FHitOut.SetValue(slice, b.Hit ? 1 : 0);
                    FActiveOut.SetValue(slice, b.Active ? 1 : 0);

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }
Esempio 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 ToggleButtonGroup());
                }
            }
            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 ||
                FTransformIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    ToggleButtonGroup group = (ToggleButtonGroup)FControllerGroups[slice];

                    Matrix4x4 trans;
                    Vector2D  count, size;

                    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);

                    group.UpdateTransform(trans, count, size);
                }
            }

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

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

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

            this.UpdateTouches(inputSpreadCount);

            //set value
            slice = 0;
            if (FValueIn.PinIsChanged || FSetValueIn.PinIsChanged)
            {
                for (int i = 0; i < inputSpreadCount; i++)
                {
                    ToggleButtonGroup group = 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 || this.FFirstframe)
                        {
                            //update value
                            FValueIn.GetValue(slice, out val);
                            group.UpdateValue((ToggleButton)group.FControllers[j], val >= 0.5);
                        }
                        slice++;
                    }
                }
            }


            //write output to pins
            FValueOut.SliceCount     = outcount;
            FTransformOut.SliceCount = outcount;
            FHitOut.SliceCount       = outcount;

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

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

                    FTransformOut.SetMatrix(slice, s.Transform);
                    FValueOut.SetValue(slice, s.Value ? 1 : 0);
                    FHitOut.SetValue(slice, s.Hit ? 1 : 0);

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }
Esempio n. 3
0
        //this method is called by vvvv when the node is created
        public override void SetPluginHost(IPluginHost Host)
        {
            //assign host
            FHost = Host;

            //create inputs:

            //transform
            FHost.CreateTransformInput("Transform In", TSliceMode.Dynamic, TPinVisibility.True, out FTransformIn);
            //FHost.CreateValueInput("Transform In", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FTransformIn);

            //value
            FHost.CreateValueInput("Value Input ", 2, null, TSliceMode.Dynamic, TPinVisibility.True, out FValueIn);
            FValueIn.SetSubType2D(0, 1, 0.01, 0, 0, false, false, false);

            FHost.CreateValueInput("Set Value", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSetValueIn);
            FSetValueIn.SetSubType(0, 1, 1, 0, true, false, false);

            //counts
            FHost.CreateValueInput("Count X", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FCountXIn);
            FCountXIn.SetSubType(1, double.MaxValue, 1, 1, false, false, true);

            FHost.CreateValueInput("Count Y", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FCountYIn);
            FCountYIn.SetSubType(1, double.MaxValue, 1, 1, false, false, true);

            //size
            FHost.CreateValueInput("Size X", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSizeXIn);
            FSizeXIn.SetSubType(double.MinValue, double.MaxValue, 0.01, 0.9, false, false, false);

            FHost.CreateValueInput("Size Y", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSizeYIn);
            FSizeYIn.SetSubType(double.MinValue, double.MaxValue, 0.01, 0.9, false, false, false);

            //mouse
            this.FHost.CreateValueInput("Touch Id", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInTouchId);
            this.FPinInTouchId.SetSubType(double.MinValue, double.MaxValue, 1, 0, false, false, true);

            this.FHost.CreateValueInput("Touch Position", 2, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInTouchPos);
            this.FPinInTouchPos.SetSubType2D(double.MinValue, double.MaxValue, 0.01, 0, 0, false, false, false);

            this.FHost.CreateValueInput("Is new", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out this.FPinInIsNew);
            this.FPinInIsNew.SetSubType(0, 1, 1, 0, false, true, false);

            //color

            FHost.CreateValueInput("Size Slider", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSizeSliderIn);
            FSizeSliderIn.SetSubType(double.MinValue, double.MaxValue, 0.01, 0.02, false, false, false);

            FHost.CreateValueInput("Slider Speed", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSliderSpeedIn);
            FSliderSpeedIn.SetSubType(0, double.MaxValue, 0.01, 1, false, false, false);


            //create outputs
            FHost.CreateTransformOutput("Transform Out", TSliceMode.Dynamic, TPinVisibility.True, out FTransformOut);

            FHost.CreateTransformOutput("Slider Transform Out", TSliceMode.Dynamic, TPinVisibility.True, out FPinOutSliderTransform);


            FHost.CreateValueOutput("Value Output ", 2, null, TSliceMode.Dynamic, TPinVisibility.True, out FValueOut);
            FValueOut.SetSubType2D(0, 1, 0.01, 0, 0, false, false, false);

            FHost.CreateValueOutput("Hit", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FHitOut);
            FHitOut.SetSubType(0, 1, 1, 0, true, false, false);


            FHost.CreateValueOutput("Spread Counts", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSpreadCountsOut);
            FSpreadCountsOut.SetSubType(0, double.MaxValue, 0.01, 0, false, false, true);


            FControllerGroups = new List <SliderXYGroup>();
        }