void SpritePackerHelper::ReloadParticleSprites(SceneData* sceneData) { List<Entity*> particleEffects; sceneData->GetAllParticleEffects(particleEffects); for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it) { Entity* curNode = (*it); ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT)); if (!effectComponent) { continue; } effectComponent->Stop(); // All the children of this Scene Node must have Emitter components. int32 emittersCount = curNode->GetChildrenCount(); for (int32 i = 0; i < emittersCount; i ++) { Entity* childNode = curNode->GetChild(i); ParticleEmitter * emitter = GetEmitter(childNode); if (!emitter) { continue; } emitter->ReloadLayerSprites(); } effectComponent->Start(); } }
void CommandRemoveParticleEmitterForce::Execute() { // Need to know selected Layer Node to add the Force to. BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); ForceParticleEditorNode* forceNode = dynamic_cast<ForceParticleEditorNode*>(selectedNode); if (!forceNode || !forceNode->GetRootNode()) { return; } // Mark the "parent" Layer Node to selection. forceNode->GetLayerEditorNode()->SetMarkedToSelection(true); ParticleEffectComponent * effectComponent = forceNode->GetParticleEffectComponent(); if (effectComponent) { effectComponent->Stop(); } ParticlesEditorController::Instance()->RemoveParticleForceNode(forceNode); if (effectComponent) { effectComponent->Restart(); } // Update the scene graph. QtMainWindowHandler::Instance()->RefreshSceneGraph(); }
void CommandAddParticleEmitterLayer::Execute() { // Need to know selected Particle Emitter Layers Root. BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); EmitterParticleEditorNode* emitterNode = dynamic_cast<EmitterParticleEditorNode*>(selectedNode); if (!emitterNode) { return; } ParticleEffectComponent * effectComponent = emitterNode->GetParticleEffectComponent(); DVASSERT(effectComponent); effectComponent->Stop(); // Lets select this node when the tree will be rebuilt. LayerParticleEditorNode* layerNode = ParticlesEditorController::Instance()->AddParticleLayerToNode(emitterNode); if (layerNode) { layerNode->SetMarkedToSelection(true); } effectComponent->Restart(); // Update the scene graph. QtMainWindowHandler::Instance()->RefreshSceneGraph(); }
void ParticleEffectSystem::Process() { float32 timeElapsed = SystemTimer::Instance()->FrameDelta(); size = components.size(); for(index = 0; index < size; ++index) { ParticleEffectComponent * component = static_cast<ParticleEffectComponent*>(components[index]); component->EffectUpdate(timeElapsed); } }
void CommandRestartParticleEffect::Execute() { BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); EffectParticleEditorNode* effectNode = dynamic_cast<EffectParticleEditorNode*>(selectedNode); if (!effectNode || !effectNode->GetRootNode() || !effectNode->GetRootNode()) { return; } ParticleEffectComponent * effectComponent = effectNode->GetParticleEffectComponent(); DVASSERT(effectComponent); effectComponent->Restart(); }
Component * ParticleEffectComponent::Clone(Entity * toEntity) { ParticleEffectComponent * newComponent = new ParticleEffectComponent(); newComponent->SetEntity(toEntity); newComponent->stopAfterNRepeats = stopAfterNRepeats; newComponent->stopWhenEmpty = stopWhenEmpty; newComponent->needEmitPlaybackComplete = needEmitPlaybackComplete; newComponent->playbackComplete = playbackComplete; newComponent->effectDuration = effectDuration; newComponent->emittersCurrentlyStopped = emittersCurrentlyStopped; return newComponent; }
void CommandStartStopParticleEffect::Execute() { BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); EffectParticleEditorNode* effectNode = dynamic_cast<EffectParticleEditorNode*>(selectedNode); if (!effectNode || !effectNode->GetRootNode()) { return; } ParticleEffectComponent* effectComponent = effectNode->GetParticleEffectComponent(); if (this->isStart) { effectComponent->Start(); } else { effectComponent->Stop(); } }
void SpritePackerHelper::EnumerateSpritesForReloading(SceneData* sceneData, Map<String, Sprite *> &sprites) { List<Entity*> particleEffects; sceneData->GetAllParticleEffects(particleEffects); for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it) { Entity* curNode = (*it); ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT)); if (!effectComponent) { continue; } effectComponent->Stop(); // All the children of this Scene Node must have Emitter components. int32 emittersCount = curNode->GetChildrenCount(); for (int32 i = 0; i < emittersCount; i ++) { Entity* childNode = curNode->GetChild(i); ParticleEmitter * emitter = GetEmitter(childNode); if (!emitter) { continue; } Vector<ParticleLayer*> & layers = emitter->GetLayers(); int32 layersCount = layers.size(); for (int il = 0; il < layersCount; ++il) { Sprite *sprite = layers[il]->GetSprite(); sprites[sprite->GetRelativePathname()] = sprite; } } effectComponent->Start(); } }
EffectParticleEditorNode* ParticlesEditorController::RegisterParticleEffectNode(Entity* effectNode, bool autoStart) { if (!effectNode) { Logger::Warning("ParticlesEditorController::RegisterParticleEffectNode(): node is NULL!"); return NULL; } EffectParticleEditorNode* rootNode = new EffectParticleEditorNode(effectNode); this->particleEffectNodes[effectNode] = rootNode; if (autoStart) { ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(effectNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT)); DVASSERT(effectComponent); effectComponent->Start(); } return rootNode; }
void CommandAddParticleEmitterForce::Execute() { // Need to know selected Layer Node to add the Force to. BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); LayerParticleEditorNode* layerNode = dynamic_cast<LayerParticleEditorNode*>(selectedNode); if (!layerNode || !layerNode->GetRootNode()) { return; } ParticleEffectComponent * effectComponent = layerNode->GetParticleEffectComponent(); DVASSERT(effectComponent); effectComponent->Stop(); ForceParticleEditorNode* forceNode = ParticlesEditorController::Instance()->AddParticleForceToNode(layerNode); if (forceNode) { forceNode->SetMarkedToSelection(true); } effectComponent->Restart(); // Update the scene graph. QtMainWindowHandler::Instance()->RefreshSceneGraph(); }
void SpritePackerHelper::EnumerateSpritesForReloading(SceneData* sceneData, Map<String, Sprite *> &sprites) { List<Entity*> particleEffects; sceneData->GetAllParticleEffects(particleEffects); for (auto it = particleEffects.begin(); it != particleEffects.end(); ++it) { Entity* curNode = (*it); ParticleEffectComponent * effectComponent = cast_if_equal<ParticleEffectComponent*>(curNode->GetComponent(Component::PARTICLE_EFFECT_COMPONENT)); if (!effectComponent) { continue; } bool isStopped = effectComponent->IsStopped(); if (!isStopped) { effectComponent->Stop(); } // All the children of this Scene Node must have Emitter components. int32 emittersCount = curNode->GetChildrenCount(); for (int32 i = 0; i < emittersCount; i ++) { Entity* childNode = curNode->GetChild(i); ParticleEmitter * emitter = GetEmitter(childNode); EnumerateSpritesForParticleEmitter(emitter, sprites); } if (!isStopped) { effectComponent->Start(); } } }