SceneGraphItem* ParticlesEditorSceneModelHelper::GetGraphItemForParticlesLayer(GraphItem* rootItem, DAVA::ParticleLayer* layer) { // Check fot the current root SceneGraphItem* curItem = dynamic_cast<SceneGraphItem*>(rootItem); if (curItem && curItem->GetExtraUserData()) { LayerParticleEditorNode* editorNode = dynamic_cast<LayerParticleEditorNode*>(curItem->GetExtraUserData()); if (editorNode && editorNode->GetLayer() == layer) { return curItem; } } // Verify for all children. int32 childrenCount = rootItem->ChildrenCount(); for (int32 i = 0; i < childrenCount; i ++) { SceneGraphItem* curItem = dynamic_cast<SceneGraphItem*>(rootItem->Child(i)); SceneGraphItem* resultItem = GetGraphItemForParticlesLayer(curItem, layer); if (resultItem) { return resultItem; } } // Nothing is found... return NULL; }
void ParticlesEditorController::RemoveParticleForceNode(ForceParticleEditorNode* forceNode) { if (!forceNode || !forceNode->GetLayerEditorNode()) { return; } LayerParticleEditorNode* layerNode = forceNode->GetLayerEditorNode(); ParticleLayer* layer = layerNode->GetLayer(); if (!layer) { return; } // If the selected node is one to be removed - clean it up. CleanupSelectedNodeIfDeleting(forceNode); // Remove the force from the emitter... int forceIndex = forceNode->GetForceIndex(); layer->RemoveForce(forceIndex); // ...and from the tree. layerNode->RemoveChildNode(forceNode); // Done removing, recalculate the indices and names. layerNode->UpdateForcesIndices(); }
void CommandRemoveParticleEmitterLayer::Execute() { // Need to know selected Layer Node to remove it. BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); LayerParticleEditorNode* layerNode = dynamic_cast<LayerParticleEditorNode*>(selectedNode); if (!layerNode || !layerNode->GetRootNode()) { return; } // Mark the "parent" Emitter Node to selection. layerNode->GetEmitterEditorNode()->SetMarkedToSelection(true); ParticleEffectComponent * effectComponent = layerNode->GetParticleEffectComponent(); if (effectComponent) { effectComponent->Stop(); } ParticlesEditorController::Instance()->RemoveParticleLayerNode(layerNode); 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(); }
bool ParticlesEditorSceneModelHelper::GetCheckableStateForGraphItem(GraphItem* graphItem) const { LayerParticleEditorNode* layerEditorNode = GetLayerEditorNodeByGraphItem(graphItem); if (!layerEditorNode || !layerEditorNode->GetLayer()) { return false; } return !layerEditorNode->GetLayer()->GetDisabled(); }
void ParticlesEditorSceneModelHelper::SetCheckableStateForGraphItem(GraphItem* graphItem, bool value) { LayerParticleEditorNode* layerEditorNode = GetLayerEditorNodeByGraphItem(graphItem); if (!layerEditorNode || !layerEditorNode->GetLayer()) { return; } // Execute the appropriate command. CommandsManager::Instance()->ExecuteAndRelease(new CommandUpdateParticleLayerEnabled(layerEditorNode->GetLayer(), value)); }
void ParticlesEditorController::EmitSelectedNodeChanged(bool forceRefresh) { if (this->selectedNode == NULL) { emit EmitterSelected(NULL, this->selectedNode); return; } // Determine the exact node type and emit the event needed. EffectParticleEditorNode* effectEditorNode = dynamic_cast<EffectParticleEditorNode*>(this->selectedNode); if (effectEditorNode) { emit EmitterSelected(NULL, this->selectedNode); emit EffectSelected(effectEditorNode->GetRootNode()); return; } EmitterParticleEditorNode* emitterEditorNode = dynamic_cast<EmitterParticleEditorNode*>(this->selectedNode); if (emitterEditorNode) { emit EmitterSelected(emitterEditorNode->GetEmitterNode(), this->selectedNode); return; } LayerParticleEditorNode* layerEditorNode = dynamic_cast<LayerParticleEditorNode*>(this->selectedNode); if (layerEditorNode) { emit LayerSelected(layerEditorNode->GetEmitterNode(), layerEditorNode->GetLayer(), this->selectedNode, forceRefresh); return; } ForceParticleEditorNode* forceEditorNode = dynamic_cast<ForceParticleEditorNode*>(this->selectedNode); if (forceEditorNode) { emit ForceSelected(forceEditorNode->GetEmitterNode(), forceEditorNode->GetLayer(), forceEditorNode->GetForceIndex(), this->selectedNode); return; } // Cleanip the selection in case we don't know what to do. Logger::Warning("ParticlesEditorController::EmitSelectedNodeChanged() - unknown selected node type!"); EmitterSelected(NULL, this->selectedNode); }
void CommandCloneParticleEmitterLayer::Execute() { // Need to know selected Layer Node to remove it. BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); LayerParticleEditorNode* layerNode = dynamic_cast<LayerParticleEditorNode*>(selectedNode); if (!layerNode) { return; } LayerParticleEditorNode* clonedNode = ParticlesEditorController::Instance()->CloneParticleLayerNode(layerNode); if (clonedNode) { clonedNode->SetMarkedToSelection(true); } // Update the scene graph. QtMainWindowHandler::Instance()->RefreshSceneGraph(); }
void ParticlesEditorSceneModelHelper::UpdateLayerRepresentation(GraphItem* rootItem, DAVA::ParticleLayer* layer, SceneGraphModel* sceneGraphModel) { // Get the appropriate Scene Graph Item. SceneGraphItem* layerItem = GetGraphItemForParticlesLayer(rootItem, layer); if (!layerItem) { return; } // Extract the Particle Editor Node from it... LayerParticleEditorNode* layerNode = GetLayerEditorNodeByGraphItem(layerItem); if (!layerNode) { return; } bool innerEmitterExistedBeforeSync = (layerNode->GetInnerEmittersCount() > 0); // ... and do the synchronization for inner emitters. SynchronizeInnerEmitterNode(layerNode, layerItem, sceneGraphModel); }
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(); }