void ParticlesEditorSceneModelHelper::BuildEntitiesSets(EffectParticleEditorNode* node, Entity* effectRootNode, Set<Entity*>& entitiesInParticleEditor, Set<Entity*>& entitiesInSceneGraph) { for (List<BaseParticleEditorNode*>::const_iterator iter = node->GetChildren().begin(); iter != node->GetChildren().end(); iter ++) { EmitterParticleEditorNode* childNode = dynamic_cast<EmitterParticleEditorNode*>(*iter); if (!childNode || !childNode->GetEmitterNode()) { continue; } entitiesInParticleEditor.insert(childNode->GetEmitterNode()); } // Build the set of nodes present int emittersCountInEffect = effectRootNode->GetChildrenCount(); for (int32 i = 0; i < emittersCountInEffect; i ++) { // Create the new Emitter and add it to the tree. Entity* effectEntity = effectRootNode->GetChild(i); if (!effectEntity) { continue; } entitiesInSceneGraph.insert(effectEntity); } }
void ParticlesEditorController::FindEmitterEditorNode(Entity* emitterSceneNode, EffectParticleEditorNode** effectEditorNode, EmitterParticleEditorNode** emitterEditorNode) { for (PARTICLESEFFECTITER iter = particleEffectNodes.begin(); iter != particleEffectNodes.end(); iter ++) { const BaseParticleEditorNode::PARTICLEEDITORNODESLIST& emitterEditorNodes = iter->second->GetChildren(); for (List<BaseParticleEditorNode*>::const_iterator innerIter = emitterEditorNodes.begin(); innerIter != emitterEditorNodes.end(); innerIter ++) { EmitterParticleEditorNode* innerNode = dynamic_cast<EmitterParticleEditorNode*>(*innerIter); if (innerNode && innerNode->GetEmitterNode() == emitterSceneNode) { *effectEditorNode = iter->second; *emitterEditorNode = innerNode; break; } } // If the emitter editor found during inner loop - break the outer one too. if (*effectEditorNode && *emitterEditorNode) { break; } } }
void CommandSaveParticleEmitterToYaml::Execute() { BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); EmitterParticleEditorNode* emitterNode = dynamic_cast<EmitterParticleEditorNode*>(selectedNode); if (!emitterNode || !emitterNode->GetEmitterNode()) { return; } ParticleEmitter * emitter = emitterNode->GetParticleEmitter(); if (!emitter) { return; } FilePath yamlPath = emitter->GetConfigPath(); if (this->forceAskFilename || yamlPath.IsEmpty() ) { QString projectPath = QString(EditorSettings::Instance()->GetParticlesConfigsPath().GetAbsolutePathname().c_str()); QString filePath = QFileDialog::getSaveFileName(NULL, QString("Save Particle Emitter YAML file"), projectPath, QString("YAML File (*.yaml)")); if (filePath.isEmpty()) { return; } yamlPath = FilePath(filePath.toStdString()); } emitter->SaveToYaml(yamlPath); }
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 CommandLoadParticleEmitterFromYaml::Execute() { BaseParticleEditorNode* selectedNode = ParticlesEditorController::Instance()->GetSelectedNode(); EmitterParticleEditorNode* emitterNode = dynamic_cast<EmitterParticleEditorNode*>(selectedNode); if (!emitterNode || !emitterNode->GetEmitterNode()) { return; } QString projectPath = QString(EditorSettings::Instance()->GetParticlesConfigsPath().GetAbsolutePathname().c_str()); Logger::Debug("Project path: %s", projectPath.toStdString().c_str()); QString filePath = QFileDialog::getOpenFileName(NULL, QString("Open Particle Emitter Yaml file"), projectPath, QString("YAML File (*.yaml)")); if (filePath.isEmpty()) { return; } // In case this emitter already has Editor Nodes - remove them before loading. ParticlesEditorController::Instance()->CleanupParticleEmitterEditorNode(emitterNode); ParticleEmitter* emitter = emitterNode->GetParticleEmitter(); if(!emitter) { return; } emitter->LoadFromYaml(filePath.toStdString()); // Perform the validation of the Yaml file loaded. String validationMessage; if (ParticlesEditorSceneDataHelper::ValidateParticleEmitter(emitter, validationMessage) == false) { ShowErrorDialog(validationMessage); } QtMainWindowHandler::Instance()->RefreshSceneGraph(); }