Exemplo n.º 1
0
void Particle::draw() 
{
	//if (!vertexArrayIDParticle)
		generateParticle();
	glBindVertexArray(vertexArrayIDParticle);
	glDrawArrays(GL_TRIANGLES, 0, 3*3);
}
Exemplo n.º 2
0
void ParticleEngine::generateBloodEffect(const sf::Vector2f& position){
	//generate static particles to remain
	for(int i=1;i<=40;i++){
		float radius = (float)(rand() % 4 + 1);
		sf::Color colour(rand() % 50 + 150,0,0);
		sf::Vector2f pos = sf::Vector2f((float)(rand() % 50 - 25),(float)(rand() % 40 - 25)) + position;
		generateStatic(pos,colour,radius);
	}
	for(float x=-1;x<=1;){
		for(float y= -1;y <= 1;){
			float radius = (float)(rand() % 5 + 3);
			sf::Color colour(rand() % 50 + 150,0,0);
			sf::Vector2f pos = sf::Vector2f((float)(rand() % 50 - 25),(float)(rand() % 40 - 25)) + position;
			sf::Vector2f direction = sfld::Vector2f(x,y).normalise();
			float r = (float)(rand() % 4 + 1)/10.0f;
			std::shared_ptr<Particle> particle = generateParticle(pos,rand() % 250 + 50,colour,radius,direction,r);
			particle->mtype = Particle::blood;
			y += 0.2f;
		}
		x+=0.2f;
	}
	/*for(float x=0;x>=1;){
		for(float y= 1;y <= 0;){
			float radius = 1;
			sf::Color colour(rand() % 50 + 150,0,0);
			sf::Vector2f pos = sf::Vector2f(rand() % 50 - 25,rand() % 40 - 25) + position;
			sf::Vector2f direction = maths::normalise(sf::Vector2f(x,y));
			generateParticle(pos,1000,colour,radius,direction,0.1);
			y -= 0.1;
		}
		x+=0.1;
	}*/

}
Exemplo n.º 3
0
void ParticleEngine::generateMiniExplosionEffect(const sf::Vector2f& position){
	for(float x=-0.3f;x<=0.3f;){
		for(float y= -0.3f;y <= 0.3f;){
			float radius = (float)(rand() % 5 + 5);
			sf::Color colour(255,rand() % 150 + 50,rand() % 50);
			sf::Vector2f pos = sf::Vector2f((float)(rand() % 20 - 10),(float)(rand() % 20 - 10)) + position;
			sf::Vector2f direction = sfld::Vector2f(x,y).normalise();
			float r = (float)(rand() % 2 + 1)/10.0f;
			std::shared_ptr<Particle> particle = generateParticle(pos,rand() % 250 + 50,colour,radius,direction,r);
			y += 0.1f;
		}
		x+=0.1f;
	}
}
Exemplo n.º 4
0
void Particles::setPhysics(b2World * world, float pos_x, float pos_y, float width, float height , bool dynamic){
    this->world = world;
    this->pos_x = pos_x;
    this->pos_y = pos_y;
    this->width = width;
    this->height = height;

    int32 count = 4;
    this->world = world;
    glm::vec3 *vertices_tmp = new glm::vec3[count];

    vertices_tmp[0].x = FLT_MAX;
    vertices_tmp[2].x = FLT_MIN;
    vertices_tmp[0].y = FLT_MAX;
    vertices_tmp[2].y = FLT_MIN;

    for(ObjectVertex &i : vertices){
        if(vertices_tmp[0].x > i.position.x){
            vertices_tmp[0].x = i.position.x;
            vertices_tmp[3].x = i.position.x;
        }
        if(vertices_tmp[0].y > i.position.y){
            vertices_tmp[0].y = i.position.y;
            vertices_tmp[2].y = i.position.y;
        }
        if(vertices_tmp[2].x < i.position.x){
            vertices_tmp[2].x = i.position.x;
            vertices_tmp[1].x = i.position.x;
        }
        if(vertices_tmp[2].y < i.position.y){
            vertices_tmp[2].y = i.position.y;
            vertices_tmp[3].y = i.position.y;
        }
    }


    scale.x = (RADIUS_OF_PARTICLE*2)/(vertices_tmp[2].x - vertices_tmp[0].x);


    scale.y = (RADIUS_OF_PARTICLE*2)/(vertices_tmp[2].y - vertices_tmp[0].y);

    scale.z = scale.y;


    for(int i = 0; i < 100 ; ++i){
        generateParticle();
    }
}
Exemplo n.º 5
0
StatusCode ConstPtParticleGun::getNextEvent(HepMC::GenEvent& theEvent) {
  Gaudi::LorentzVector theFourMomentum;
  Gaudi::LorentzVector origin;
  // note: pgdid is set in function generateParticle
  int thePdgId;
  generateParticle(theFourMomentum, origin, thePdgId);

  // create HepMC Vertex --
  // by calling add_vertex(), the hepmc event is given ownership of the vertex
  HepMC::GenVertex* v = new HepMC::GenVertex(HepMC::FourVector(origin.X(), origin.Y(), origin.Z(), origin.T()));
  // create HepMC particle --
  // by calling add_particle_out(), the hepmc vertex is given ownership of the particle
  HepMC::GenParticle* p = new HepMC::GenParticle(
      HepMC::FourVector(theFourMomentum.Px(), theFourMomentum.Py(), theFourMomentum.Pz(), theFourMomentum.E()),
      thePdgId,
      1);  // hepmc status code for final state particle

  v->add_particle_out(p);

  theEvent.add_vertex(v);
  theEvent.set_signal_process_vertex(v);

  return StatusCode::SUCCESS;
}