本文整理汇总了C++中ParticleSet::reincarnate方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSet::reincarnate方法的具体用法?C++ ParticleSet::reincarnate怎么用?C++ ParticleSet::reincarnate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSet
的用法示例。
在下文中一共展示了ParticleSet::reincarnate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: got_particle
/**
* Get light particles from syllable, add to part_set.
* Actually, reincarnate() is used as a callback. Particles from
* part_set are reborn if available.
* params: num_per_face: if set, will generate this many for each face
* speed: magnitude of velocity vector
* which_surface: which face (or sides can be selected),
* possible values = -1 -> all, BASE, EXTRUDED, SIDES
*/
void AnimatedSyllable3D::get_particles(ParticleSet& part_set, GLfloat speed,
int num_per_face, int which_surface) {
int num_in_face = base_face.polygons.size();
if(num_per_face == -1) {
num_per_face = num_in_face/3;
}
// assign random polygon indices to get particles from
// within faces
vector<int> poly_indices(num_per_face);
for (int i = 0; i < num_per_face; ++i) {
poly_indices.push_back( rand() % num_in_face );
}
// color
vec4 col;
// velocity temps
Vec vel;
vec3 vel3;
// center of syllable
// Vec syll_center = center;
Vec syll_center = assigned_center;
// ray to vertex on face
Vec ray_from_center;
// cout << "get_particles: syll_center: " << syll_center << endl;
copyv(col, ambient_diffuse);
col[3] = 1.0;
bool got_particle(false);
// cout << "get_particles: color: " << stringv(col, 4) << endl;
// generate particles and add to part_set
for (size_t i = 0; i < poly_indices.size(); ++i) {
int index = poly_indices[i];
Polygon *p;
// Particle p1(1.0, col), p2(1.0, col);
p = base_face.polygons[index];
// use center of poly and facet norm
// copyv(p1.position, vertices[p->verts[0]]);
// copyv(p1.position, p->center);
ray_from_center = Vec(p->center) - syll_center;
// set direction * speed factor as particle's velocity
// direction: custom for syllables on cylinder
// base face normals point inward in xz towards y axis
Vec n = p->facetnorm;
// try adding ray from center to the normal and normalizing
vel = n + ray_from_center;
vel = vel.unit_vec() * speed;
vel.array_out(vel3);
// if(i == 100) cout << "base vel vec: " << vel << endl;
got_particle = part_set.reincarnate(col, p->center, vel3);
// do the same for the extruded face
p = extruded_face.polygons[index];
ray_from_center = Vec(p->center) - syll_center;
n = p->facetnorm;
// try adding ray from center to the normal and normalizing
vel = n + ray_from_center;
vel = vel.unit_vec() * speed;
vel.array_out(vel3);
// if(i == 100) cout << "extr vel vec: " << vel << endl;
got_particle = part_set.reincarnate(col, p->center, vel3);
}
}