void initDustParticles(float xPos, float yPos) { unsigned short dustIdx[NUMBER_OF_DUST_PARTICLES]; int index; dustParticles = NUMBER_OF_DUST_PARTICLES; if (dust != NULL) free(dust); dust = (PARTICLE *)malloc(NUMBER_OF_DUST_PARTICLES * sizeof(PARTICLE)); for (index=0;index<NUMBER_OF_DUST_PARTICLES;index++) createDustParticle(index, xPos, yPos, rand()%10); for(unsigned int i = 0; i< NUMBER_OF_DUST_PARTICLES; i++) dustIdx[i] = (short)i; glGenBuffers(1, &dustBuffObj); glBindBuffer(GL_ARRAY_BUFFER, dustBuffObj); glBufferData(GL_ARRAY_BUFFER, sizeof(dustPos), dustPos, GL_STATIC_DRAW); glGenBuffers(1, &dustIndxBuffObj); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dustIndxBuffObj); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(dustIdx), dustIdx, GL_STATIC_DRAW); }
void CLevitate::Update(float timeDelta) { float a; if(!arxtime.is_paused()) { this->currdurationang += timeDelta; ulCurrentTime += timeDelta; this->currframetime = timeDelta; m_stoneDelay -= timeDelta; } //animation cone this->ang = (float)this->currdurationang / 1000.f; if(this->ang > 1.f) { this->currdurationang = 0; this->ang = 1.f; } int dustParticles = 0; switch(this->key) { case 0: //monté du cone a = (float) ulCurrentTime / 1000.f; if(a > 1.f) { a = 0.f; this->key++; } m_coneScale = a; dustParticles = 3; break; case 1: //animation cone m_coneScale = (float)ulCurrentTime / (float)ulDuration; if(ulCurrentTime >= ulDuration) { m_coneScale = 1.f; this->key++; } dustParticles = 10; break; } for(int i = 0; i < dustParticles; i++) { createDustParticle(); } if(m_stoneDelay <= 0) { m_stoneDelay = Random::get(50, 150); AddStone(m_pos + randomOffsetXZ(m_baseRadius)); } }
void createDustParticle(int index) { int radius = 1; float xPos, yPos, zPos; xPos = 1.0 * (rand() % 1000 - 500) /1000.0; zPos = 1.0 * (rand() % 1000 - 500) /1000.0; yPos = -.3 + sqrt(radius - zPos* zPos) -(xPos * xPos); createDustParticle(index, xPos, yPos, zPos); }
void LevitateSpell::Update(float timeDelta) { ulCurrentTime += timeDelta; Vec3f target; if(m_target == PlayerEntityHandle) { target = player.pos + Vec3f(0.f, 150.f, 0.f); player.levitate = true; } else { target = entities[m_caster]->pos; } m_pos = target; float coneScale = 0.f; int dustParticles = 0; if(ulCurrentTime < 1000) { coneScale = (float) ulCurrentTime / 1000.f; dustParticles = 3; } else { coneScale = 1.f; dustParticles = 10; } cone1.Update(timeDelta, m_pos, coneScale); cone2.Update(timeDelta, m_pos, coneScale); m_stones.Update(timeDelta, m_pos); for(int i = 0; i < dustParticles; i++) { createDustParticle(); } cone1.Render(); cone2.Render(); m_stones.DrawStone(); ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos); }
void LevitateSpell::Update() { Vec3f target; if(m_target == EntityHandle_Player) { target = player.pos + Vec3f(0.f, 150.f, 0.f); player.levitate = true; } else { target = entities[m_caster]->pos; } m_pos = target; float coneScale = 0.f; int dustParticles = 0; if(m_elapsed < GameDurationMs(1000)) { coneScale = m_elapsed / GameDurationMs(1000); dustParticles = 3; } else { coneScale = 1.f; dustParticles = 10; } cone1.Update(g_gameTime.lastFrameDuration(), m_pos, coneScale); cone2.Update(g_gameTime.lastFrameDuration(), m_pos, coneScale); m_stones.Update(g_gameTime.lastFrameDuration(), m_pos); for(int i = 0; i < dustParticles; i++) { createDustParticle(); } cone1.Render(); cone2.Render(); m_stones.DrawStone(); ARX_SOUND_RefreshPosition(m_snd_loop, entities[m_target]->pos); }
void moveParticles() { double dt = .01; // printf("this is called at %lf\n", glfwGetTime()); UpdateParticles(dust,dustParticles,physical,springs,nsprings,dt,1, 1); int dustPosNum = 0; int index = 0; for(index = 0; index < dustParticles; index++) { if(dust[index].age > dust[index].lifespan) { if(glfwGetTime() < 4) { createDustParticle(index); // printf("created a new particle at %lf\n", glfwGetTime()); } else dustParticles--; } else { dustPos[index*3] = dust[index].p.x; dustPos[index*3+1] = dust[index].p.y; dustPos[index*3+2] = dust[index].p.z; } } glGenBuffers(1, &dustBuffObj); glBindBuffer(GL_ARRAY_BUFFER, dustBuffObj); glBufferData(GL_ARRAY_BUFFER, sizeof(dustPos), dustPos, GL_STATIC_DRAW); UpdateParticles(snow,snowParticles,physical,springs,nsprings,dt,1, 1); int snowPosNum = 0; for(index = 0; index < snowParticles; index++) { if(snow[index].age > snow[index].lifespan) { createSnowParticle(index); } else { snowPos[index*3] = snow[index].p.x; snowPos[index*3+1] = snow[index].p.y; snowPos[index*3+2] = snow[index].p.z; } } glGenBuffers(1, &snowBuffObj); glBindBuffer(GL_ARRAY_BUFFER, snowBuffObj); glBufferData(GL_ARRAY_BUFFER, sizeof(snowPos), snowPos, GL_STATIC_DRAW); }