예제 #1
0
        public override void CopyFrom(AbstractMTGui2dController Source)
        {
            base.CopyFrom(Source);
            RotarySlider s = (RotarySlider)Source;

            this.Value      = s.Value;
            SliderTransform = s.SliderTransform;
        }
예제 #2
0
        public override void CopyFrom(BasicGui2dController Source)
        {
            base.CopyFrom(Source);
            RotarySlider s = (RotarySlider)Source;

            this.Value      = s.Value;
            SliderTransform = s.SliderTransform;
            ColorSlider     = s.ColorSlider;
        }
예제 #3
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 RotarySliderGroup());
                }
            }
            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 ||
                FSliderColorIn.PinIsChanged ||
                FSliderSpeedIn.PinIsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RotarySliderGroup group = (RotarySliderGroup)FControllerGroups[slice];

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

                    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);
                    FSliderColorIn.GetColor(slice, out slider);
                    FSliderSpeedIn.GetValue(slice, out sliderSpeed);

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

            //get spread counts
            int outcount = 0;

            FSpreadCountsOut.SliceCount = inputSpreadCount;

            for (slice = 0; slice < inputSpreadCount; slice++)
            {
                RotarySliderGroup group = (RotarySliderGroup)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++)
                {
                    RotarySliderGroup group = (RotarySliderGroup)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++)
                {
                    RotarySliderGroup group = (RotarySliderGroup)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((RotarySlider)group.FControllers[j], val);

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

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

                    FTransformOut.SetMatrix(slice * 2, s.Transform);
                    FTransformOut.SetMatrix(slice * 2 + 1, s.Transform);
                    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.000000001)
                        {
                            FInternalValueConfig.SetValue(slice, s.Value);
                        }
                    }

                    slice++;
                }
            }

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

            //update parameters
            int slice;

            if (AnyParameterPinChanged() ||
                FSliderColorIn.IsChanged ||
                FSliderSpeedIn.IsChanged)
            {
                for (slice = 0; slice < inputSpreadCount; slice++)
                {
                    RotarySliderGroup group = (RotarySliderGroup)FControllerGroups[slice];
                    group.UpdateTransform(FTransformIn[slice], FCountIn[slice], FSizeIn[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++)
            {
                RotarySliderGroup group = (RotarySliderGroup)FControllerGroups[slice];

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

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

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

                    for (int j = 0; j < pcount; j++)
                    {
                        if (FSetValueIn[slice])
                        {
                            //update value
                            group.UpdateValue((RotarySlider)group.FControllers[j], FValueIn[slice]);
                            valueSet = true;
                        }
                        else if (FFirstframe)
                        {
                            //load from config pin on first frame
                            group.UpdateValue((RotarySlider)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++)
            {
                RotarySliderGroup group = (RotarySliderGroup)FControllerGroups[i];
                int pcount = group.FControllers.Length;

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

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

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

                    slice++;
                }
            }

            //end of frame
            FFirstframe = false;
        }