LUAMTA_FUNCTION(particle_emitter, EmitParticle) { auto self = my->ToParticleEmitter(1); self->EmitParticles(my->ToNumber(2)); return 0; }
/// // Update time-based variables // void Update ( ESContext *esContext, float deltaTime ) { UserData *userData = ( UserData * ) esContext->userData; userData->time += deltaTime; EmitParticles ( esContext, deltaTime ); }
int CGutParticle::Simulate(float time_advance) { // `发射新粒子` EmitParticles(time_advance); // `粒子运动模拟` AnimateParticles(time_advance); return m_iNumParticles; }
void Particle::Frame(float frameTime) { // Release old particles. KillParticles(); // Emit new particles. EmitParticles(frameTime); // Update the position of the particles. UpdateParticles(frameTime); }
bool ParticleSystemClass::Frame(float frameTime, ID3D11DeviceContext* deviceContext, D3DXVECTOR3 emitterPosition, D3DXVECTOR3 camPos) { bool result; KillParticles(); EmitParticles(frameTime, emitterPosition); UpdateParticles(frameTime, camPos); result = UpdateBuffers(deviceContext); //updating dynamic vertex buffer with new position of each particle if(!result) { return false; } return true; }
bool ParticleSystemClass::Frame(float frameTime, ID3D11DeviceContext* deviceContext) { bool result; // Release old particles. KillParticles(); // Emit new particles. EmitParticles(frameTime); // Update the position of the particles. UpdateParticles(frameTime); // Update the dynamic vertex buffer with the new position of each particle. result = UpdateBuffers(deviceContext); if(!result) { return false; } return true; }
//Frame Particle System bool CParticleSystem::Frame(ID3D11DeviceContext* deviceContext, float frameTime, CCamera* mainCamera) { bool result; //Release previous Particles KillParticles(); //Emit new Particles EmitParticles(frameTime); //Update positions of Particles UpdateParticles(frameTime); //Update Buffers (Dynamic) result = UpdateBuffers(deviceContext, mainCamera); if (!result) { return false; } return true; }
//Main loop of the system void GPUParticleSystem::Update(ID3D11Device* device, ID3D11DeviceContext* deviceContext, float dt) { EmitParticles(deviceContext, dt); UpdateParticles(deviceContext, dt); elapsedTime += dt; //Timer that allows the system to select numbers from the random texture const float timer = 1.0f; if (elapsedTime > timer) { elapsedTime -= timer; } //Handles the rotation of the camera DirectX::XMMATRIX matRot; DirectX::XMMATRIX matTrans; matRot = DirectX::XMMatrixRotationY(rot); matTrans = DirectX::XMMatrixTranslation(0.0f, 0.0f, 0.0f); DirectX::XMMATRIX matFinal = matTrans * matRot; DirectX::XMStoreFloat4x4(&m_World, matFinal); }
void CollisionSystem::SolveCollision(std::shared_ptr<Entity> entity1, std::shared_ptr<Entity> entity2) { if (reproductionEnabled && Engine::GetInstance().HasComponent(entity1, "ReproductionComponent") && Engine::GetInstance().HasComponent(entity2, "ReproductionComponent")) { if (ReproduceEntities(entity1, entity2)) return; } if (complexityEnabled && Engine::GetInstance().HasComponent(entity1, "ComplexityComponent") && Engine::GetInstance().HasComponent(entity2, "ComplexityComponent")) { EmitParticles(entity1); EmitParticles(entity2); } if (Engine::GetInstance().HasComponent(entity1, "InfectionComponent") && Engine::GetInstance().HasComponent(entity2, "InfectionComponent")) { if (TransmitInfection(entity1, entity2)) return; } else if (Engine::GetInstance().HasComponent(entity2, "InfectionComponent") && Engine::GetInstance().HasComponent(entity1, "InfectionComponent")) { if (TransmitInfection(entity2, entity1)) return; } if (Engine::GetInstance().HasComponent(entity1, "ComplexityComponent") && Engine::GetInstance().HasComponent(entity2, "CellParticleComponent")) IncorporateEntity(entity1, entity2); else if (Engine::GetInstance().HasComponent(entity2, "ComplexityComponent") && Engine::GetInstance().HasComponent(entity1, "CellParticleComponent")) IncorporateEntity(entity2, entity1); else if (Engine::GetInstance().HasComponent(entity1, "GrowthComponent") && Engine::GetInstance().HasComponent(entity2, "EatableComponent")) EatEntity(entity1, entity2); else if (Engine::GetInstance().HasComponent(entity2, "GrowthComponent") && Engine::GetInstance().HasComponent(entity1, "EatableComponent")) EatEntity(entity2, entity1); else if (Engine::GetInstance().HasComponent(entity1, "CombatComponent") && Engine::GetInstance().HasComponent(entity2, "CombatComponent")) CombatEntities(entity1, entity2); else if (Engine::GetInstance().HasComponent(entity1, "SlowingComponent") && Engine::GetInstance().HasComponent(entity2, "ParticleComponent")) SlowEntity(entity1, entity2); else if (Engine::GetInstance().HasComponent(entity2, "SlowingComponent") && Engine::GetInstance().HasComponent(entity1, "ParticleComponent")) SlowEntity(entity2, entity1); else if (Engine::GetInstance().HasComponent(entity1, "VitaminComponent") && Engine::GetInstance().HasComponent(entity2, "GrowthComponent")) VitaminateEntity(entity1, entity2); else if (Engine::GetInstance().HasComponent(entity2, "VitaminComponent") && Engine::GetInstance().HasComponent(entity1, "GrowthComponent")) VitaminateEntity(entity2, entity1); else if (Engine::GetInstance().HasComponent(entity1, "VitaminComponent") && Engine::GetInstance().HasComponent(entity2, "ParticleComponent")) return; else if (Engine::GetInstance().HasComponent(entity2, "VitaminComponent") && Engine::GetInstance().HasComponent(entity1, "ParticleComponent")) return; else CollideBodies(entity1, entity2); }