本文整理汇总了C++中ParticleSystem::addParticle方法的典型用法代码示例。如果您正苦于以下问题:C++ ParticleSystem::addParticle方法的具体用法?C++ ParticleSystem::addParticle怎么用?C++ ParticleSystem::addParticle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParticleSystem
的用法示例。
在下文中一共展示了ParticleSystem::addParticle方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createParticles
void createParticles() {
Particle p1 = Particle();
unsigned int i;
srand(time(NULL)); // for rand function
if (objFile) {
maxX = vertexes[0].getX();
maxY = vertexes[0].getY();
maxZ = vertexes[0].getZ();
for(i = 0; i < vertexes.size(); i++) {
//p1 = Particle(0.02, 0.0, 3.0, 998.29, 0, 3.5, vertexes[i], Vector(0, 0, 0));
p1 = Water(vertexes[i]);
if (maxX < vertexes[i].getX()) {
maxX = vertexes[i].getX();
}
if (maxY < vertexes[i].getY()) {
maxY = vertexes[i].getY();
}
if (maxZ < vertexes[i].getZ()) {
maxZ = vertexes[i].getZ();
}
pSystem.addParticle(p1);
}
pSystem.setBoundaries(-maxX, -1, -maxZ, maxX + 1, maxY + 1, maxZ + 1);
} else {
for(i = 0; i < numParticles/2; i++) {
p1 = Water();
pSystem.addParticle(p1);
}
for(; i < numParticles; i++) {
p1 = Mucus();
pSystem.addParticle(p1);
}
}
}
示例2: update
void Demo::update() {
Vec2f gravity = Vec2f(0, 0.01);
particleSystem->applyForce(gravity);
float dx = lmap((float)getMousePos().x, 0.0f, (float)getWindowWidth(), -0.2f, 0.2f);
Vec2f wind = Vec2f(dx, 0);
particleSystem->applyForce(wind);
particleSystem->addParticle();
particleSystem->update();
}
示例3: lmap
void NOC_4_08_ParticleSystemSmokeApp::draw()
{
gl::clear( Color::black() );
// Calculate a "wind" force based on mouse horizontal position
float dx = lmap( mousePos.x, 0.0f, float( getWindowWidth() ), -0.2f, 0.2f );
Vec2f wind = Vec2f( dx, 0 );
ps.applyForce(wind);
for( int i = 0; i < 2; i++ ){
ps.addParticle();
}
ps.run();
// Draw an arrow representing the wind force
drawVector( wind, Vec2f( getWindowWidth() / 2, 50 ), 500 );
}
开发者ID:FreeArtBureau,项目名称:The-Nature-of-Code-Examples,代码行数:17,代码来源:NOC_4_08_ParticleSystemSmokeApp.cpp
示例4: AddParticleStartingAt
void AddParticleStartingAt(Vec4<float> WorldPoint) {
ParticleSystem* ps = ModelerApplication::Instance()->GetParticleSystem();
for (int i = 0; i < VAL(PARTICLE_COUNT) * 5 ; i++) {
float mag = rand() % 10 / 10.0 + 0.2;
float theta = rand() % 360 / 57.3;
float yVelocity = rand() % 10 / 10.0 + 2;
float xVelocity = cos(theta) * mag;
float zVelocity = sin(theta) * mag * 3;
//printf("add: %f, %f, %f\n", WorldPoint[0], WorldPoint[1], WorldPoint[2]);
Vec3f position(WorldPoint[0], WorldPoint[1], WorldPoint[2]);
Vec3f velocity(xVelocity, 5, zVelocity);
Particle* p = new PointObj(1.0f, position, velocity);
//printf("added: %f, %f, %f\n", p->getPosition()[0], p->getPosition()[1], p->getPosition()[2]);
ps->addParticle(p);
}
}
示例5: keyboard
void keyboard(unsigned char key, int x, int y) {
Particle p1;
switch(key) {
case ' ': // allow spacebar to end the program
exit(0);
break;
case 'b':
maxX = 1;
maxY = 0;
maxZ = 1;
bBoxScene = false;
bxScene = false;
bzScene = false;
bNoBound = true;
pSystem.setBoundaries(-maxX, -1, -maxZ, maxX, maxY, maxZ);
break;
case 'p':
p1 = Water();
p1.setPosition(Point3D(0,.1,0));
pSystem.addParticle(p1);
break;
case 'o':
for(float i = 0.; i < 5; i++){
for(float j = 0.; j < 5; j++){
for(float k = 0.; k < 5; k++){
p1 = Mucus();
p1.setPosition(Point3D(i/50,j/50-.2,k/50));
pSystem.addParticle(p1);
}
}
}
break;
case 'w':
for(float i = 0.; i < 5; i++){
for(float j = 0.; j < 5; j++){
for(float k = 0.; k < 5; k++){
p1 = Water();
p1.setPosition(Point3D(i/50,j/50-.2,k/50));
pSystem.addParticle(p1);
}
}
}
break;
case 'x': // opens up x portion of boundary
bBoxScene = false;
bxScene = true;
bzScene = false;
bNoBound = false;
pSystem.setBoundaries(-1, -1, -.1, .1, 0, .1);
break;
case 'z': // open up z portion of the boundary
bBoxScene = false;
bxScene = false;
bzScene = true;
bNoBound = false;
pSystem.setBoundaries(-.1, -1, -.2, .1, 0, .1);
break;
case 'c': // change camera
camera++;
if (camera > numcameras)
camera = 1;
break;
default:
break;
}
glutPostRedisplay();
}
示例6: perform
void ParticleFactory::perform(const double elapsedSeconds, const Vec2f origin, const Listener& list, ParticleSystem & ps)
{
double offsetSeconds = elapsedSeconds + d_adjustSeconds - d_offsetTime;
if (offsetSeconds < 0)
ci::app::console() << "waiting for song to start..." << std::endl;
if (offsetSeconds >= 30 && offsetSeconds < 45)
{
while (ps.mParticles.size() < 3)
{
Particle* particle = new ParticleG(origin, list);
ps.addParticle(particle);
}
}
if (offsetSeconds >= 45 && offsetSeconds < 75)
{
Particle* particle = new ParticleC(origin, list);
ps.addParticle(particle);
}
if (offsetSeconds >= 75 && offsetSeconds < 105)
{
Particle* particle = new ParticleB(origin, list);
ps.addParticle(particle);
}
if (offsetSeconds >= 105 && offsetSeconds < 135)
{
Particle* particle = new ParticleL(origin, list);
ps.addParticle(particle);
}
if (offsetSeconds >= 135 && offsetSeconds < 150)
{
Particle* particle = new ParticleI(origin, list);
ps.addParticle(particle);
}
if (offsetSeconds >= 135 && offsetSeconds < 165)
{
for (int i = 0; i < (int)(list.getVolume()*10.f); ++i)
{
Particle* particle = new ParticleD(origin, list);
ps.addParticle(particle);
}
for (int i = 0; i < 3; ++i)
{
Particle* particle = new ParticleA(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
}
}
if (offsetSeconds >= 165 && offsetSeconds < 195)
{
for (int i = 0; i < 4; ++i)
{
Particle* particle = new ParticleH(origin, list);
ps.addParticle(particle);
}
}
if (offsetSeconds >= 195 && offsetSeconds < 210)
{
for (int i = 0; i < 4; ++i)
{
Particle* particle = new ParticleF(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
}
Particle* particle = new ParticleE(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
}
if (offsetSeconds >= 210 && offsetSeconds < 225)
{
Particle* particle = new ParticleJ(origin, list);
ps.addParticle(particle);
}
if (offsetSeconds >= 225 && offsetSeconds < 255)
{
Particle* particle = new ParticleN(origin, list);
ps.addParticle(particle);
}
if (offsetSeconds >= 255 )
{
Particle* particle = new ParticleK(origin, list);
ps.addParticle(particle);
}
}
示例7: create
void ParticleFactory::create(const double elapsedSeconds, const Vec2f origin, const Listener& list, ParticleSystem & ps)
{
ps.mUnderlays = 3;
switch (d_particleToCreate)
{
case PARTICLE_A:{
for (int i = 0; i < 3; ++i)
{
Particle* particle = new ParticleA(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
}
}break;
case PARTICLE_B:{
Particle* particle = new ParticleB(origin, list);
ps.addParticle(particle);
}break;
case PARTICLE_C:{
Particle* particle = new ParticleC(origin, list);
ps.addParticle(particle);
}break;
case PARTICLE_D:{
for (int i = 0; i < (int)(list.getVolume()*20.f); ++i)
{
Particle* particle = new ParticleD(origin, list);
ps.addParticle(particle);
}
}break;
case PARTICLE_E:{
Particle* particle = new ParticleE(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
}break;
case PARTICLE_F:{
for (int i = 0; i < 4; ++i)
{
Particle* particle = new ParticleF(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
}
}break;
case PARTICLE_G:{
while (ps.mParticles.size() < 3)
{
Particle* particle = new ParticleG(origin, list);
ps.addParticle(particle);
}
}break;
case PARTICLE_H:{
for (int i = 0; i < 4; ++i)
{
Particle* particle = new ParticleH(origin, list);
ps.addParticle(particle);
}
}break;
case PARTICLE_I:{
Particle* particle = new ParticleI(origin, list);
ps.addParticle(particle);
}break;
case PARTICLE_J:{
Particle* particle = new ParticleJ(origin, list);
ps.addParticle(particle);
}break;
case PARTICLE_K:{
Particle* particle = new ParticleK(origin, list);
ps.addParticle(particle);
}break;
case PARTICLE_L:{
Particle* particle = new ParticleL(origin, list);
ps.addParticle(particle);
}break;
case PARTICLE_M:{
Particle* particle = new ParticleM(origin, list);
particle->mOrientation = ps.mOrientation;
ps.addParticle(particle);
ps.mUnderlays = 1;
}break;
case PARTICLE_N:{
Particle* particle = new ParticleN(origin, list);
ps.addParticle(particle);
}break;
default:
ci::app::console() << "UNKNOWN PARTICLE: " << d_particleToCreate;
break;
}
}
示例8: update
void Demo::update() {
particleSystem->addParticle();
particleSystem->update();
}