//-------------------------------------------------------------- void ofApp::setup(){ // 画面基本設定 ofSetFrameRate(60); ofSetBackgroundAuto(false); ofBackground(0); // ofNoFill(); ofSetColor(255, 255, 0); gui.setup(); gui.add(refresh.setup("refresh", 100, 100, 3000)); gui.add(speed.setup("speed", 8.0, 0.0, 20.0)); gui.add(defSize.setup("Default size", 10, 1, 20)); gui.add(size.setup("radius size", 0.1, 0, 10)); gui.add(forceX.setup("FORCE X", 0.01, 0, 1)); gui.add(forceY.setup("FORCE Y", 0.01, 0, 1)); gui.add(forceZ.setup("FORCE Z", 0.01, 0, 1)); gui.add(forceSeedX.setup("FORCE SEED X", 0.01, 0, 1)); gui.add(forceSeedY.setup("FORCE SEED Y", 0.01, 0, 1)); gui.add(forceSeedZ.setup("FORCE SEED Z", 0.01, 0, 1)); gui.add(colorStart.setup("C1", 0.1, 0, 1)); gui.add(colorEnd.setup("C2", 0.4, 0, 1)); gui.add(shape.setup("PARTICLE SHAPE", 0, 0, 3)); gui.loadFromFile("settings.xml"); // light.enable(); initParticles(); }
void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: g_bExitESC = true; exit(EXIT_SUCCESS); break; case 'r': memset(hvfield, 0, sizeof(cData) * DS); cudaMemcpy(dvfield, hvfield, sizeof(cData) * DS, cudaMemcpyHostToDevice); initParticles(particles, DIM, DIM); cudaGraphicsUnregisterResource(cuda_vbo_resource); getLastCudaError("cudaGraphicsUnregisterBuffer failed"); glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(cData) * DS, particles, GL_DYNAMIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); cudaGraphicsGLRegisterBuffer(&cuda_vbo_resource, vbo, cudaGraphicsMapFlagsNone); getLastCudaError("cudaGraphicsGLRegisterBuffer failed"); break; default: break; } }
int main(int argc, char *argv[]) { param params; AABB water_volume; AABB boundary_volume; fluid_particle *fluid_particles = NULL; boundary_particle *boundary_particles = NULL; initParams(&water_volume, &boundary_volume, ¶ms); initParticles(&fluid_particles, &boundary_particles, &water_volume, &boundary_volume, ¶ms); eulerStart(fluid_particles, boundary_particles, ¶ms); // Main simulation loop #pragma acc enter data copyin(fluid_particles[0:params.number_fluid_particles], boundary_particles[0:params.number_boundary_particles],params[0:1]) for(int n=0; n<params.number_steps; n++) { updatePressures(fluid_particles, ¶ms); updateAccelerations(fluid_particles, boundary_particles, ¶ms); updatePositions(fluid_particles, ¶ms); if (n % params.steps_per_frame == 0) { #pragma acc update host(fluid_particles[0:params.number_fluid_particles]) writeFile(fluid_particles, ¶ms); } } #pragma acc exit data delete(fluid_particles[0:params.number_fluid_particles],boundary_particles[0:params.number_boundary_particles],params[0:1]) finalizeParticles(fluid_particles, boundary_particles); return 0; }
/** * Hier findet die komplette Initialisierung des kompletten SPIEeles statt. * Inklusive der Datenhaltung und des SPIEelfeldes. */ void initGame () { initCameraPosition(); initSpheres(); initQuads(); initParticles(); }
void init( ) { int x, z; glShadeModel(GL_SMOOTH); glClearColor(0.0, 0.0, 0.0, 0.0); glClearDepth(1.0); glEnable(GL_DEPTH_TEST); // Ground Verticies // Ground Colors for (z = 0; z < 21; z++) { for (x = 0; x < 21; x++) { ground_points[x][z][0] = x - 10.0; ground_points[x][z][1] = accum; ground_points[x][z][2] = z - 10.0; ground_colors[z][x][0] = r; // red value ground_colors[z][x][1] = g; // green value ground_colors[z][x][2] = b; // blue value ground_colors[z][x][3] = 0.0; // acummulation factor } } // Initialize particles for (loop = 0; loop < MAX_PARTICLES; loop++) { initParticles(loop); } }
int main(int argc, char *argv[]) { param params; AABB water_volume; AABB boundary_volume; fluid_particle *fluid_particles = NULL; boundary_particle *boundary_particles = NULL; initParams(&water_volume, &boundary_volume, ¶ms); initParticles(&fluid_particles, &boundary_particles, &water_volume, &boundary_volume, ¶ms); eulerStart(fluid_particles, boundary_particles, ¶ms); // Main simulation loop for(int n=0; n<params.number_steps; n++) { updatePressures(fluid_particles, ¶ms); updateAccelerations(fluid_particles, boundary_particles, ¶ms); updatePositions(fluid_particles, ¶ms); if (n % params.steps_per_frame == 0) { writeFile(fluid_particles, ¶ms); } } finalizeParticles(fluid_particles, boundary_particles); return 0; }
void GLWidget::initializeGL() { qDebug() << "Initializing OpenGL"; qglClearColor(QColor(20, 20, 20)); initShaders(); initParticles(); initVBOs(); psTexture = bindTexture(pointSpriteImage, GL_TEXTURE_2D, GL_RGBA); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); velTexture = bindTexture(paletteImage, GL_TEXTURE_2D, GL_RGBA); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); qDebug() << "OpenGL initialized."; initializeCL(); }
int main(int argc, char *argv[]) { param params; AABB water_volume; AABB boundary_volume; fluid_particle *fluid_particles = NULL; boundary_particle *boundary_particles = NULL; initParams(&water_volume, &boundary_volume, ¶ms); initParticles(&fluid_particles, &boundary_particles, &water_volume, &boundary_volume, ¶ms); eulerStart(fluid_particles, boundary_particles, ¶ms); // Main simulation loop // Hint: Copy fluid_particles(params.number_fluid_particles), boundary_particles(params.number_boundary_particles), and params(1) for(int n=0; n<params.number_steps; n++) { updatePressures(fluid_particles, ¶ms); updateAccelerations(fluid_particles, boundary_particles, ¶ms); updatePositions(fluid_particles, ¶ms); if (n % params.steps_per_frame == 0) { // Hint: Make sure to update the host fluid_particle data writeFile(fluid_particles, ¶ms); } } // Hint: delete any acc data allocated finalizeParticles(fluid_particles, boundary_particles); return 0; }
template <typename PointInT, typename StateT> bool pcl::tracking::KLDAdaptiveParticleFilterTracker<PointInT, StateT>::initCompute () { if (!Tracker<PointInT, StateT>::initCompute ()) { PCL_ERROR ("[pcl::%s::initCompute] Init failed.\n", getClassName ().c_str ()); return (false); } if (transed_reference_vector_.empty ()) { // only one time allocation transed_reference_vector_.resize (maximum_particle_number_); for (unsigned int i = 0; i < maximum_particle_number_; i++) { transed_reference_vector_[i] = PointCloudInPtr (new PointCloudIn ()); } } coherence_->setTargetCloud (input_); if (!change_detector_) change_detector_ = boost::shared_ptr<pcl::octree::OctreePointCloudChangeDetector<PointInT> >(new pcl::octree::OctreePointCloudChangeDetector<PointInT> (change_detector_resolution_)); if (!particles_ || particles_->points.empty ()) initParticles (true); return (true); }
// For Rain void drawRain() { float x, y, z; for (loop = 0; loop < MAX_PARTICLES; loop=loop+2) { if (par_sys[loop].alive == true) { x = par_sys[loop].xpos; y = par_sys[loop].ypos; z = par_sys[loop].zpos + zoom; // Draw particles glColor3f(0.5, 0.5, 1.0); glBegin(GL_LINES); glVertex3f(x, y, z); glVertex3f(x, y+0.5, z); glEnd(); // Update values //Move // Adjust slowdown for speed! par_sys[loop].ypos += par_sys[loop].vel / (slowdown*1000); par_sys[loop].vel += par_sys[loop].gravity; // Decay par_sys[loop].life -= par_sys[loop].fade; if (par_sys[loop].ypos <= -10) { par_sys[loop].life = -1.0; } //Revive if (par_sys[loop].life < 0.0) { initParticles(loop); } } } }
void main(void) { int gd = CUSTOM, gm = CUSTOM_MODE(1024,768); int page = 0; g_mousestate curState; g_mousestate oldState; int scrolling = 0; initgraph(&gd, &gm, ""); initParticles(particles); while(!anykeypressed()) { getmousestate(&curState); if((curState.buttons & MOUSE_LEFTBUTTON) == 0) { scrolling = 0; } else { if(scrolling == 0) { scrolling = 1; getmousestate(&oldState); } else { orgX -= -curState.x + oldState.x; orgY += -curState.y + oldState.y; oldState = curState; } } updateParticles(particles, particles2); setactivepage(1 - page); clearviewport(); drawParticles(particles); setvisualpage(1 - page); page = 1 - page; delay(4); } closegraph(); }
/// \param effectDef XML tag containing the effect definition ParticleEffect::ParticleEffect(TiXmlElement *effectDef) { // assign defaults m_nTotalParticleCount = 0; m_bCycleParticles = true; m_bIsDead = false; m_IsDying = false; m_nLiveParticleCount = 0; m_fEmitPartial = 1.0f; // start with at least one particle m_vecGravity = Vector3::kZeroVector; m_vecPosition = Vector3::kZeroVector; m_txtParticleTexture = NULL; m_UpdateFunc.clear(); m_InitFunc.clear(); m_fPILife = 1.0f; m_fPISpeed = 100.0f; m_fPIDragValue = 0.0f; m_PIFadeIn = 0.0f; m_PIFadeOut = 1.0f; m_PIFadeMax = 1.0f; m_PIRotationSpeed = 0.0f; m_PIRotationStopTime = 0.0f; m_distFunc = NULL; // default emit rate is all at once (or at least all in the first .01 secs) m_nEmitRate = m_nTotalParticleCount * 100; m_sort = false; m_vertBuffer = NULL; m_indexBuffer = NULL; // get system data effectDef->Attribute("particleCount", &m_nTotalParticleCount); const char *filename = effectDef->Attribute("textureName"); // initialize effect properties from the xml tag initProperties(effectDef); // allocate memory needed m_Particles = new Particle[m_nTotalParticleCount]; m_drawOrder = new int[m_nTotalParticleCount]; initParticles(); // create vertex and index buffers, and initialize index buffer. We can // create the index buffer as static since it doesn't change values; this // will increase performance a little. m_vertBuffer = new VertexLBuffer(m_nTotalParticleCount * 4, true); m_indexBuffer = new IndexBuffer(m_nTotalParticleCount * 2); initIndexBuffer(); // this should be replaced with the renderer version of loading a texture gDirectoryManager.setDirectory(eDirectoryTextures); D3DXIMAGE_INFO structImageInfo; //image information HRESULT hres=D3DXCreateTextureFromFileEx(pD3DDevice, filename, 0,0,1,0,D3DFMT_A8R8G8B8,D3DPOOL_MANAGED,D3DX_FILTER_NONE, D3DX_DEFAULT,0,&structImageInfo,NULL, &m_txtParticleTexture); }
void Init() { initD3D(); initParticles(); initVertexData(); initRectangleVertexes(); initEffect(); }
void init() { // General Graphics glClearColor(0.1, 0.1, 0.1, 1); glEnable(GL_DEPTH_TEST); //particle initiation initParticles(); }
void PlaneSupportedCuboidEstimator::cloudCallback( const sensor_msgs::PointCloud2::ConstPtr& msg) { boost::mutex::scoped_lock lock(mutex_); NODELET_INFO("cloudCallback"); if (!latest_polygon_msg_ || !latest_coefficients_msg_) { JSK_NODELET_WARN("Not yet polygon is available"); return; } if (!tracker_) { NODELET_INFO("initTracker"); // Update polygons_ vector polygons_.clear(); for (size_t i = 0; i < latest_polygon_msg_->polygons.size(); i++) { Polygon::Ptr polygon = Polygon::fromROSMsgPtr(latest_polygon_msg_->polygons[i].polygon); polygons_.push_back(polygon); } // viewpoint tf::StampedTransform transform = lookupTransformWithDuration(tf_, sensor_frame_, msg->header.frame_id, ros::Time(0.0), ros::Duration(0.0)); tf::vectorTFToEigen(transform.getOrigin(), viewpoint_); ParticleCloud::Ptr particles = initParticles(); tracker_.reset(new pcl::tracking::ROSCollaborativeParticleFilterTracker<pcl::PointXYZ, pcl::tracking::ParticleCuboid>); tracker_->setCustomSampleFunc(boost::bind(&PlaneSupportedCuboidEstimator::sample, this, _1)); tracker_->setLikelihoodFunc(boost::bind(&PlaneSupportedCuboidEstimator::likelihood, this, _1, _2)); tracker_->setParticles(particles); tracker_->setParticleNum(particle_num_); support_plane_updated_ = false; // Publish histograms publishHistogram(particles, 0, pub_histogram_global_x_, msg->header); publishHistogram(particles, 1, pub_histogram_global_y_, msg->header); publishHistogram(particles, 2, pub_histogram_global_z_, msg->header); publishHistogram(particles, 3, pub_histogram_global_roll_, msg->header); publishHistogram(particles, 4, pub_histogram_global_pitch_, msg->header); publishHistogram(particles, 5, pub_histogram_global_yaw_, msg->header); publishHistogram(particles, 6, pub_histogram_dx_, msg->header); publishHistogram(particles, 7, pub_histogram_dy_, msg->header); publishHistogram(particles, 8, pub_histogram_dz_, msg->header); // Publish particles sensor_msgs::PointCloud2 ros_particles; pcl::toROSMsg(*particles, ros_particles); ros_particles.header = msg->header; pub_particles_.publish(ros_particles); } else { ParticleCloud::Ptr particles = tracker_->getParticles(); Eigen::Vector4f center; pcl::compute3DCentroid(*particles, center); if (center.norm() > fast_cloud_threshold_) { estimate(msg); } } }
void ParticleEffect::start() { initParticles(); m_bIsDead = false; m_IsDying = false; m_nLiveParticleCount = 0; m_fEmitPartial = 1.0f; }
ParticleGenerator::ParticleGenerator(int maxParticles, std::string vertexShader, std::string fragmentShader) { mMaxParticles = maxParticles; mParticles = new Particle[maxParticles]; mShader.loadVertexShader(vertexShader); mShader.loadFragmentShader(fragmentShader); initParticles(); }
void keyboard(unsigned char key, int x, int y) { switch (key) { case 27: g_bExitESC = true; exit(EXIT_SUCCESS); break; case 'f': if (!fullscreen) { fullscreen = 1; glutFullScreenToggle(); } else { fullscreen = 0; glutLeaveFullScreen(); } break; case 'r': pthread_mutex_lock(&display_mutex); memset(hvfield, 0, sizeof(cData) * DS); cudaMemcpy(dvfield, hvfield, sizeof(cData) * DS, cudaMemcpyHostToDevice); initParticles(particles, DIM, DIM); #ifndef OPTIMUS cudaGraphicsUnregisterResource(cuda_vbo_resource); getLastCudaError("cudaGraphicsUnregisterBuffer failed"); #endif #if defined(OPTIMUS) || defined(BROADCAST) cudaMemcpy(particles_gpu, particles, sizeof(cData) * DS, cudaMemcpyHostToDevice); #endif glBindBufferARB(GL_ARRAY_BUFFER_ARB, vbo); glBufferDataARB(GL_ARRAY_BUFFER_ARB, sizeof(cData) * DS, particles, GL_DYNAMIC_DRAW_ARB); glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); #ifndef OPTIMUS cudaGraphicsGLRegisterBuffer(&cuda_vbo_resource, vbo, cudaGraphicsMapFlagsNone); getLastCudaError("cudaGraphicsGLRegisterBuffer failed"); #endif pthread_mutex_unlock(&display_mutex); break; default: break; } }
ParticleSystem::ParticleSystem () : slowdown (1.0f), tex (0), active (false), x (0), y (0), darken (0.0f), blendMode (0) { initParticles (0); }
void menu::init_Escena() { ofLogNotice("- - - - - - - init escena() - - - - - - - "); bshowdebug=false; ofPoint centro = ofPoint(W_WIDTH/2.0, W_HEIGHT/2.0); isKeyPressed = false; isMousePressed = false; // Crear las particulas initParticles(); bDraw4Forces = true; fRed = false; swFuerzaDensidad = false; ofEnableAlphaBlending(); // fbos: // limpiarlas fbo1.begin(); ofClear(255,255,255,0); fbo1.end(); fbo2.begin(); ofClear(255,255,255,0); fbo2.end(); fbo3.begin(); ofClear(255,255,255,0); fbo3.end(); fbo4.begin(); ofClear(255,255,255,0); fbo4.end(); bDrawFbos = false; // rangos angulares de los sectores // delete[] rangosAngDeg; rangosAngDeg [0] = 0; rangosAngDeg [1] = 90; rangosAngDeg [2] = 180; rangosAngDeg [3] = 270; ofDisableAlphaBlending(); // addListeners // Aqui no hacemos nada (por ahora) con las colisiones y otros eventos // box2d.enableEvents(); // ofAddListener(box2d.contactStartEvents, this, &menu::contactStart); // ofAddListener(box2d.contactEndEvents, this, &menu::contactEnd); // Listeners para detectar que se esta tocando en una zona u otra /* ofAddListener(button1.buttonEvent ,this, &menu::onButtonPressed); ofAddListener(button2.buttonEvent ,this, &menu::onButtonPressed); ofAddListener(button3.buttonEvent ,this, &menu::onButtonPressed); ofAddListener(button4.buttonEvent ,this, &menu::onButtonPressed);*/ ofLogNotice("menu - init_escena - fin"); currentButton=-1; for(int i=0; i<buttons.size();i++){ buttons[i].touchUpAll(); } hands.objectsCol.clear(); }
int main( int argc, char* args[] ) { Particles emitter; //Start up SDL and create window if ( init(&gWindow, &renderer) ) { printf( "Failed to initialize!\n" ); } else { if (load_texture(&smokeTexture, renderer) == 1) { printf("Failed to load texture\n"); } else { initParticles( &emitter, 170, 315 ); printf("in main %f\n", emitter.m_speed); emitter.m_lastRender = getMilliCount(); //Main loop flag #ifdef EMSCRIPTEN emscripten_set_main_loop_arg((em_arg_callback_func)loop, (void*)&emitter, 0, 1); #else while (!quit) { SDL_Delay(15); loop(&emitter); } #endif } } //Free resources and close SDL SDL_DestroyTexture(smokeTexture); smokeTexture = NULL; SDL_DestroyRenderer(renderer); renderer = NULL; SDL_DestroyWindow(gWindow); gWindow = NULL; IMG_Quit(); SDL_Quit(); return 0; }
particleSystem::particleSystem(int number){ xstart = 0.f; ystart = 0.f; zstart = 0.f; xend = 4.0f; yend = 6.0f; zend = 4.0f; initParticles(number); initSphere(); gridcells.resize(4,6,4, particles); }
int main(int argc, char *argv[]){ struct timespec bgn,nd; npart = atoi(argv[1]); /*command line input expected which provides the number of particles */ nstep = atoi(argv[2]); /*command line input expected which provides the number of particles */ /*initialize the position of particles in space and also their velocity and acceleration vector values*/ initParticles(npart); clock_gettime(CLOCK_REALTIME, &bgn); /*begin the simulation with the initialization done previously and using simulation parameters defined in the global constants*/ begin_simulation(); clock_gettime(CLOCK_REALTIME, &nd); printf("%f\n", timediff(bgn,nd)); }
void GLFluids::reset() { memset(hvfield, 0, sizeof(float2) * DS); cudaMemcpy(dvfield, hvfield, sizeof(float2) * DS, cudaMemcpyHostToDevice); initParticles(particles, DIM, DIM); glBindBuffer(GL_ARRAY_BUFFER, vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(float2) * DS, particles, GL_DYNAMIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); cudaGraphicsGLRegisterBuffer(&cuda_vbo_resource, vbo, cudaGraphicsMapFlagsNone); }
GLFluids::GLFluids(QWidget *parent) : QGLWidget(parent), QGLFunctions() { vbo = 0; wWidth = qMax(512, DIM); wHeight = qMax(512, DIM); hvfield = (float2 *)malloc(sizeof(float2) * DS); memset(hvfield, 0, sizeof(float2) * DS); // Allocate and initialize device data cudaMallocPitch((void **)&dvfield, &tPitch, sizeof(float2)*DIM, DIM); cudaMemcpy(dvfield, hvfield, sizeof(float2) * DS, cudaMemcpyHostToDevice); // Temporary complex velocity field data cudaMalloc((void **)&vxfield, sizeof(float2) * PDS); cudaMalloc((void **)&vyfield, sizeof(float2) * PDS); setup_texture(DIM, DIM); bind_texture(); // Create particle array particles = (float2 *)malloc(sizeof(float2) * DS); memset(particles, 0, sizeof(float2) * DS); initParticles(particles, DIM, DIM); // Create CUFFT transform plan configuration cufftPlan2d(&planr2c, DIM, DIM, CUFFT_R2C); cufftPlan2d(&planc2r, DIM, DIM, CUFFT_C2R); // TODO: update kernels to use the new unpadded memory layout for perf // rather than the old FFTW-compatible layout cufftSetCompatibilityMode(planr2c, CUFFT_COMPATIBILITY_FFTW_PADDING); cufftSetCompatibilityMode(planc2r, CUFFT_COMPATIBILITY_FFTW_PADDING); QTimer *timer = new QTimer(this); connect(timer, &QTimer::timeout, [&](){ simulateFluids(); updateGL(); }); timer->start(0); }
task main() { initParticles(); if (PATH_FOLLOWING) { DISPLAY_SCALE = DISPLAY_SCALE_PATH_FOLLOW; yoff = 10*DISPLAY_SCALE; xoff = 5*DISPLAY_SCALE; runPathTest(); } else { DISPLAY_SCALE = DISPLAY_SCALE_SQUARE; yoff = 5*DISPLAY_SCALE; xoff = 25*DISPLAY_SCALE; drawSquare(); } wait1Msec(10000); }
void XBScene1::setup(XBBaseGUI *_gui) { XBBaseScene::setup(_gui); wavesMask.allocate(ofGetWidth(), ofGetHeight(), GL_RGB); wavesMask.begin(); ofSetBackgroundAuto(false); ofBackground(0, 0, 0); wavesMask.end(); initWindows(); initParticles(); initWaves(); initStones(); initLines(); blur.setup(getMainFBO().getWidth(), getMainFBO().getHeight(), 0); XBScene1GUI *myGUI = (XBScene1GUI *) gui; myGUI->flashDirector.getParameter().cast<bool>().addListener(this, &XBScene1::flashDirector); }
//-------------------------------------------------------------- void ofApp::update(){ ofSetWindowTitle(ofToString(ofGetFrameRate())); t = ofGetElapsedTimef(); frameCount++; if(frameCount > refresh) { initParticles(); } for (int i = 0; i < CIRCLE_NUM; i++) { particle[i].resetForce(); // particle[i].addForce( ofVec3f(ofSignedNoise(t, i * forceSeedX) * forceX, ofSignedNoise(t, i * forceSeedY) * forceY, ofSignedNoise(t, i * forceSeedZ) * forceZ)); particle[i].addForce( ofVec3f(ofSignedNoise(t, i * forceSeedX) * forceX, ofSignedNoise(t, i * forceSeedY) * forceY, ofNoise(t, i * forceSeedZ) * forceZ)); particle[i].updateForce(); particle[i].updateSize(ofNoise(t * 0.2, 0.01 * i) * size); particle[i].updatePos(); particle[i].updateColor(colorStart, colorEnd); } }
// For Snow void drawSnow() { float x, y, z; for (loop = 0; loop < MAX_PARTICLES; loop=loop+2) { if (par_sys[loop].alive == true) { x = par_sys[loop].xpos; y = par_sys[loop].ypos; z = par_sys[loop].zpos + zoom; // Draw particles glColor3f(1.0, 1.0, 1.0); glPushMatrix(); glTranslatef(x, y, z); glutSolidSphere(0.2, 16, 16); glPopMatrix(); // Update values //Move par_sys[loop].ypos += par_sys[loop].vel / (slowdown*1000); par_sys[loop].vel += par_sys[loop].gravity; // Decay par_sys[loop].life -= par_sys[loop].fade; if (par_sys[loop].ypos <= -10) { int zi = z - zoom + 10; int xi = x + 10; ground_colors[zi][xi][0] = 1.0; ground_colors[zi][xi][2] = 1.0; ground_colors[zi][xi][3] += 1.0; if (ground_colors[zi][xi][3] > 1.0) { ground_points[xi][zi][1] += 0.1; } par_sys[loop].life = -1.0; } //Revive if (par_sys[loop].life < 0.0) { initParticles(loop); } } } }
void imageProcessing(IplImage* img) { // Create temporary images CvSize sz = cvGetSize(img); IplImage* hsv_image = cvCreateImage(sz,8,3); IplImage* hsv_mask = cvCreateImage(sz,8,1); // HSV Conversion and Thresholding cvCvtColor(img,hsv_image,CV_BGR2HSV); cvInRangeS(hsv_image,hsv_min,hsv_max, hsv_mask); // Init if((height != sz.height) | (width != sz.width)) { height = sz.height; width = sz.width; initParticles(); } // Filter particleFilter(hsv_mask); // Compute variance std::pair<double,double> V = particlesVariance(); //ROS_INFO("Variances: Vx = %f, Vy = %f",V.first,V.second); if((V.first < Var_min) & (V.second < Var_min)) { robotDetected = true; } // Draw particles showParticles(hsv_mask); // Show result //cvNamedWindow("Search",1); cvShowImage("Search",hsv_mask); cvWaitKey(10); }