//-------------------------------------------------------------- void testApp::update(){ panel.update(); nIterations = panel.getValueI("N_ITERATIONS"); nNearestNeighborsK = panel.getValueI("N_NEIGHBORS"); nMaxPointsToVisit = nNearestNeighborsK + 6; totalCycleDurationInIterations = nIterations * 6; if (!bPause && (iterationCount < nIterations)){ int nToAddPerFrame = panel.getValueI("ADD_PER_FRAME"); //addPositionsProbabilisticallyBasedOnSourceImage (nToAddPerFrame); addPointsOnTooLongConnections(); applyImageForces(); IppiSize allBufRoi = {nParticles, 1}; // add random forces to velocities unsigned int pSeed; float fmax = panel.getValueF("FORCE_NOISE"); ippiAddRandUniform_Direct_32f_C1IR(velocityx, particleStep32f, allBufRoi, -fmax,fmax, &pSeed); ippiAddRandUniform_Direct_32f_C1IR(velocityy, particleStep32f, allBufRoi, -fmax,fmax, &pSeed); // multiply velocities by damping factor Ipp32f damping = panel.getValueF("DAMPING"); Ipp32f progressiveDamping = ofMap(iterationCount, 0,nIterations, 1.0, 0.0, true); ippiMulC_32f_C1IR(progressiveDamping, velocityx, particleStep32f, allBufRoi); ippiMulC_32f_C1IR(progressiveDamping, velocityy, particleStep32f, allBufRoi); // add velocities to positions ippiAdd_32f_C1IR(velocityx, particleStep32f, positionx, particleStep32f, allBufRoi); ippiAdd_32f_C1IR(velocityy, particleStep32f, positiony, particleStep32f, allBufRoi); // clamp positions to acceptable ranges ippiThreshold_LTValGTVal_32f_C1IR (positionx, particleStep32f, allBufRoi, bounds.x, bounds.x, bounds.x+bounds.width, bounds.x+bounds.width); ippiThreshold_LTValGTVal_32f_C1IR (positiony, particleStep32f, allBufRoi, bounds.y, bounds.y, bounds.y+bounds.height, bounds.y+bounds.height); //---------------------------------- updateNearestNeighbors(); updateParticles(); } iterationCount++; if (iterationCount == nIterations){ saveFBO(); // DO IT! } if (bCycleAutomatically && (iterationCount > totalCycleDurationInIterations)){ initialize(false); } }
void ParticleTrace :: keyPressed ( int key ) { if( key == 't' ) { if( bShowParticleLines ) { saveFBO( fboLines ); } else if( bShowParticleStrip ) { saveFBO( fboStrips ); } else if( bShowParticleType ) { saveFBO( fboType ); } } }