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 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(); } }
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(); } } }