Beispiel #1
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 SliderXYGroup());
                }
            }
            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 ||
                FSizeSliderIn.PinIsChanged ||
                FTransformIn.PinIsChanged ||
                FColorIn.PinIsChanged ||
                FOverColorIn.PinIsChanged ||
                FActiveColorIn.PinIsChanged ||
                FSliderColorIn.PinIsChanged ||
                FSliderSpeedIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    SliderXYGroup group = (SliderXYGroup)FControllerGroups[slice];

                    Matrix4x4 trans;
                    Vector2D  count, size;
                    double    sizeSlider, sliderSpeed;
                    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);

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

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

            for (slice = 0; slice < inputSpreadCount; slice++)
            {
                SliderXYGroup group = (SliderXYGroup)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++)
                {
                    SliderXYGroup group = (SliderXYGroup)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++)
                {
                    SliderXYGroup group  = (SliderXYGroup)FControllerGroups[i];
                    int           pcount = group.FControllers.Length;

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

                        FSetValueIn.GetValue(slice, out val.x);

                        if (val.x >= 0.5)
                        {
                            //update value
                            FValueIn.GetValue2D(slice, out val.x, out val.y);
                            group.UpdateValue((SliderXY)group.FControllers[j], val);

                            valueSet = true;
                        }
                        else if (FFirstframe)
                        {
                            //load from config pin on first frame
                            FInternalValueConfig.GetValue2D(slice, out val.x, out val.y);
                            group.UpdateValue((SliderXY)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++)
            {
                SliderXYGroup group  = (SliderXYGroup)FControllerGroups[i];
                int           pcount = group.FControllers.Length;

                for (int j = 0; j < pcount; j++)
                {
                    SliderXY s = (SliderXY)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.SetValue2D(slice, s.Value.x, s.Value.y);
                    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)
                    {
                        Vector2D val;
                        FInternalValueConfig.GetValue2D(slice, out val.x, out val.y);

                        if (VMath.Abs(s.Value - val) > 0.00000001)
                        {
                            FInternalValueConfig.SetValue2D(slice, s.Value.x, s.Value.y);
                        }
                    }

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }
Beispiel #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 SliderXYGroup());
                }
            }
            else if (diff < 0)
            {
                for (int i = 0; i < -diff; i++)
                {
                    FControllerGroups.RemoveAt(FControllerGroups.Count - 1 - i);
                }
            }

            //update parameters
            int slice;

            if (AnyParameterPinChanged() ||
                FSizeSliderIn.IsChanged ||
                FSliderSpeedIn.IsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    SliderXYGroup group = (SliderXYGroup)FControllerGroups[slice];

                    group.UpdateTransform(FTransformIn[slice], FCountIn[slice], FSizeIn[slice], FSizeSliderIn[slice], FColorIn[slice], FOverColorIn[slice], FActiveColorIn[slice], FSliderColorIn[slice], FSliderSpeedIn[slice]);
                }
            }

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

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

                outcount += group.FControllers.Length;
                FSpreadCountsOut[slice] = group.FControllers.Length;
            }

            //update mouse and colors
            bool valueSet = UpdateMouse <SliderXYGroup, SliderXY>(inputSpreadCount);

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

                    for (int j = 0; j < pcount; j++)
                    {
                        if (FSetValueIn[slice])
                        {
                            group.UpdateValue((SliderXY)group.FControllers[j], FValueIn[slice]);

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

                        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++)
            {
                SliderXYGroup group  = (SliderXYGroup)FControllerGroups[i];
                int           pcount = group.FControllers.Length;

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

                    FTransformOut[slice * 2]     = s.Transform;
                    FTransformOut[slice * 2 + 1] = s.SliderTransform;
                    FColorOut[slice * 2]         = s.CurrentCol;
                    FColorOut[slice * 2 + 1]     = s.ColorSlider;
                    FValueOut[slice]             = s.Value;
                    FMouseOverOut[slice]         = s.GetAndResetMouseOver();
                    FHitOut[slice]    = s.Hit;
                    FActiveOut[slice] = s.Active;

                    //update config pin
                    if (valueSet)
                    {
                        if (VMath.Abs(s.Value - FInternalValueConfig[slice]) > 0.00000001)
                        {
                            FInternalValueConfig[slice] = s.Value;
                        }
                    }

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }