/* private void MotionPlus() { * FPinMotionPlusOutputAccelleration.SliceCount = 1; * * double[] normalizedA = new double[3]; * normalizedA[0] = (double)(FRemote.WiimoteState.MotionPlusState.RawValues.X); * normalizedA[1] = (double)(FRemote.WiimoteState.MotionPlusState.RawValues.Y); * normalizedA[2] = (double)(FRemote.WiimoteState.MotionPlusState.RawValues.Z); * * FPinMotionPlusOutputAccelleration.SetValue3D(0, normalizedA[0], normalizedA[1], normalizedA[2]); * } */ private void Classic() { FPinOutputExtCursor.SliceCount = 1; FPinOutputExtCursor.SetValue(0, FRemote.WiimoteState.ClassicControllerState.ButtonState.Up?1d:0d); FPinOutputExtCursor.SetValue(1, FRemote.WiimoteState.ClassicControllerState.ButtonState.Down?1d:0d); FPinOutputExtCursor.SetValue(2, FRemote.WiimoteState.ClassicControllerState.ButtonState.Left?1d:0d); FPinOutputExtCursor.SetValue(3, FRemote.WiimoteState.ClassicControllerState.ButtonState.Right?1d:0d); FPinOutputExtControls.SliceCount = 1; FPinOutputExtControls.SetValue(0, FRemote.WiimoteState.ClassicControllerState.ButtonState.Plus?1d:0d); FPinOutputExtControls.SetValue(1, FRemote.WiimoteState.ClassicControllerState.ButtonState.Minus?1d:0d); FPinOutputExtControls.SetValue(2, FRemote.WiimoteState.ClassicControllerState.ButtonState.Home?1d:0d); FPinOutputExtControls.SliceCount = 1; FPinOutputExtControls2.SetValue(0, FRemote.WiimoteState.ClassicControllerState.ButtonState.ZL?1d:0d); FPinOutputExtControls2.SetValue(1, FRemote.WiimoteState.ClassicControllerState.ButtonState.ZR?1d:0d); FPinOutputExtControls2.SetValue(3, FRemote.WiimoteState.ClassicControllerState.ButtonState.TriggerL?1d:0d); FPinOutputExtControls2.SetValue(4, FRemote.WiimoteState.ClassicControllerState.ButtonState.TriggerR?1d:0d); FPinOutputExtButtons.SliceCount = 1; FPinOutputExtButtons.SetValue(0, FRemote.WiimoteState.ClassicControllerState.ButtonState.A?1d:0d); FPinOutputExtButtons.SetValue(1, FRemote.WiimoteState.ClassicControllerState.ButtonState.B?1d:0d); FPinOutputExtButtons.SetValue(2, FRemote.WiimoteState.ClassicControllerState.ButtonState.X?1d:0d); FPinOutputExtButtons.SetValue(3, FRemote.WiimoteState.ClassicControllerState.ButtonState.Y?1d:0d); FPinOutputExtJoystickLeft.SliceCount = 1; FPinOutputExtJoystickLeft.SetValue(0, FRemote.WiimoteState.ClassicControllerState.RawJoystickL.X * 2); FPinOutputExtJoystickLeft.SetValue(1, FRemote.WiimoteState.ClassicControllerState.RawJoystickL.Y * 2); FPinOutputExtJoystickRight.SliceCount = 1; FPinOutputExtJoystickRight.SetValue(0, FRemote.WiimoteState.ClassicControllerState.RawJoystickR.X * 2); FPinOutputExtJoystickRight.SetValue(1, FRemote.WiimoteState.ClassicControllerState.RawJoystickR.Y * 2); }
public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); if (FMidiScore == null) { return; } List <TLBaseKeyFrame> activeNotes = new List <TLBaseKeyFrame>(); foreach (TLMidiSlice ms in FOutputSlices) { activeNotes.AddRange(ms.KeyFrames.FindAll(delegate(TLBaseKeyFrame mk) { return(mk.Time <= CurrentTime && CurrentTime < (mk as TLMidiKeyFrame).End); })); } for (int i = 0; i < 128; i++) { TLMidiKeyFrame m = activeNotes.Find(delegate(TLBaseKeyFrame mk) { return((mk as TLMidiKeyFrame).Note == i); }) as TLMidiKeyFrame; if (m == null) { FChannelOut.SetValue(i, 0); FVelocityOut.SetValue(i, 0); } else { FChannelOut.SetValue(i, m.Channel); FVelocityOut.SetValue(i, m.Velocity); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FSkeletonInput.PinIsChanged) { if (FSkeletonInput.IsConnected) { object currInterface; FSkeletonInput.GetUpstreamInterface(out currInterface); inputSkeleton = (Skeleton)currInterface; } else { inputSkeleton = null; } } if (FSkeletonInput.PinIsChanged || FJointNameInput.PinIsChanged) { if (inputSkeleton != null) { string jointName; IJoint currJoint; FParentNameOutput.SliceCount = FJointNameInput.SliceCount; FBaseTransformOutput.SliceCount = FJointNameInput.SliceCount; FAnimationTransformOutput.SliceCount = FJointNameInput.SliceCount; for (int i = 0; i < FJointNameInput.SliceCount; i++) { FJointNameInput.GetString(i, out jointName); if (inputSkeleton.JointTable.ContainsKey(jointName)) { currJoint = (IJoint)inputSkeleton.JointTable[jointName]; if (currJoint.Parent != null) { FParentNameOutput.SetString(i, currJoint.Parent.Name); } else { FParentNameOutput.SetString(i, ""); } FJointIdOutput.SetValue(i, currJoint.Id); FBaseTransformOutput.SetMatrix(i, VMath.Rotate(currJoint.Rotation) * currJoint.BaseTransform); FAnimationTransformOutput.SetMatrix(i, currJoint.AnimationTransform); } else { FJointIdOutput.SetValue(i, -1); FBaseTransformOutput.SetMatrix(i, VMath.IdentityMatrix); FAnimationTransformOutput.SetMatrix(i, VMath.IdentityMatrix); } } } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //compute only on refresh if (FRefresh.PinIsChanged) { System.Windows.Forms.Screen [] screens = System.Windows.Forms.Screen.AllScreens; //set slicecount FResolutionOutput.SliceCount = screens.Length; FResolutionOffsetOutput.SliceCount = screens.Length; FWorkAreaOutput.SliceCount = screens.Length; FWorkAreaOffsetOutput.SliceCount = screens.Length; FBitsPerPixel.SliceCount = screens.Length; FDeviceName.SliceCount = screens.Length; FIsPrimary.SliceCount = screens.Length; //loop for all slices for (int i = 0; i <= screens.GetUpperBound(0); i++) { //write data to outputs FResolutionOutput.SetValue2D(i, screens[i].Bounds.Width, screens[i].Bounds.Height); FResolutionOffsetOutput.SetValue2D(i, screens[i].Bounds.Left, screens[i].Bounds.Top); FWorkAreaOutput.SetValue2D(i, screens[i].WorkingArea.Width, screens[i].WorkingArea.Height); FWorkAreaOffsetOutput.SetValue2D(i, screens[i].WorkingArea.Left, screens[i].WorkingArea.Top); FBitsPerPixel.SetValue(i, (double)screens[i].BitsPerPixel); FDeviceName.SetString(i, screens[i].DeviceName); FIsPrimary.SetValue(i, (double)screens[i].Primary.GetHashCode()); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FMyValueInput.PinIsChanged) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FMyValueOutput.SliceCount = SpreadMax; //the variables to fill with the input data double currentValueSlice; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FMyValueInput.GetValue(i, out currentValueSlice); //your function per slice //write data to outputs FMyValueOutput.SetValue(i, currentValueSlice); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FValueInput.PinIsChanged || FDigitInput.PinIsChanged) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FValueOutput.SliceCount = SpreadMax; //the variables to fill with the input data double currentValueSlice; double currentDigitSlice; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FValueInput.GetValue(i, out currentValueSlice); FDigitInput.GetValue(i, out currentDigitSlice); FValueOutput.SetValue(i, Math.Round(currentValueSlice, (int)Math.Round(currentDigitSlice))); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FMyValueInputX.PinIsChanged | FMyValueInputY.PinIsChanged) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FMyValueOutputX.SliceCount = SpreadMax; FMyValueOutputY.SliceCount = SpreadMax; FMyValueOutputZ.SliceCount = SpreadMax; //the variables to fill with the input data double currentValueSliceX; double currentValueSliceY; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FMyValueInputX.GetValue(i, out currentValueSliceX); FMyValueInputY.GetValue(i, out currentValueSliceY); //write data to outputs FMyValueOutputX.SetValue(i, 2 * currentValueSliceX / (1 + currentValueSliceX * currentValueSliceX + currentValueSliceY * currentValueSliceY)); FMyValueOutputY.SetValue(i, 2 * currentValueSliceY / (1 + currentValueSliceX * currentValueSliceX + currentValueSliceY * currentValueSliceY)); FMyValueOutputZ.SetValue(i, (-1 + currentValueSliceX * currentValueSliceX + currentValueSliceY * currentValueSliceY) / (1 + currentValueSliceX * currentValueSliceX + currentValueSliceY * currentValueSliceY)); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //the variables to fill with the input data // speed vector double currentValueSliceV1; double currentValueSliceV2; if (FValueInputDeltaT.PinIsChanged) { FValueInputDeltaT.GetValue(0, out deltaT); } if (FValueInputU.PinIsChanged) { FValueInputU.GetValue(0, out U); } //if any of the inputs has changed //recompute the outputs if (FValueInputX.PinIsChanged || FValueInputY.PinIsChanged) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FValueOutputX.SliceCount = SpreadMax; FValueOutputY.SliceCount = SpreadMax; previousValueSliceX = new double[SpreadMax]; previousValueSliceY = new double[SpreadMax]; for (int i = 0; i < SpreadMax; i++) { //read data from inputs FValueInputX.GetValue(i, out previousValueSliceX[i]); FValueInputY.GetValue(i, out previousValueSliceY[i]); } } //loop for all slices for (int i = 0; i < SpreadMax; i++) { //compute Ikeda map double t = 0.4 - 6 / (previousValueSliceX[i] * previousValueSliceX[i] + previousValueSliceX[i] * previousValueSliceY[i] + 1); currentValueSliceV1 = 1 + U * (previousValueSliceX[i] * Math.Cos(t) - previousValueSliceY[i] * Math.Sin(t)); currentValueSliceV2 = U * (previousValueSliceX[i] * Math.Cos(t) + previousValueSliceY[i] * Math.Sin(t)); currentValueSliceV1 *= deltaT; currentValueSliceV2 *= deltaT; //update values previousValueSliceX[i] = previousValueSliceX[i] + currentValueSliceV1; previousValueSliceY[i] = previousValueSliceY[i] + currentValueSliceV2; //write data to outputs FValueOutputX.SetValue(i, previousValueSliceX[i]); FValueOutputY.SetValue(i, previousValueSliceY[i]); } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { if (FInput.PinIsChanged || FGamma.PinIsChanged || FBinSize.PinIsChanged) { double curIn, curGamma, tmpBin; int curBin; ArrayList outList = new ArrayList(); ArrayList curList; for (int i = 0; i < SpreadMax; i++) { FInput.GetValue(i, out curIn); FGamma.GetValue(i, out curGamma); FBinSize.GetValue(i, out tmpBin); curBin = (int)Math.Round(tmpBin); curList = new ArrayList(curBin); for (int j = 0; j < curBin; j++) { double start = j / (double)curBin / curGamma; double end = (curBin - 1.0) / (double)curBin / curGamma; end = start + 1.0 - end; curList.Add(VMath.Map(curIn, start, end, 0.0, 1.0, TMapMode.Clamp)); } outList.AddRange(curList); } FOut.SliceCount = outList.Count; for (int i = 0; i < outList.Count; i++) { FOut.SetValue(i, (double)outList[i]); } } }
public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); if (CurrentState == null) { return; } FCurrentStateOut.SetString(0, CurrentState.Name); var stateCount = (FOutputSlices[0] as TLAutomataSlice).KeyFrames.Count - 1; FStateTimes.SliceCount = stateCount; for (int i = 0; i < (FOutputSlices[0] as TLAutomataSlice).KeyFrames.Count - 1; i++) { FStateTimes.SetValue(i, (FOutputSlices[0] as TLAutomataSlice).KeyFrames[i].Time); } FStates.SliceCount = stateCount; for (int i = 0; i < (FOutputSlices[0] as TLAutomataSlice).KeyFrames.Count - 1; i++) { FStates.SetString(i, ((FOutputSlices[0] as TLAutomataSlice).KeyFrames[i] as TLStateKeyFrame).Name); } }
public override void Evaluate(double CurrentTime) { base.Evaluate(CurrentTime); for (int i = 0; i < FOutputSlices.Count; i++) { FValueOut.SetValue(i, (FOutputSlices[i] as TLValueSlice).Output); } }
private void BalanceBoard() { FPinOutputExtButtons.SetValue(0, FRemote.WiimoteState.BalanceBoardState.WeightKg); FPinOutputExtAccelleration.SliceCount = 4; FPinOutputExtAccelleration.SetValue(0, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopLeft); FPinOutputExtAccelleration.SetValue(1, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopRight); FPinOutputExtAccelleration.SetValue(2, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft); FPinOutputExtAccelleration.SetValue(3, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomRight); //FPinOutputExtAccelleration.SliceCount = 1; //FPinOutputExtAccelleration.SetValue4D(0, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopLeft, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.TopRight, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomLeft, FRemote.WiimoteState.BalanceBoardState.SensorValuesKg.BottomRight); FPinOutputExtJoystickLeft.SliceCount = 1; FPinOutputExtJoystickLeft.SetValue2D(0, FRemote.WiimoteState.BalanceBoardState.CenterOfGravity.X * 2, FRemote.WiimoteState.BalanceBoardState.CenterOfGravity.Y * 2); }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FPositionInput.PinIsChanged || FVectorSizeInput.PinIsChanged || FV010Input.PinIsChanged || FV110Input.PinIsChanged || FV100Input.PinIsChanged || FV000Input.PinIsChanged || FV011Input.PinIsChanged || FV111Input.PinIsChanged || FV101Input.PinIsChanged || FV001Input.PinIsChanged) { //get vector size double vs; FVectorSizeInput.GetValue(0, out vs); int vectorSize = (int)vs; SpreadMax = Math.Max(SpreadMax, FPositionInput.SliceCount * vectorSize); //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FPositionOutput.SliceCount = SpreadMax; //the variables to fill with the input data Vector3D vectorSlice; double V010Slice; double V110Slice; double V100Slice; double V000Slice; double V011Slice; double V111Slice; double V101Slice; double V001Slice; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FPositionInput.GetValue3D(i / vectorSize, out vectorSlice.x, out vectorSlice.y, out vectorSlice.z); FV010Input.GetValue(i, out V010Slice); FV110Input.GetValue(i, out V110Slice); FV100Input.GetValue(i, out V100Slice); FV000Input.GetValue(i, out V000Slice); FV011Input.GetValue(i, out V011Slice); FV111Input.GetValue(i, out V111Slice); FV101Input.GetValue(i, out V101Slice); FV001Input.GetValue(i, out V001Slice); //function per slice V000Slice = VMath.Trilerp(vectorSlice, V010Slice, V110Slice, V100Slice, V000Slice, V011Slice, V111Slice, V101Slice, V001Slice); //write data to outputs FPositionOutput.SetValue(i, V000Slice); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { FPositionPin.SetValue3D(0, FSensor.Translation.X, FSensor.Translation.Y, FSensor.Translation.Z); FRotationPin.SetValue3D(0, FSensor.Rotation.X, FSensor.Rotation.Y, FSensor.Rotation.Z); FAnglePin.SetValue(0, FSensor.Rotation.Angle); for (int i = 0; i < FKeyboard.Keys; i++) { if (FKeyboard.IsKeyDown(i + 1)) { FKeyboardPin.SetValue(i, 1); } else { FKeyboardPin.SetValue(i, 0); } } FDeviceTypePin.SetValue(0, FDeviceType); }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { double Enable; FEnable.GetValue(0, out Enable); //if any of the inputs has changed //recompute the outputs if (FEnable.PinIsChanged) { if (Enable == 1) { m_PhidgetManager.Enable(); } else { m_PhidgetManager.Disable(); } } if (Enable == 1 || FEnable.PinIsChanged) { int SliceCount = m_PhidgetManager.Devices.Count; FLibraryVersion.SliceCount = 1; FLibraryVersion.SetString(0, m_PhidgetManager.LibaryVersion); FDevice.SliceCount = SliceCount; FSerial.SliceCount = SliceCount; FVersion.SliceCount = SliceCount; for (int i = 0; i <= SliceCount; i++) { FDevice.SetString(i, m_PhidgetManager.Devices.ToArray()[i].Name); FSerial.SetValue(i, m_PhidgetManager.Devices.ToArray()[i].SerialNumber); FVersion.SetValue(i, m_PhidgetManager.Devices.ToArray()[i].Version); } } else if (Enable == 0 || FEnable.PinIsChanged) { //int SliceCount = 1; //FDevice.SliceCount = SliceCount; //FSerial.SliceCount = SliceCount; //FVersion.SliceCount = SliceCount; //FDevice.SetString(0, ""); //FSerial.SetValue(0, -1); //FVersion.SetValue(0, -1); } else { } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FirstValue.PinIsChanged || SecondValue.PinIsChanged || SpreadCount.PinIsChanged) { double currentSpreadCount; double outSpreadCount = 0; double firstValue, secondValue; //for (int k = 0; k < SpreadCount.SliceCount; k++) for (int k = 0; k < SpreadMax; k++) { FirstValue.GetValue(k, out firstValue); SecondValue.GetValue(k, out secondValue); SpreadCount.GetValue(k, out currentSpreadCount); currentSpreadCount = Math.Max(1, currentSpreadCount); outSpreadCount += currentSpreadCount; FMyValueOutput.SliceCount = (int)outSpreadCount; double[] f = new double[(int)currentSpreadCount]; f[0] = firstValue; FMyValueOutput.SetValue(0, f[0]); f[1] = secondValue; FMyValueOutput.SetValue(1, f[1]); for (int i = 2; i < currentSpreadCount; i++) { f[i] = f[i - 1] + f[i - 2]; FMyValueOutput.SetValue(i, f[i]); } } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { if (FSpeedInput.PinIsChanged || FNarratorInput.PinIsChanged || FStringInput.PinIsChanged) { //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs double rate = 5.0; FSpeedInput.GetValue(i, out rate); vox.Rate = (int)rate; int voiceindex = 0; FNarratorInput.GetOrd(i, out voiceindex); vox.Voice = vox.GetVoices(string.Empty, string.Empty).Item(voiceindex); FStringInput.GetString(i, out input_string); } } if (FSpeakInput.PinIsChanged) { double speak = 0.0; FSpeakInput.GetValue(0, out speak); if (speak > 0.5) { vox.Speak(input_string, SpeechVoiceSpeakFlags.SVSFlagsAsync | SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak); } } //remember that we are running with autoevaluate == true if (done == true) //endstream was fired { done = false; FDoneOutput.SetValue(0, 1.0); } else { FDoneOutput.SetValue(0, 0.0); } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { int diff = FStart.Count - SpreadMax; if (diff > 0) { FStart.RemoveRange(SpreadMax, diff); } for (int i = 0; i > diff; i--) { FStart.Add(DateTime.Now); } FOutput.SliceCount = SpreadMax; FRunning.SliceCount = SpreadMax; FActive.SliceCount = SpreadMax; double curSet, curReset, curTime, curActive, curRunning, curOut; for (int i = 0; i < SpreadMax; i++) { curActive = 0; curRunning = 0; curOut = 0; FReset.GetValue(i, out curReset); FSet.GetValue(i, out curSet); if (curSet < 0.5 || curReset > 0.5) { FStart[i] = DateTime.Now; } else { curActive = 1; FTime.GetValue(i, out curTime); TimeSpan span = DateTime.Now - FStart[i]; double elapsed = ((double)span.TotalMilliseconds / 1000.0); curRunning = Math.Min(elapsed / curTime, 1.0); if (elapsed >= curTime) { curOut = 1; } } FOutput.SetValue(i, curOut); FRunning.SetValue(i, curRunning); FActive.SetValue(i, curActive); } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { double Enable = 0; FSerial.GetValue(0, out m_Serial); FEnable.GetValue(0, out Enable); if (FEnable.PinIsChanged || FSerial.PinIsChanged) { if (Enable == 1) { m_CTouchData.Enable(m_Serial); } else { m_CTouchData.Close(); } } if (true) { FPress.SliceCount = 1; FPosition.SliceCount = 1; FPosition.SetValue(0, m_CTouchData.Position); if (FSensitivity.PinIsChanged) { double Sense; FSensitivity.GetValue(0, out Sense); m_CTouchData.SetSense(Sense); } for (int i = 0; i < m_CTouchData.Press.Length; i++) { FPress.SliceCount = m_CTouchData.Press.Length; FPress.SetValue(i, m_CTouchData.Press[i]); } FInfo.SliceCount = m_CTouchData.Info.Length; for (int i = 0; i < m_CTouchData.Info.Length; i++) { FInfo.SetString(i, m_CTouchData.Info[i]); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FInput.PinIsChanged || FVecSize.PinIsChanged || FBinSize.PinIsChanged) { double tmpVec; FVecSize.GetValue(0, out tmpVec); int vecSize = (int)Math.Round(tmpVec); VecBin spread = new VecBin(FInput, FBinSize, vecSize); List <double> outSpread = new List <double>(); // List<double> binId = new List<double>(); for (int i = 0; i < spread.BinCount; i++) { List <double> curBin = new List <double>(spread.GetBin(i)); int binCount = (int)(curBin.Count / (double)vecSize); for (int b = 0; b < Math.Pow(binCount, (double)vecSize); b++) { for (int v = 0; v < vecSize; v++) { int id = (int)Math.Floor(b / Math.Pow(binCount, v)); id = id % binCount; id *= vecSize; id += v; outSpread.Add(curBin[id]); } } } FOut.SliceCount = outSpread.Count; for (int i = 0; i < outSpread.Count; i++) { FOut.SetValue(i, outSpread[i]); } // FBinId.SliceCount=binId.Count; // for (int i=0; i<binId.Count; i++) // { // FBinId.SetValue(i, binId[i]); // } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FPositionInput.PinIsChanged || FVectorSizeInput.PinIsChanged || FP1Input.PinIsChanged || FP2Input.PinIsChanged || FP3Input.PinIsChanged || FP4Input.PinIsChanged) { //get vector size double vs; FVectorSizeInput.GetValue(0, out vs); int vectorSize = (int)vs; SpreadMax = Math.Max(SpreadMax, FPositionInput.SliceCount * vectorSize); //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FValueOutput.SliceCount = SpreadMax; //the variables to fill with the input data Vector2D vectorSlice; double p1Slice; double p2Slice; double p3Slice; double p4Slice; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FPositionInput.GetValue2D(i / vectorSize, out vectorSlice.x, out vectorSlice.y); FP1Input.GetValue(i, out p1Slice); FP2Input.GetValue(i, out p2Slice); FP3Input.GetValue(i, out p3Slice); FP4Input.GetValue(i, out p4Slice); //function per slice p1Slice = VMath.Bilerp(vectorSlice, p1Slice, p2Slice, p3Slice, p4Slice); //write data to outputs FValueOutput.SetValue(i, p1Slice); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FDistortion.PinIsChanged || FFocalLength.PinIsChanged || FPrincipalPoint.PinIsChanged || FResolution.PinIsChanged) { //get the distortion values FDistortion.GetValue4D(0, out FDist.x, out FDist.y, out FDist.z, out FDist.w); FFocalLength.GetValue2D(0, out FFocal.x, out FFocal.y); FPrincipalPoint.GetValue2D(0, out FPrincipal.x, out FPrincipal.y); FResolution.GetValue2D(0, out FReso.x, out FReso.y); } //set slicecounts for output //here its the same as the input SpreadMax = FInput.SliceCount; FOutput.SliceCount = SpreadMax; FTries.SliceCount = SpreadMax; //the variable to fill with the input data Vector2D currentPosition; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FInput.GetValue2D(i, out currentPosition.x, out currentPosition.y); int tries; //function per slice currentPosition = Undistort(currentPosition, FFocal, FPrincipal, FDist, FReso, out tries); //write data to outputs FOutput.SetValue2D(i, currentPosition.x, currentPosition.y); FTries.SetValue(i, tries); } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FSource.PinIsChanged || FDestination.PinIsChanged || FDo.PinIsChanged) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FDone.SliceCount = SpreadMax; //the variables to fill with the input data double curDo; string curSource, curDest; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FSource.GetString(i, out curSource); FDestination.GetString(i, out curDest); FDo.GetValue(i, out curDo); double curDone = 0; if (curDo == 1) { IWshShell wsh = new WshShellClass(); IWshShortcut curShortcut = (IWshShortcut)wsh.CreateShortcut(curDest + ".lnk"); curShortcut.WindowStyle = 1; //for default window, 3 for maximize, 7 for minimize curShortcut.TargetPath = curSource; //for me, or any valid Path string curShortcut.Save(); curDone = 1; } //write data to outputs FDone.SetValue(i, curDone); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { if (FMyValueInputX.PinIsChanged || FMyValueInputY.PinIsChanged || FMyValueInputZ.PinIsChanged) { //the variables to fill with the input data double x, y, z, w; FMyValueOutputX.SliceCount = SpreadMax; FMyValueOutputY.SliceCount = SpreadMax; FMyValueOutputZ.SliceCount = SpreadMax; FMyValueOutputW.SliceCount = SpreadMax; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read data from inputs FMyValueInputX.GetValue(i, out x); FMyValueInputY.GetValue(i, out y); FMyValueInputZ.GetValue(i, out z); // If q = A*(x*i+y*j+z*k) where (x,y,z) is unit length, then // exp(q) = cos(A)+sin(A)*(x*i+y*j+z*k). If sin(A) is near zero, // use exp(q) = cos(A)+A*(x*i+y*j+z*k) since A/sin(A) has limit 1. w = Math.Sqrt(x * x + y * y + z * z); if (Math.Sin(w) < epsilon || Math.Sin(w) > epsilon) { x *= Math.Sin(w) / w; y *= Math.Sin(w) / w; z *= Math.Sin(w) / w; } //write data to outputs FMyValueOutputX.SetValue(i, x); FMyValueOutputY.SetValue(i, y); FMyValueOutputZ.SetValue(i, z); FMyValueOutputW.SetValue(i, Math.Cos(w)); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FPositionInput.PinIsChanged || FOctavesInput.PinIsChanged || FFrequencyInput.PinIsChanged || FPersistanceInput.PinIsChanged) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FOutput.SliceCount = SpreadMax; double octaves, freq, pers; FOctavesInput.GetValue(0, out octaves); FFrequencyInput.GetValue(0, out freq); FPersistanceInput.GetValue(0, out pers); //the variable to fill with the input position Vector4D pos; //loop for all slices for (int i = 0; i < SpreadMax; i++) { //read position from inputs FPositionInput.GetValue4D(i, out pos.x, out pos.y, out pos.z, out pos.w); //noise function per slice double noiseVal = 0; for (int o = 0; o <= (int)octaves; o++) { double comul = Math.Pow(freq, o); noiseVal += SimplexNoise.noise(pos.x * comul, pos.y * comul, pos.z * comul, pos.w * comul) * Math.Pow(pers, o); } //write data to outputs FOutput.SetValue(i, noiseVal); } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //first set slicecounts for all outputs //the incoming int SpreadMax is the maximum slicecount of all input pins, which is a good default FBatteryStateOut.SliceCount = 1; FPowerStateOut.SliceCount = 1; FPowerMessage.SliceCount = 1; int currentValueSlice = 0; string currentStringSlice = "hallo"; string batteryStatus = "nix los hier"; //function PowerStatus power = SystemInformation.PowerStatus; currentValueSlice = (int)(power.BatteryLifePercent * 100); batteryStatus = power.BatteryChargeStatus.ToString(); switch (power.PowerLineStatus) { case PowerLineStatus.Online: currentStringSlice = "Main"; break; case PowerLineStatus.Offline: currentStringSlice = "Battery"; break; case PowerLineStatus.Unknown: Console.WriteLine("Unknown"); break; } //write data to outputs FBatteryStateOut.SetValue(0, currentValueSlice); FPowerStateOut.SetString(0, currentStringSlice); FPowerMessage.SetString(0, batteryStatus); }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FMyValueInputM.PinIsChanged || FMyValueInputN.PinIsChanged || FMyValuePhaseM.PinIsChanged || FMyValuePhaseN.PinIsChanged) { double m, n; FMyValueInputM.GetValue(0, out m); FMyValueInputN.GetValue(0, out n); double phaseM, phaseN; FMyValuePhaseM.GetValue(0, out phaseM); FMyValuePhaseN.GetValue(0, out phaseN); int index; int sliceCount = (int)(m * n); FMyValueOutputX.SliceCount = sliceCount; FMyValueOutputY.SliceCount = sliceCount; FMyValueOutputIsPrime.SliceCount = sliceCount; for (int j = 0; j < n; j++) { for (int i = 0; i < m; i++) { index = (int)(m * j + i); //write data to outputs double x = Convert.ToDouble(i) - Convert.ToDouble(j) / 2; double y = Convert.ToDouble(j) * Math.Sqrt(3) / 2; FMyValueOutputX.SetValue(index, x); FMyValueOutputY.SetValue(index, y); FMyValueOutputIsPrime.SetValue(index, isprime(i + Convert.ToInt32(phaseM), j + Convert.ToInt32(phaseN))); } } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { double Enable; double Serial; //FConnected.SliceCount = 1; FSerial.GetValue(0, out Serial); FEnable.GetValue(0, out Enable); try { if (FSerial.PinIsChanged || FEnable.PinIsChanged) { if (FSerial.PinIsChanged) { if (m_IKitData != null) { m_IKitData.Close(); m_IKitData = null; } } if (Enable > 0.5) { if (m_IKitData == null) { m_IKitData = new GetEncoderHSData(); m_IKitData.Open(Serial); } } else { if (m_IKitData != null) { FInfo.SliceCount = 1; FInfo.SetString(0, "Disabled"); m_IKitData.Close(); m_IKitData = null; } } } } catch (Exception ex) { FHost.Log(TLogType.Error, "Error by initialising Phidget"); FHost.Log(TLogType.Error, ex.Message.ToString()); } if (Enable == 1 && m_IKitData.Attached) { // int SliceCountAnalogIn = m_IKitData.InfoDevice.ToArray()[0].EncoderInputs; try { try { //getting Encoder Position if (m_IKitData.InfoDevice.ToArray()[0].EncoderInputs != 0) { FPositionOut.SliceCount = SliceCountAnalogIn; for (int i = 0; i < SliceCountAnalogIn; i++) { FPositionOut.SetValue(i, m_IKitData.EncoderInputs[i]); } } } catch (Exception ex) { FHost.Log(TLogType.Error, "Error in " + m_IKitData.InfoDevice.ToArray()[0].Name + " getting encoder Position"); FHost.Log(TLogType.Error, ex.Message.ToString()); } try { // set Position if (FSetPosition.PinIsChanged) { double setPosition; FSetPosition.GetValue(0, out setPosition); if (setPosition > 0.5) { double SliceCountSense = FPositionIn.SliceCount; double[] tPosition = new double[SliceCountAnalogIn]; for (int i = 0; i < SliceCountAnalogIn; i++) { double sense; FPositionIn.GetValue(i, out sense); tPosition[i] = sense; } m_IKitData.SetPosition(tPosition); } } } catch (Exception ex) { FHost.Log(TLogType.Error, "Error in " + m_IKitData.InfoDevice.ToArray()[0].Name + " setting encoder Position"); FHost.Log(TLogType.Error, ex.Message.ToString()); } //setting Phidget Infos try { int SpreadSizeInfo = 3; for (int i = 0; i < SpreadSizeInfo; i++) { FInfo.SliceCount = 3; switch (i) { case 0: FInfo.SetString(i, "Name: " + m_IKitData.InfoDevice.ToArray()[0].Name); break; case 1: FInfo.SetString(i, "Serial: " + m_IKitData.InfoDevice.ToArray()[0].SerialNumber.ToString()); break; case 2: FInfo.SetString(i, "Version: " + m_IKitData.InfoDevice.ToArray()[0].Version.ToString()); break; } } } catch (Exception ex) { FHost.Log(TLogType.Error, "Error in Phidget " + m_IKitData.InfoDevice.ToArray()[0].Name + " setting Phidget Infos"); FHost.Log(TLogType.Error, ex.Message.ToString()); } } catch (Exception ex) { FHost.Log(TLogType.Error, "Error in Phidget " + m_IKitData.InfoDevice.ToArray()[0].Name); FHost.Log(TLogType.Error, ex.Message.ToString()); } } }
public void Evaluate(int SpreadMax) { //calc input spreadcount int inputSpreadCount = SpreadMax; //create or delete systems int diff = inputSpreadCount - FParticleSystemsList.Count; if (diff > 0) { for (int i = 0; i < diff; i++) { FParticleSystemsList.Add(new ParticleSystem()); } } else if (diff < 0) { for (int i = 0; i < -diff; i++) { FParticleSystemsList.RemoveAt(FParticleSystemsList.Count - 1 - i); } } //update 3D parameters int slice; if (FInitPositionsIn.PinIsChanged || FVelDirectionIn.PinIsChanged || FVelDeviationIn.PinIsChanged || FAccDirectionIn.PinIsChanged || FAccDeviationIn.PinIsChanged) { for (slice = 0; slice < inputSpreadCount; slice++) { ParticleSystem ps = (ParticleSystem)FParticleSystemsList[slice]; double x, y, z; //update origins FInitPositionsIn.GetValue3D(slice, out x, out y, out z); ps.origin = new Vector3D(x, y, z); //update directions FVelDirectionIn.GetValue3D(slice, out x, out y, out z); ps.direction = new Vector3D(x, y, z); //update deviation FVelDeviationIn.GetValue3D(slice, out x, out y, out z); ps.deviation = new Vector3D(x, y, z); //update acceleration deviation FAccDirectionIn.GetValue3D(slice, out x, out y, out z); ps.accDirection = new Vector3D(x, y, z); //update acceleration deviation FAccDeviationIn.GetValue3D(slice, out x, out y, out z); ps.accDeviation = new Vector3D(x, y, z); } } //update single parameters if (FMassIn.PinIsChanged || FMassDeviationIn.PinIsChanged || FLifetimeIn.PinIsChanged || FLifetimeDeviationIn.PinIsChanged || FIsInfluencedIn.PinIsChanged || FInfluenceIn.PinIsChanged || FInfluenceAmountIn.PinIsChanged || FdtIn.PinIsChanged) { for (slice = 0; slice < inputSpreadCount; slice++) { ParticleSystem ps = (ParticleSystem)FParticleSystemsList[slice]; double mass, massDeviation; double lifetimeIn, lifetimeDeviation; double isInfluenced, influenceAmount, influences; double dt; FMassIn.GetValue(slice, out mass); FMassDeviationIn.GetValue(slice, out massDeviation); FLifetimeIn.GetValue(slice, out lifetimeIn); FLifetimeDeviationIn.GetValue(slice, out lifetimeDeviation); FIsInfluencedIn.GetValue(slice, out isInfluenced); FInfluenceAmountIn.GetValue(slice, out influenceAmount); FInfluenceIn.GetValue(slice, out influences); FdtIn.GetValue(slice, out dt); ps.mass = mass; ps.massDeviation = massDeviation; ps.lifetime = lifetimeIn; ps.lifetimeDeviation = lifetimeDeviation; ps.influences = (influences >= 0.5); ps.isInfluenced = (isInfluenced >= 0.5); ps.influenceAmount = influenceAmount; ps.dt = dt; } } //force calculation UpdateForce(); // Cycle through all particle systems, run them and get particle counts FSpreadCountsOut.SliceCount = FParticleSystemsList.Count; int outcount = 0; slice = 0; for (slice = 0; slice < inputSpreadCount; slice++) { ParticleSystem ps = (ParticleSystem)FParticleSystemsList[slice]; //add new particle ? double emit; FEmitIn.GetValue(slice, out emit); if (emit >= 0.5) { ps.addParticle(); } //update system double time; FHost.GetCurrentTime(out time); ps.run(0.1); FLastTime = time; //check particle count outcount += ps.particles.Count; FSpreadCountsOut.SetValue(slice, ps.particles.Count); } //write output to pins FPosOut.SliceCount = outcount; FAgeOut.SliceCount = outcount; FHeadingOut.SliceCount = outcount; slice = 0; for (int i = 0; i < inputSpreadCount; i++) { ParticleSystem ps = (ParticleSystem)FParticleSystemsList[i]; int pcount = ps.particles.Count; for (int j = 0; j < pcount; j++) { Particle p = (Particle)ps.particles[j]; FPosOut.SetValue3D(slice, p.loc.x, p.loc.y, p.loc.z); FHeadingOut.SetValue3D(slice, p.vel.x, p.vel.y, p.vel.z); FAgeOut.SetValue(slice, 1 - p.age()); slice++; } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { double pinInputEnable, pinInputDigitizing; FPinInputEnable.GetValue(0, out pinInputEnable); FPinInputDigitizing.GetValue(0, out pinInputDigitizing); if (FPinInputEnable.PinIsChanged) { if (pinInputEnable == 1d) { Enable(); } else { Disable(); } } if (Tablet == null) { return; } if (FPinInputDigitizing.PinIsChanged) { digitizing = (pinInputDigitizing == 1d); if (pinInputEnable == 1d) { Disable(); } Disconnect(); Connect(); if (pinInputEnable == 1d) { Enable(); } } if ((pinInputEnable == 1d)) { FPinOutputProximity.SetValue(0, InContext ? 1 : 0); FPinOutputX.SetValue(0, X); FPinOutputY.SetValue(0, Y); FPinOutputPressure.SetValue(0, NormalPressure); FPinOutputCursor.SetValue(0, CursorNum); FPinOutputSerialNo.SetValue(0, SerialNo); FPinOutputCursorType.SetValue(0, CursorType); FPinOutputCursorSubtype.SetValue(0, CursorSubtype); FPinOutputButtons.SliceCount = NumButtons; for (int i = 0; i < NumButtons; i++) { FPinOutputButtons.SetValue(i, ((Buttons & (1 << i)) != 0) ? 1 : 0); } FPinOutputAzimuth.SetValue(0, Azimuth); FPinOutputTilt.SetValue(0, Tilt); if (FPinDebugButtons != null) { FPinDebugButtons.SetValue(0, NumButtons); } FPinOutputDimensions.SliceCount = 2; FPinOutputDimensions.SetValue(0, Tablet.Context.InputExtentX); FPinOutputDimensions.SetValue(1, Tablet.Context.InputExtentY); FPinOutputCursorName.SetString(0, CursorName); } }