//called when data for any output pin is requested public void Evaluate(int spreadMax) { int xyzCount, wCount; double *xyzData, wData, outData; Fxyz.GetValuePointer(out xyzCount, out xyzData); FSingle.GetValuePointer(out wCount, out wData); if (xyzCount == 0 || wCount == 0) { spreadMax = 0; } else { spreadMax = (int)Math.Ceiling((double)xyzCount / 3); spreadMax = Math.Max(spreadMax, wCount); } FOutPin.SliceCount = spreadMax; FOutPin.GetValuePointer(out outData); var comp0 = component[0]; var comp1 = component[1]; var comp2 = component[2]; var comp3 = component[3]; for (int i = 0; i < spreadMax; i++) { outData[(i * 4 + comp0)] = xyzData[(i * 3 + 0) % xyzCount]; outData[(i * 4 + comp1)] = xyzData[(i * 3 + 1) % xyzCount]; outData[(i * 4 + comp2)] = xyzData[(i * 3 + 2) % xyzCount]; outData[(i * 4 + comp3)] = wData[(i) % wCount]; } }
//called when data for any output pin is requested public void Evaluate(int spreadMax) { int inCount; double *xyzData, wData, inData; FInPin.GetValuePointer(out inCount, out inData); spreadMax = (int)Math.Ceiling((double)inCount / 4); Fxyz.SliceCount = spreadMax; Fxyz.GetValuePointer(out xyzData); FSingle.SliceCount = spreadMax; FSingle.GetValuePointer(out wData); var comp0 = component[0]; var comp1 = component[1]; var comp2 = component[2]; var comp3 = component[3]; for (int i = 0; i < spreadMax; i++) { xyzData[(i * 3 + 0)] = inData[(i * 4 + comp0) % inCount]; xyzData[(i * 3 + 1)] = inData[(i * 4 + comp1) % inCount]; xyzData[(i * 3 + 2)] = inData[(i * 4 + comp2) % inCount]; wData[(i)] = inData[(i * 4 + comp3) % inCount]; } }
public ValueOutput(IValueOut pin) { FPin = pin; pin.GetValuePointer(out dataptr); }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public unsafe void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FIn.PinIsChanged || FVectorSize.PinIsChanged || FBinSize.PinIsChanged) { double *inVals; int inC; FIn.GetValuePointer(out inC, out inVals); double tmpVec; FVectorSize.GetValue(0, out tmpVec); int vecSize = Math.Max((int)Math.Round(tmpVec), 1); int vecMax = (int)Math.Ceiling(inC / (decimal)vecSize); double firstBin; FBinSize.GetValue(0, out firstBin); int total = 0; List <int> binList = new List <int>(); if (!(FBinSize.SliceCount == 1 && firstBin == 0)) { int binIncr = 0; bool end = false; while (!end) { double tmpBin; FBinSize.GetValue(binIncr, out tmpBin); int curBin = (int)Math.Round(tmpBin); if (curBin < 0) { curBin = vecMax / Math.Abs(curBin); } binList.Add(curBin); binIncr++; total += curBin; if (binIncr % FBinSize.SliceCount == 0 && total >= vecMax) { end = true; } } } FOut.SliceCount = vecMax * vecSize; double *outVals; FOut.GetValuePointer(out outVals); int outIncr = 0; foreach (int b in binList) { for (int i = 0; i < b * vecSize; i++) { int prev = i - vecSize; int next = i + vecSize; if (prev < 0) { outVals[i + outIncr] = (inVals[(outIncr + next) % inC] - inVals[(i + outIncr) % inC]); } else if (next >= b * vecSize) { outVals[i + outIncr] = (inVals[(i + outIncr) % inC] - inVals[(outIncr + prev) % inC]); } else { outVals[i + outIncr] = (inVals[(outIncr + next) % inC] - inVals[(i + outIncr) % inC]) / 2; outVals[i + outIncr] += (inVals[(i + outIncr) % inC] - inVals[(outIncr + prev) % inC]) / 2; } } outIncr += b * vecSize; } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public void Evaluate(int SpreadMax) { if (FSwitch.PinIsChanged || FEvaluate) { Array.Resize(ref FHit, SpreadMax); FOutput.SliceCount = SpreadMax; string curCase; for (int i = 0; i < SpreadMax; i++) { FSwitch.GetString(i, out curCase); int def = -1; int hit = -1; for (int s = 0; s < FCaseArr.Length; s++) { if (curCase == FCaseArr[s]) { hit = s; } if (FCaseArr[s] == "default") { def = s; } } if (hit < 0) { hit = def; } if (hit >= 0 && hit != FHit[i]) { FHit[i] = hit; FEvaluate = true; } } } if (!FEvaluate) { foreach (int id in FHit) { if (FPinArr[id].PinIsChanged) { FEvaluate = true; break; } } } if (FEvaluate) { unsafe { double *outVals; FOutput.GetValuePointer(out outVals); for (int i = 0; i < SpreadMax; i++) { double *inVals; int inCount; FPinArr[FHit[i]].GetValuePointer(out inCount, out inVals); outVals[i] = inVals[i % inCount]; } } FEvaluate = false; } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public unsafe void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FInput.PinIsChanged || FPts.PinIsChanged || FCtrl.PinIsChanged || FVecSize.PinIsChanged || FPtPC.PinIsChanged || FInPC.PinIsChanged || FClosed.PinIsChanged) { double tmpVecSize; FVecSize.GetValue(0, out tmpVecSize); int vecSize = Math.Max(1, (int)Math.Round(tmpVecSize)); double inBins; FInPC.GetValue(0, out inBins); inBins = Math.Round(inBins); int inTotal = 0; List <int> inBinList = new List <int>(); if (FInPC.SliceCount > 1 || inBins != 0) { int inBinIncr = 0; bool inEnd = false; while (!inEnd) { FInPC.GetValue(inBinIncr, out inBins); int curInBin = (int)Math.Round(inBins); if (curInBin < 0) { curInBin = (int)Math.Ceiling(FInput.SliceCount / (double)Math.Abs(curInBin)); } inBinList.Add(curInBin); inBinIncr++; inTotal += curInBin; if (inBinIncr % FInPC.SliceCount == 0 && inTotal >= FInput.SliceCount) { inEnd = true; } } } double ptBins; FPtPC.GetValue(0, out ptBins); ptBins = Math.Round(ptBins); int curvesTotal = 0; List <int> ptBinList = new List <int>(); if (FPtPC.SliceCount > 1 || ptBins != 0) { int ptsMax = Math.Max(FPts.SliceCount, FCtrl.SliceCount); ptsMax = (int)Math.Ceiling(ptsMax / (double)vecSize); int ptBinIncr = 0; bool ptEnd = false; while (!ptEnd) { FPtPC.GetValue(ptBinIncr, out ptBins); int curBin = (int)Math.Round(ptBins); if (curBin < 0) { curBin = (int)Math.Ceiling(ptsMax / (double)Math.Abs(curBin)); } ptBinList.Add(curBin); ptBinIncr++; curvesTotal += curBin; if (ptBinIncr % FPtPC.SliceCount == 0 && curvesTotal >= ptsMax) { ptEnd = true; } } } FCurveC.SliceCount = 1; FCurveC.SetValue(0, (double)ptBinList.Count); int maxLoop = Math.Max(ptBinList.Count, inBinList.Count); maxLoop = Math.Max(maxLoop, FClosed.SliceCount); double *ins, pts, ctrls; int inC, ptC, ctrlC; FInput.GetValuePointer(out inC, out ins); FPts.GetValuePointer(out ptC, out pts); FCtrl.GetValuePointer(out ctrlC, out ctrls); double[] returnArr = new double[0]; int iIncr = 0, pIncr = 0; for (int c = 0; c < maxLoop; c++) { int iCount = inBinList[c % inBinList.Count]; int pCount = ptBinList[c % ptBinList.Count]; Array.Resize(ref returnArr, returnArr.Length + (iCount * vecSize)); double[] inArr = new double[iCount]; for (int i = 0; i < iCount; i++) { inArr[i] = ins[(iIncr + i) % inC]; } for (int v = 0; v < vecSize; v++) { double[] ptArr = new double[pCount]; double[] ctrlArr = new double[pCount]; for (int p = 0; p < pCount; p++) { int ptId = pIncr + (p * vecSize) + v; ptArr[p] = pts[ptId % ptC]; ctrlArr[p] = ctrls[ptId % ctrlC]; } double closed; FClosed.GetValue(c, out closed); bool isClosed = closed > 0.5; double[] outArr = PolyBezier(inArr, ptArr, ctrlArr, isClosed); for (int o = 0; o < outArr.Length; o++) { returnArr[(iIncr + o) * vecSize + v] = outArr[o]; } } iIncr += iCount; pIncr += pCount * vecSize; } double *outVal; FOutput.SliceCount = returnArr.Length; FOutput.GetValuePointer(out outVal); for (int i = 0; i < returnArr.Length; i++) { outVal[i] = returnArr[i]; } } }
//here we go, thats the method called by vvvv each frame //all data handling should be in here public unsafe void Evaluate(int SpreadMax) { //if any of the inputs has changed //recompute the outputs if (FSpreadC.PinIsChanged || FPts.PinIsChanged || FCtrl.PinIsChanged || FVecSize.PinIsChanged || FBinSize.PinIsChanged || FFactor.PinIsChanged || FPhase.PinIsChanged || FClosed.PinIsChanged) { double tmpVecSize; FVecSize.GetValue(0, out tmpVecSize); int vecSize = Math.Max(1, (int)Math.Round(tmpVecSize)); double ptBins; FBinSize.GetValue(0, out ptBins); ptBins = Math.Round(ptBins); int ptsTotal = 0; List <int> ptBinList = new List <int>(); if (FFactor.SliceCount > 1 || ptBins != 0) { int ptsMax = Math.Max(FPts.SliceCount, FCtrl.SliceCount); ptsMax = (int)Math.Ceiling(ptsMax / (double)vecSize); int binIncr = 0; bool end = false; while (!end) { FBinSize.GetValue(binIncr, out ptBins); int curBin = (int)Math.Round(ptBins); if (curBin < 0) { curBin = (int)Math.Ceiling(ptsMax / (double)Math.Abs(curBin)); } ptBinList.Add(curBin); binIncr++; ptsTotal += curBin; if (binIncr % FBinSize.SliceCount == 0 && ptsTotal >= ptsMax) { end = true; } } } int maxLoop = Math.Max(ptBinList.Count, FPhase.SliceCount); maxLoop = Math.Max(maxLoop, FFactor.SliceCount); maxLoop = Math.Max(maxLoop, FClosed.SliceCount); maxLoop = Math.Max(maxLoop, FSpreadC.SliceCount); double *pts, ctrls, spread; int ptC, ctrlC, spreadC; FPts.GetValuePointer(out ptC, out pts); FCtrl.GetValuePointer(out ctrlC, out ctrls); FSpreadC.GetValuePointer(out spreadC, out spread); int pIncr = 0, oIncr = 0; double[] returnArr = new double[0]; for (int c = 0; c < maxLoop; c++) { double phase, factor; FPhase.GetValue(c, out phase); FFactor.GetValue(c, out factor); int curSpreadC = (int)Math.Round(spread[c % spreadC]); Array.Resize(ref returnArr, returnArr.Length + curSpreadC * vecSize); double[] inArr = new double[curSpreadC]; for (int i = 0; i < curSpreadC; i++) { inArr[i] = ((i / (double)curSpreadC) * factor) + phase; } int pCount = ptBinList[c % ptBinList.Count]; for (int v = 0; v < vecSize; v++) { double[] ptArr = new double[pCount]; double[] ctrlArr = new double[pCount]; for (int p = 0; p < pCount; p++) { int ptId = pIncr + (p * vecSize) + v; ptArr[p] = pts[ptId % ptC]; ctrlArr[p] = ctrls[ptId % ctrlC]; } double closed; FClosed.GetValue(c, out closed); bool isClosed = closed > 0.5; double[] outArr = PolyBezier(inArr, ptArr, ctrlArr, isClosed); for (int o = 0; o < outArr.Length; o++) { returnArr[(oIncr + o) * vecSize + v] = outArr[o]; } } oIncr += curSpreadC; pIncr += pCount * vecSize; } double *outVal; FOutput.SliceCount = returnArr.Length; FOutput.GetValuePointer(out outVal); for (int i = 0; i < returnArr.Length; i++) { outVal[i] = returnArr[i]; } } }