//this method is called by vvvv when the node is created public override void SetPluginHost(IPluginHost Host) { base.SetPluginHost(Host); //create inputs: //value //correct subtype of value pin FValueIn.SetSubType(0, 1, 1, 0, false, true, false); FValueOut.SetSubType(0, 1, 1, 0, false, true, false); }
//this method is called by vvvv when the node is created public override void SetPluginHost(IPluginHost Host) { base.SetPluginHost(Host); //create inputs: //value //correct subtype of value pin FValueIn.SetSubType(0, 1, 0.01, 0, false, false, false); //color FHost.CreateValueInput("Slider Speed", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSliderSpeedIn); FSliderSpeedIn.SetSubType(0, double.MaxValue, 0.01, 0.25, false, false, false); FHost.CreateTransformOutput("Slider Transform", TSliceMode.Dynamic, TPinVisibility.True, out FPinOutSliderTransform); }
//this method is called by vvvv when the node is created public override void SetPluginHost(IPluginHost Host) { base.SetPluginHost(Host); //create inputs: //value //correct subtype of value pin FValueIn.SetSubType(0, 1, 0.01, 0, false, false, false); FInternalValueConfig.SetSubType(0, 1, 0.01, 0, false, false, false); //color FHost.CreateColorInput("Slider Color", TSliceMode.Dynamic, TPinVisibility.True, out FSliderColorIn); FSliderColorIn.SetSubType(new RGBAColor(1, 1, 1, 1), true); FHost.CreateValueInput("Slider Speed", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSliderSpeedIn); FSliderSpeedIn.SetSubType(0, double.MaxValue, 0.01, 0.25, false, false, false); }
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; }
//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); //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 FHost.CreateValueInput("Mouse X", 1, null, TSliceMode.Single, TPinVisibility.True, out FMouseXIn); FMouseXIn.SetSubType(double.MinValue, double.MaxValue, 0.01, 0, false, false, false); FHost.CreateValueInput("Mouse Y", 1, null, TSliceMode.Single, TPinVisibility.True, out FMouseYIn); FMouseYIn.SetSubType(double.MinValue, double.MaxValue, 0.01, 0, false, false, false); FHost.CreateValueInput("Mouse Left", 1, null, TSliceMode.Single, TPinVisibility.True, out FLeftButtonIn); FLeftButtonIn.SetSubType(0, 1, 1, 0, false, true, false); //color FHost.CreateColorInput("Color", TSliceMode.Dynamic, TPinVisibility.True, out FColorIn); FColorIn.SetSubType(new RGBAColor(0.2, 0.2, 0.2, 1), true); FHost.CreateColorInput("Mouse Over Color", TSliceMode.Dynamic, TPinVisibility.True, out FOverColorIn); FOverColorIn.SetSubType(new RGBAColor(0.5, 0.5, 0.5, 1), true); FHost.CreateColorInput("Activated Color", TSliceMode.Dynamic, TPinVisibility.True, out FActiveColorIn); FActiveColorIn.SetSubType(new RGBAColor(1, 1, 1, 1), true); 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.CreateColorInput("Slider Color", TSliceMode.Dynamic, TPinVisibility.True, out FSliderColorIn); FSliderColorIn.SetSubType(new RGBAColor(1, 1, 1, 1), true); 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.CreateColorOutput("Color", TSliceMode.Dynamic, TPinVisibility.True, out FColorOut); FColorOut.SetSubType(new RGBAColor(0.2, 0.2, 0.2, 1), true); 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("Active", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FActiveOut); FActiveOut.SetSubType(0, 1, 1, 0, false, true, false); FHost.CreateValueOutput("Hit", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FHitOut); FHitOut.SetSubType(0, 1, 1, 0, true, false, false); FHost.CreateValueOutput("Mouse Over", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FMouseOverOut); FMouseOverOut.SetSubType(0, 1, 1, 0, false, true, false); FHost.CreateValueOutput("Spread Counts", 1, null, TSliceMode.Dynamic, TPinVisibility.True, out FSpreadCountsOut); FSpreadCountsOut.SetSubType(0, double.MaxValue, 0.01, 0, false, false, true); //create config pin FHost.CreateValueConfig("Internal Value ", 2, null, TSliceMode.Dynamic, TPinVisibility.OnlyInspector, out FInternalValueConfig); FInternalValueConfig.SetSubType2D(0, 1, 0.01, 0, 0, false, false, false); FControllerGroups = new ArrayList(); }
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; }
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; }
//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>(); }