示例#1
0
void TempFigure::show(SDL_Rect* otherCamera) {
   if (marker == INACTIVE)
      return;
   else if (marker == REMOVE) {
      bool animationDone = true;
      marker = INACTIVE;

      if (animationDone) {
         if (Mix_PlayChannel(-1, scratch.getMix_Chunk(), 0) < 0) {
            printf("Mix_PlayChannel: %s\n", Mix_GetError());
            throw SoundException();
         }
      }
   }
   else if (marker == ACTIVE) {
      if (numClips > 0) {
         if (v.x < 0) {
            status = LEFT;
            animationFrame += AFVALUE;
         }
         else if (v.x > 0) {
            status = RIGHT;
            animationFrame += AFVALUE;
         }
         else
            animationFrame = 0;

         if (animationFrame >= numClips)
            animationFrame = 0;

         if (leader) {
            if (status == LEFT)
               applySurface((int) p.x - camera->x, (int) p.y - camera->y,
                     *image, screen, &cl[static_cast<int>(animationFrame)]);
            else if (status == RIGHT)
               applySurface((int) p.x - camera->x, (int) p.y - camera->y,
                     *image, screen, &cr[static_cast<int>(animationFrame)]);

            if (particleEffects)
               showParticles(camera);
         }
         else {
            if (status == LEFT)
               applySurface((int) p.x - otherCamera->x,
                     (int) p.y - otherCamera->y, *image, screen,
                     &cl[static_cast<int>(animationFrame)]);
            else if (status == RIGHT)
               applySurface((int) p.x - otherCamera->x,
                     (int) p.y - otherCamera->y, *image, screen,
                     &cr[static_cast<int>(animationFrame)]);

            if (particleEffects)
               showParticles(otherCamera);
         }
      }
   }
   else
      throw InvalidMarkerException();
}
示例#2
0
void PlayerFigure::show(SDL_Rect* otherCamera) {
   if (numClips > 0) {
      if (v.x < 0) {
         status = LEFT;
         animationFrame += AFVALUE;
      }
      else if (v.x > 0) {
         status = RIGHT;
         animationFrame += AFVALUE;
      }
      if (v.x == 0 || animationFrame >= numClips)
         animationFrame = 0;

      if (status == LEFT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cl[static_cast<int>(animationFrame)]);
      else if (status == RIGHT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cr[static_cast<int>(animationFrame)]);

      if (particleEffects)
         showParticles(camera);

      cursor.show();
   }

   if (grabstate) {
      //TODO signal thread to perform A* algorithm
      SDL_CondSignal(canTest);
   }
}
示例#3
0
void PlayerFigure::show(SDL_Rect* otherCamera) {
   if (numClips > 0) {
      if (v.x < 0) {
         status = LEFT;
         animationFrame += AFVALUE;
      }
      else if (v.x > 0) {
         status = RIGHT;
         animationFrame += AFVALUE;
      }
      if (v.x == 0 || animationFrame >= numClips)
         animationFrame = 0;

      if (status == LEFT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cl[static_cast<int>(animationFrame)]);
      else if (status == RIGHT)
         applySurface(static_cast<int>(p.x) - camera->x,
               static_cast<int>(p.y) - camera->y, *image, screen,
               &cr[static_cast<int>(animationFrame)]);

      if (particleEffects)
         showParticles(camera);

      cursor.show();
   }
}
示例#4
0
Figure::Marker CircFigure::show(SDL_Rect* otherCamera) {
   if (numClips > 0) {
      if (v.x < 0) {
         status = LEFT;
         animationFrame += AFVALUE;
      }
      else if (v.x > 0) {
         status = RIGHT;
         animationFrame += AFVALUE;
      }
      else
         animationFrame = 0;

      if (animationFrame >= numClips)
         animationFrame = 0;

      if (leader) {
         if (status == LEFT)
            applySurface((int) p.x - r - camera->x, (int) p.y - r - camera->y,
                  *image, screen, &cl[static_cast<int>(animationFrame)]);
         else if (status == RIGHT)
            applySurface((int) p.x - r - camera->x, (int) p.y - r - camera->y,
                  *image, screen, &cr[static_cast<int>(animationFrame)]);

         if (particleEffects)
            showParticles(camera);
      }
      else {
         if (status == LEFT)
            applySurface((int) p.x - r - otherCamera->x,
                  (int) p.y - r - otherCamera->y, *image, screen,
                  &cl[static_cast<int>(animationFrame)]);
         else if (status == RIGHT)
            applySurface((int) p.x - r - otherCamera->x,
                  (int) p.y - r - otherCamera->y, *image, screen,
                  &cr[static_cast<int>(animationFrame)]);

         if (particleEffects)
            showParticles(otherCamera);
      }
   }

   return marker;
}
示例#5
0
void
UiSettings::loadSettings()
{
    QSettings s( "CS224", "snow" );

    windowPosition() = s.value( "windowPosition", QPoint(0,0) ).toPoint();
    windowSize() = s.value( "windowSize", QSize(1000,800) ).toSize();

    fillNumParticles() = s.value( "fillNumParticles", 512*128 ).toInt();
    fillResolution() = s.value( "fillResolution", 0.05f ).toFloat();
    fillDensity() = s.value( "fillDensity", 150.f ).toFloat();

    exportDensity() = s.value("exportDensity", false).toBool();
    exportVelocity() = s.value("exportVelocity", false).toBool();

    exportFPS() = s.value("exportFPS", 24).toInt();
    maxTime() = s.value("maxTime", 3).toFloat();

    gridPosition() = vec3( s.value("gridPositionX", 0.f).toFloat(),
                           s.value("gridPositionY", 0.f).toFloat(),
                           s.value("gridPositionZ", 0.f).toFloat() );


    gridDimensions() = glm::ivec3( s.value("gridDimensionX", 128).toInt(),
                                   s.value("gridDimensionY", 128).toInt(),
                                   s.value("gridDimensionZ", 128).toInt() );

    gridResolution() = s.value( "gridResolution", 0.05f ).toFloat();

    timeStep() = s.value( "timeStep", 1e-5 ).toFloat();
    implicit() = s.value( "implicit", true ).toBool();
    materialPreset() = s.value( "materialPreset", MAT_DEFAULT).toInt();

    showContainers() = s.value( "showContainers", true ).toBool();
    showContainersMode() = s.value( "showContainersMode", WIREFRAME ).toInt();
    showColliders() = s.value( "showColliders", true ).toBool();
    showCollidersMode() = s.value( "showCollidersMode", SOLID ).toInt();
    showGrid() = s.value( "showGrid", false ).toBool();
    showGridMode() = s.value( "showGridMode", MIN_FACE_CELLS ).toInt();
    showGridData() = s.value( "showGridData", false ).toBool();
    showGridDataMode() = s.value( "showGridDataMode", NODE_DENSITY ).toInt();
    showParticles() = s.value( "showParticles", true ).toBool();
    showParticlesMode() = s.value( "showParticlesMode", PARTICLE_MASS ).toInt();

    selectionColor() = glm::vec4( 0.302f, 0.773f, 0.839f, 1.f );
}
示例#6
0
void ParticleFilter::showTopNParticles(int count)
{
    m_img->copyTo(m_outIMG);
    if (count > m_num_particles)
        count = m_num_particles;
    else if (count == 0)
        showParticles();
    int x = 0;
    int y = 0;
    for (int i = 0; i < count; ++i)
    {
        x = m_particles[i]->x();
        y = m_particles[i]->y();
        int x_end = x + m_particle_width;
        int y_end = y + m_particle_height;
        rectangle(m_outIMG, cvPoint(x, y), cvPoint(x_end, y_end), cvScalar(130, 0, 0), 1);
    }
}
示例#7
0
void
UiSettings::saveSettings()
{
    QSettings s( "CS224", "snow" );

    s.setValue( "windowPosition", windowPosition() );
    s.setValue( "windowSize", windowSize() );

    s.setValue( "fillNumParticles", fillNumParticles() );
    s.setValue( "fillResolution", fillResolution() );
    s.setValue( "fillDensity", fillDensity() );

    s.setValue("exportDensity", exportDensity());
    s.setValue("exportVelocity",exportVelocity());
    s.setValue( "exportFPS", exportFPS());
    s.setValue( "maxTime", maxTime());

    s.setValue( "gridPositionX", gridPosition().x );
    s.setValue( "gridPositionY", gridPosition().y );
    s.setValue( "gridPositionZ", gridPosition().z );

    s.setValue( "gridDimensionX", gridDimensions().x );
    s.setValue( "gridDimensionY", gridDimensions().y );
    s.setValue( "gridDimensionZ", gridDimensions().z );

    s.setValue( "gridResolution", gridResolution() );

    s.setValue( "timeStep", timeStep() );
    s.setValue( "implicit", implicit() );
    s.setValue("materialPreset", materialPreset());

    s.setValue( "showContainers", showContainers() );
    s.setValue( "showContainersMode", showContainersMode() );
    s.setValue( "showColliders", showColliders() );
    s.setValue( "showCollidersMode", showCollidersMode() );
    s.setValue( "showGrid", showGrid() );
    s.setValue( "showGridMode", showGridMode() );
    s.setValue( "showGridData", showGridData() );
    s.setValue( "showGridDataMode", showGridDataMode() );
    s.setValue( "showParticles", showParticles() );
    s.setValue( "showParticlesMode", showParticlesMode() );
}
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);
}
示例#9
0
Figure::Marker Figure::show(SDL_Rect* otherCamera) {
   if (marker == INACTIVE)
      return marker;
   else if (marker == REMOVE) {
      bool animationDone = false;
      marker = INACTIVE;

      if (animationDone) {
         //TODO: Add animation and sound for this
         //do a special animation if needed for however many frames
      }

      return marker;
   }
   else if (marker == ACTIVE) {
      if (numClips > 0) {
         if (v.x < 0) {
            status = LEFT;
            animationFrame += AFVALUE;
         }
         else if (v.x > 0) {
            status = RIGHT;
            animationFrame += AFVALUE;
         }
         else
            animationFrame = 0;

         if (animationFrame >= numClips)
            animationFrame = 0;

         if (leader) {
            if (status == LEFT)
               applySurface((int) p.x - camera->x, (int) p.y - camera->y,
                     *image, screen, &cl[static_cast<int>(animationFrame)]);
            else if (status == RIGHT)
               applySurface((int) p.x - camera->x, (int) p.y - camera->y,
                     *image, screen, &cr[static_cast<int>(animationFrame)]);

            if (particleEffects)
               showParticles(camera);
         }
         else {
            if (status == LEFT)
               applySurface((int) p.x - otherCamera->x,
                     (int) p.y - otherCamera->y, *image, screen,
                     &cl[static_cast<int>(animationFrame)]);
            else if (status == RIGHT)
               applySurface((int) p.x - otherCamera->x,
                     (int) p.y - otherCamera->y, *image, screen,
                     &cr[static_cast<int>(animationFrame)]);

            if (particleEffects)
               showParticles(otherCamera);
         }
      }

      return marker;
   }
   else
      throw InvalidMarkerException();
}